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

Re: Expanding global aliases on key press



2009/2/25 Thorsten Kampe <thorsten@xxxxxxxxxxxxxxxx>:
> 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...

This seems much simpler:
global-alias-space () { zle _expand_alias; zle .self-insert }
zle -N global-alias-space
bindkey ' ' global-alias-space
zstyle :completion:\* regular false    # I can't figure out how to
specify this more exactly

-- 
Mikael Magnusson



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