Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Expanding global aliases on key press



Hi,

I've read the new German Zsh book that was mentioned here some time ago 
(by the way: a huuuuge disappointment) and I've found this particular 
widget to expand global aliases on pressing blank:

#
global-alias-space()
    { local ga="$LBUFFER[(w)-1]"
      [[ -n $ga ]] && LBUFFER[(w)-1]="${${galiases[$ga]}:-$ga}"
      zle self-insert;}

zle -N global-alias-space
bindkey ' ' global-alias-space
#

Can anyone comment on the code, please?

Additionally I've adapted this widget to be bound to the Enter key:

#
accept-line()
    { local ga="$LBUFFER[(w)-1]"
      [[ -n $ga ]] && LBUFFER[(w)-1]="${${galiases[$ga]}:-$ga}"
      zle .accept-line;}

zle -N accept-line
#

I'd also like to hear your comments on that...


Thorsten



Messages sorted by: Reverse Date, Date, Thread, Author