Assigning
UNIX commands to Function Keys
Assigning regularly used commands to your keyboard function keys can speed up your daily work! This works in `tcsh' (but should work with `bash' in a similar way, since `bash' offers an equivalent methode of assigning commands). When using `bash' you must use the `bash' equivalent command for tcsh's "bindkey" shell built-in command! The most commonly used command i've to type as regular
user is `/bin/su -'. Since i don't like typing it every time i've assigned
Follow the instructions below: Add the statements below to your ~/.cshrc (or respectively your ~/.tcshrc) to make the assignments permanent!!! E.g. to assign " = /bin/su - " use: bindkey -c "^[[224z" "echo Switching to root account:; /bin/su -" Where "^[[224z" is the escape sequence on my SUN Type 5 keyboard generated by and ^[ is the ESC character. The -c tells bindkey to interprete the command as external or builtin command instead of an editor command. Be aware of the double quotes around the escape sequence! They are mandatory! You can also assign "parts" of a command to a function
key and by pressing that function the shell writes a "template" to
Lets assume you've to type "find / -xdev -name 'lib*.so'"
very often! Then you could assign this to a function key. To assign
bindkey -c -s "^[[227z" "find / -xdev -name '" By pressing the shell will write to stdout:
The -s switch tells tcsh that the command is taken as a literal string and treated as terminal input when is typed. The escape sequences may vary depending on your keyboard/OS
but using a simple /bin/csh or tcsh shell you can retrieve the
user@host> ^V will respond with ^[[225z where ^[ represents the ESC character! user@host> ^V will respond with ^[[226z where ^[ represents the ESC character!
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|