Pregunta

I have the following alias in my ~/.zshrc:

~ which pulseaudio-restart 
pulseaudio-restart: aliased to killall pulseaudio && pulseaudio --start

Is it possible to configure Zsh in a way that typing restart will output me pulseaudio-restart as a suggestion since it contains the string restart?

Currently, typing restart only brings up:

~ rest
restart        restore-trash
¿Fue útil?

Solución

Yes it is possible. For this you have to set/modify the matcher-list style for the completion module. This can be done with the following command:

zstyle ':completion:*' matcher-list 'l:|=* r:|=*' 

This tells the completion to look for completion on the left as well as on the right side of the typed word (specifics can be found in zshcompwid(1)).

As the name matcher-list indicates, there may be more than one match specification, in which case it is important that 'l:|=* r:|=*' is the first one. The specifications are tried in the order they appear until something returns a match.


For oh-my-zsh the matcher-list is set in lib/completion.zsh and it already contains the required specification, but only as the last option. You can either change the order there or add your own settings in ~/.zshrc after oh-my-zsh is loaded.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top