We help IT Professionals succeed at work.

Alias for function keys?

_marko_
_marko_ asked
on
Hi!

Is there a way to bind the function keys as aliases in .bashrc (or some other file) through a remote connection (PuTTY)? For example: when I press F1 it should automatically do an 'ssh -l user su.wopr.zebulun.fi'.

Marko
Comment
Watch Question

Top Expert 2005
Commented:
Yes, see 'man readline' for information about binding things to keys. You need to know what ASCII codes a key is represented by and you can equate those codes to any arbitrary command in ~/.inputrc. As an example, having:

"\eOP": "date\r"

in my .inputrc file causes the system date to be printed when I hit the F1 key. To find out what codes are sent for a key I execute xemacs in a terminal window (xemacs -nw) and use quoted-insert to (usually bound to ctrl-q) display the ASCII codes for the key in question. The same thing should also work for emacs.

Author

Commented:
Yes! Thank you!

The correct lines for me are as follows:

"\e[11~":"date\r"
"\e[12~":"ssh -l user su.wopr.zebulun.fi\r"

:-)


Marko

Author

Commented:
BTW, they don't work under screen :(

Oh well, I seldomly use screen anyway...


Marko
Top Expert 2005

Commented:
screen might be filtering the input stream, or it may not be using the same keymap. I don't use screen so I've never checked to see what it might do with the keymap.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.