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
this command (and others) to my function keys. How to do in `tcsh'?
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
stdout which you can finish on your command line. Assume the following example:
Lets assume you've to type "find / -xdev -name 'lib*.so'" very often!
Then you could assign this to a function key. To assign
this to e.g. use:
bindkey -c -s "^[[227z" "find / -xdev -name '"
By pressing the shell will write to stdout:
find / -xdev -name ' and then you can finish this command line with your desired args.
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
escape sequences for your keyboard. At your (t)csh shell prompt type ^V (press down the CONTROL key and the V key)
followed by the key for which you want to know it's escape sequences and the shell will respond with that key's escape
sequence. Example (works with /bin/csh and tcsh):
will respond with ^[[225z where ^[ represents the ESC character!
will respond with ^[[226z where ^[ represents the ESC character!
Have a Unix Problem
Do you have a UNIX Question?
Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books
Return to : - Unix System Administration Hints and Tips
(c) www.gotothings.com All material on this site is
Every effort is made to ensure the content integrity. Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.