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

Re: How to rebind the hyphen in .zshrc?



2009/10/16 Guido van Steen <gvsteen@xxxxxxxxx>:
> Dear all,
>
> In my .zshrc file I would like to include something like:
>
> rebind-hyphen {
>        # intended pre-processing
>        zle .self-insert
>        # intended post-processing
> }
>
> zle -N rebind-hyphen
> bindkey "-" rebind-hyphen
>
> This produces the following error:
>
> "rebind-hyphen" undefined-key
>
> If I add:
>
> bindkey "a" rebind-hyphen
>
> or
>
> bindkey " " rebind-hyphen
>
> there is no error at all and "a" or " " gets bound.
>
> So, I guess hyphen must be a special input character to zsh.
>
> Is there a way around this??
>
> Thanks!
>
> Guido

The trick is a - starts an option, so you have to say you aren't
giving any more options with the standard method:
bindkey -- - whatever

You have to do that when aliasing something beginning with + or - too:
alias -- +x='chmod +x'

I just noticed now though that I had just one hyphen in my .zshrc and
that works too, so I'm not sure which is canonical, both appear to
work though.

-- 
Mikael Magnusson



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