Have you ever tried to complete a command that takes longer time? Like a remote server path completion for scp
. It takes few moments and after pressing <TAB>
you don’t know if there is nothing to be completed or the shell is just waiting for a reply. And when the list is opened you don’t know which letter is the next one?
Visual hint that signals waiting:
expand-or-complete-with-dots() {
echo -n "\e[31m...\e[0m"
zle expand-or-complete
zle redisplay
}
zle -N expand-or-complete-with-dots
bindkey "^I" expand-or-complete-with-dots
Well, this ain’t anything new and it is also included in oh-my-zsh. Let’s look at another problem. I like a visual hint for a next character to be selected in ambiguities list. This can be solved e.g. by setting this:
zstyle -e ':completion:*:default' list-colors \
'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==90=01}:${(s.:.)LS_COLORS}")'
I also like AUTO_LIST
because it completes the common prefix and shows ambiguities list on the first <TAB>
press. However this has a little glitch if you combine it with the previous highlighting trick. The highlighting appears only for the typed characters and not the whole common prefix.
This trick fixes it (also not my invention):
unambigandmenu() {
zle expand-or-complete
zle magic-space
zle backward-delete-char
zle expand-or-complete
}
zle -N unambigandmenu
bindkey "^i" unambigandmenu
Works like a charm until you hit a larger list which requires your answer to the question of life “zsh: do you wish to see all 229 possibilities (58 lines)?“. It will be asked twice because you have expand-or-complete
twice. Turning off and on the AUTO_LIST
around the first expand-or-complete
fixes it.
Combined all together:
LISTMAX=0
unsetopt LIST_AMBIGUOUS MENU_COMPLETE COMPLETE_IN_WORD
setopt AUTO_MENU AUTO_LIST LIST_PACKED
unambigandmenu() {
echo -n "\e[31m...\e[0m"
# avoid opening the list on the first expand
unsetopt AUTO_LIST
zle expand-or-complete
setopt AUTO_LIST
zle magic-space
zle backward-delete-char
zle expand-or-complete
zle redisplay
}
zle -N unambigandmenu
bindkey "^i" unambigandmenu
No Comments
No comments yet.
RSS feed for comments on this post.
Sorry, the comment form is closed at this time.