With bash
you can make file globbing drop __pycache__
, by setting:
$ export GLOBIGNORE=__pycache__
Now if you issue:
$ ls __*
ls: cannot access __*: No such file or directory
Also with bash
You can use the FIGNORE
environment variable to skip file suffixes. It can be used to somewhat filter the directory...
$ mkdir __pycache__
$ export FIGNORE=__pycache__
Then when issuing:
$ ls __
tab
will complete to
$ ls __pycache__
However, if it is prefixed (such as using a path):
$ ls ./__
tab
it will not complete.
You can alias grep
to exlude the __pycache__
directories:
alias grep='grep --exclude-dir="__pycache__"'
You could also use Madhavan Kumar's answer to change the completion of grep
and the other commands you want to filter, but don't forget they will have to be defined in a rc file and sourced after sourcing bash_completion
, to apply your overrides.
FIGNORE
A colon-separated list of suffixes to ignore when performing filename
completion (see READLINE below). A filename whose suffix matches one of
the entries in FIGNORE is excluded from the list of matched filenames. A
sample value is ".o:~".
GLOBIGNORE
A colon-separated list of patterns defining the set of filenames to
be ignored by pathname expansion. If a filename matched by a pathname
expansion pattern also matches one of the patterns in GLOBIGNORE, it is
removed from the list of matches.