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

Re: Configuring Keys F1 to F12



In the last episode (Feb 11), zzapper said:
> Anthony Charles wrote in news:20110211095705.GD17063@xxxxxxxxxxxxxxx:
> > On Thu, Feb 10, 2011 at 05:39:54PM +0000, zzapper wrote:
> >> Anthony Charles wrote in news:20110210153454.GC17063@xxxxxxxxxxxxxxx:
> >> >  bindkey -s '^v<F7>' 'ls -l'
> >> 
> >> Anthony thanks works a treat:-
> >> what I failed to realise is that you have to actually type
> >> 
> >> (Control-v F7)
> >> which on my system displays as:-
> >> 
> >> bindkey -s "^[[18~" 'ls -l'
> >> 
> >> Yhis is going to be hyper useful : thanks
> >> 
> > You're welcome, sorry for being unclear.
> > 
> Anthony my fault not yours; I've just realized where I was BLOCKING!
> 
> I was trying to enter the bindkey straight into my zsh config file whereas
> i should have been generating the key sequence on the command line
> 
> so 
> bindkey -s "^[[18~" 'ls -l'
> 
> goes into ~/.zshrc

You could use something like this:

# usage: bindtc <cap> <default> <string>
bindtc () 
{
        local keyval=${termcap[$1]:-$2}
        [[ -n $keyval ]] bindkey -s $keyval $3
}

I use something similar to bind commands to things like pgup and pgdn, whose
escape sequences vary across terminals.  With it, you can run:

bindtc k7 "^[[18~" 'ls -l'

which will use the termcap entry for F7, or if it's missing, will fall back
to "^[[18~".

-- 
	Dan Nelson
	dnelson@xxxxxxxxxxxxxxx



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