I've ignored __pycache__ in my git repos and in vi's wildmenu. The last place these directories pollute my workflow is when recursively grepping through project files and when using tab auto-completion on the command line.Is there a way to configure command-line tools like grep and bash-completion to universally ignore directories?
Can I ignore __pycache__ directories in bash-completion and grep?
bash;autocomplete
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 directoryAlso 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 __tabwill 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. 