UNIX shell tricks: find the escape sequence a keypress
If you ever need to figure out what escape code is generated when you press Ctrl-Left Arrow on a random terminal process, try the following:
cat > /dev/null
<press your random key sequence here, followed by enter>
You’ll end up with the escape sequence being printed directly to the terminal window. This is useful when you’re setting up things like bindkey statements in your .screenrc.
(Hat tip to Jonathan Daugherty.)
2 March 2008