A quick trick to have custom completion on the aliases I create.
First create the function and the alias, they can be in
~/.bash_aliases or whatever.
echo "Here are the args from my function $@"
Then create the completion function (best practice
underscore+function name) which can be anywhere too. An interesting list of the helpers provided by zsh for the completion functions is here.
compadd "$@" foo bar baz
~/.zshrc we can register
_myCoolFunction as the completion function of
compdef _myCoolFunction myCoolFunction
Once everything is ready in a new shell typing
mcf <TAB> should yield the 3 completions options.
If things don't work one can check the completion function for a particular function (It does not work with the alias) with:
and the implementation with
Finally I should check how to make it work with the defined files (
~/.oh-my-zsh/completions) and understand why the
compdef command only works when put in