I have a shell pattern that marks some files as "boring" namely backup files, pyo
files, vim backups, autogenerated directories and the like. Let's call it $BORING_STUFF
.
zstyle ':completion:*' file-patterns \
'%p:globbed-items' \
'*(^-/):regular-files' \
'*(^-/):boring-files' \
'.*(^-/):hidden-files' \
'*(-/):regular-directories' \
'*(-/):boring-directories' \
'.*(-/):hidden-directories'
In this case, I have the scope of each group also constrained by applicable ignore-patterns
. (Such that boring-files
contains only boring files and regular-files
does not contain boring files)
I'd like bold items to always show up, and other items only show up if there are no other matches. (Aka. touch <tab>
will show regular directories and regular files but not hidden files, while touch .<tab>
will show hidden files.)
Here we go.
setopt extended_glob
zstyle ':completion:*' file-patterns \
"^($BORING_FILES|.*)(-/):directories:normal\ directories %p~($BORING_FILES|.*)(^-/):globbed-files:normal\ files" \
"^($BORING_FILES|.*)(^-/):noglob-files:noglob\ files" \
".*~($BORING_FILES)(^-/):hidden-files:hidden\ files .*~($BORING_FILES)(-/):hidden-directories:hidden\ directories" \
"($BORING_FILES)(^-/):boring-files:boring\ files ($BORING_FILES)(-/):boring-directories:boring\ directories" \
zstyle ':completion:*' group-order \
builtins expansions aliases functions commands globbed-files \
directories hidden-files hidden-directories \
boring-files boring-directories keywords viewable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With