1

when I type

cd path/to/python_package/

and press tab to try to fill path/to/python_package/only_module for example, I am stopped dead in my tracks! By

$ cd path/to/python_package/
__pycache__/  only_module/

How can I make tab completion for cd ignore __pycache__? In the future I imagine I will realise there are other folder names I may want to add to the "blacklist" too, does zsh support blacklisting folder names like this?

1 Answer 1

1

You can ignore some patterns in completions by tuning completion styles with the zstyle built-in. There are examples in the zsh guide.

zstyle ':completion:*:*:cd:*:*' ignored-patterns '__pycache__'

Under default settings, zsh tries a second round of completion if there are no matches the first time, and the second round does not honor ignored-patterns, so you can still complete __pycache__ after _ (or whatever it takes for __pycache__ to be the sole potential completion).

2
  • If I want to ignore more folders, do I add them after '__pycache__' like a space-separated argument list? Mar 15, 2021 at 11:50
  • @theonlygusti Yes (… ignored-patterns __pycache__ .cache), or you can use a pattern like … ignored-patterns '(__pycache__|.cache)'. Mar 15, 2021 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.