-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to exclude certain files/files a-la .gitignore? #113
Comments
Hello Dmitry,
Dmitry Semenov writes:
```
➜ find . -type f | fzy
>
./.gitignore
./.gitmessage
./.style.yapf
./docker-compose.yml
./docs/async_processing/index.rst
./docs/jupyter/business/.ipynb_checkpoints/Time Periods-checkpoint.ipynb
./docs/jupyter/business/metrics/.ipynb_checkpoints/flow-checkpoint.ipynb
./docs/jupyter/business/metrics/.ipynb_checkpoints/worktypes_weekly_reports-checkpoint.ipynb
./docs/jupyter/business/metrics/.ipynb_checkpoints/Metrics-checkpoint.ipynb
./docs/jupyter/business/metrics/.ipynb_checkpoints/metrics-checkpoint.ipynb
```
so how do I exclude folders and files by extensions? For example, exclude all folders named __pycache__ or files with .ipynb extensions?
You can pipe the find output, e.g.:
`find . -type f | fgrep -v __pycache__ | fzy' or
`find . -type f | grep -v '\.ipynb$' | fzy'.
Alternatively you can also use `ag -l' instead of find(1) that will
honor possible .*ignore files.
|
|
I use this script that I made if it's helpful for others: #!/bin/sh
# NAME
# pfind – dumb file finder for projects
#
# SYNOPSIS
# pfind [-n]
#
# DESCRIPTION
# It just finds files that are checked into a project.
#
# It does not give you any fancy options with which to filter.
usage() {
cat <<EOF >&2
usage: $0 [-n]
EOF
}
args=$(getopt n $*)
if [ $? -ne 0 ]; then
usage
exit 1
fi
use_vcs=1
set -- $args
while [ $# -ne 0 ]; do
case "$1"
in
-n)
use_vcs=0; shift;;
--)
shift; break;;
esac
done
if [ ${use_vcs} -eq 1 ] && git rev-parse --is-inside-work-tree >/dev/null; then
exec git ls-files . --cached --others --exclude-standard 2>/dev/null
else
# fallback on find but limit depth in case we are in ${HOME}, etc.
# exec find . -maxdepth 4 -type f -print 2>/dev/null
exec ag -l --depth 3 2>/dev/null
fi If you do |
@neuschaefer Does git ls-files --cached --others --exclude-standard --recurse-submodules I chucked it in my script thinking it was a nice to have that I was missing (previously I just used
and checking the man page gives:
I've updated my script above to just use |
@casr: Yes, AFAICT it works. |
Lucky! (Thanks for checking) |
so how do I exclude folders and files by extensions? For example, exclude all folders named pycache or files with .ipynb extensions?
Dmitry
The text was updated successfully, but these errors were encountered: