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

Re: ZSH's way to bind function to a key in a script?



When using   "read -k key"

I am matching against normal keys with
if [ $key = '?' ]

simple control characters like tabs with
if (( #key == ##\t ))

Ctrl + key sequences with
(( #key == ##\C-u ))

But how do I match against Alt + key sequences?

Thanks,
Wendell



________________________________
From: Jérémie Roquet <arkanosis@xxxxxxxxx>
To: zsh-users@xxxxxxx
Cc: nix@xxxxxxxxxxxxxxxx
Sent: Wed, March 9, 2011 6:35:48 AM
Subject: Re: ZSH's way to bind function to a key in a script?

2011/3/9  <nix@xxxxxxxxxxxxxxxx>:
> Can't get it working in a script. Tried both vt100/xterm terminals but nada.
> My purpose is this:
>
> while [ : ] ; do
>
> ...
>
> A user press the space button and he will see the script progress ....
>
> done

Then it's unrelated to bindkey ;-)

Try this:

while [ : ]; do
    read -ks a
    [[ $a = ' ' ]] && foo
done

Have a look at “man zshbuiltins” for more about the “read” builtin.

Best regards,

-- 
Jérémie



      


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