Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hiding certain options in zsh autocompletion

There are several commands that have esoteric options that I don't use often. For example, git has 'check-attr'. I use 'git checkout' very often, however, so I'd like, git ch to complete to git checkout or show a menu without check-attr in it. I can do this with zstyle ... ignored-patterns.

However, I'd still like to complete 'git check-attr' if nothing else matches (if I actually do want to run check-attr).

It seems that the 'hidden' zstyle is for me, but how can I specify a value (not just a tag) in the completion context? I.e. I'd like something like, zstyle ':completion:::git::' hidden-patterns 'check-attr'

Is that possible?

like image 813
apo Avatar asked Nov 04 '10 18:11

apo


2 Answers

I don't really know how this works, but the result is that git check<TAB> results in git checkout. Add this to your .zshrc:

zstyle ':completion::complete:git:*:*' ignored-patterns 'check*-*'

See http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Overview-1 for some info, if you can decypher it..

like image 158
aleb Avatar answered Sep 20 '22 09:09

aleb


Something like this should do the trick:

zstyle ':completion::complete:*:git:*' ignored-patterns check-attr
like image 31
Sec Avatar answered Sep 18 '22 09:09

Sec