Skip to content Accesskey=4Skip to sub-navigation Accesskey=3View our Accessibility Options MIT Information Systems Home About IS&T Contact IS&T Site Map Search Advanced Search
Getting StartedGetting Services by Topic or Alphabetically Getting Help

On This Page

[Help]

  

Quick Links

Top Level

Related Links

Ask OLC a question

Athena Consulting Homepage

Helpdesk Stock Answers (for Mac/PC questions)


Tcsh FUNCTION KEY bindings

It is possible to bind the function keys to csh commands, though this is a
long and ugly process.  Here are instructions.  All this information is
avaiable in the manual entry for "tcsh".

You can define a keymap to contain aliases to unix commands.  Unlike emacs,
tcsh only allows a single character as a keymap component, so multiple levels
of keymaps are required (as many as there are characters in the function key
escape sequences: 5).

The first step is to create a keymap for character sequences beginning ESC-[
(as all special keys do on our keyboards):


	create_keymap esc_km
	set_keymap meta '[' prefix esc_km

Next you need to handle all possible next characters.  These are the letters A
to D and the numbers 1 to 3:

	create_keymap esc1_km
	create_keymap esc2_km
	create_keymap esc3_km

	set_keymap esc_km A previous_history
	set_keymap esc_km B next_history
	set_keymap esc_km C forward_char
	set_keymap esc_km D backward_char
	set_keymap esc_km 1 prefix esc1_km
	set_keymap esc_km 2 prefix esc2_km
	set_keymap esc_km 3 prefix esc3_km

The arrow keys have been taken care of, but the function keys put out two more
characters still.  A keymap for each possible next character, in each possible
keymap, should be created:

	create_keymap f1_keymap 
	create_keymap f2_keymap 
	create_keymap f3_keymap 
	create_keymap f4_keymap 
	create_keymap f5_keymap 
	create_keymap f6_keymap 
	create_keymap f7_keymap 
	create_keymap f8_keymap 
	create_keymap f9_keymap 
	create_keymap f10_keymap 
	create_keymap f11_keymap 
	create_keymap f12_keymap 
	create_keymap f13_keymap 
	create_keymap f14_keymap 

These should be bound to the appropriate previous keymap:

	set_keymap esc1_km 1 prefix f1_keymap
	set_keymap esc1_km 2 prefix f2_keymap
	set_keymap esc1_km 3 prefix f3_keymap
	set_keymap esc1_km 4 prefix f4_keymap
	set_keymap esc1_km 5 prefix f5_keymap
	set_keymap esc1_km 7 prefix f6_keymap
	set_keymap esc1_km 8 prefix f7_keymap
	set_keymap esc1_km 9 prefix f8_keymap
	set_keymap esc2_km 0 prefix f9_keymap
	set_keymap esc2_km 1 prefix f10_keymap
	set_keymap esc2_km 3 prefix f11_keymap
	set_keymap esc2_km 4 prefix f12_keymap
	set_keymap esc2_km 5 prefix f13_keymap
	set_keymap esc2_km 6 prefix f14_keymap

The last step is to create a binding for the character '~' in each of these
keymaps, as that is the last character produced by all function keys.  The
simplest binding is a unix command:

	set_keymap f1_keymap '~' unix_command 'echo -n "F1 pressed"'

A popular binding is to set a function key to alias to "|more <RETURN>".

A complete list of possibilities can be found in the "tcsh" man page.

If you do not want to bind all the keys, some of the keymaps can be deleted.
For example, esc3_km is only useful on the vax, where function key numbers go
past 30.

This is the list function key codes:

	# On both vax and rt the function keys emit "ESC [ # ~"
	# The keys map to values of "#" as follows:
	# F1            11
	# ...
	# F5            15
	# F6            17
	# ...
	# F10           21
	# F11           23      (RT only; this is "escape" on the vax)
	# F12           24
	# F13           25      (Vax only; no such key on RT)
	# F14           26      (Vax only; no such key on RT)
	# UP arrow      A
	# DOWN arrow    B
	# LEFT arrow    D
	# RIGHT arrow   C

MIT Home | Getting Started | Getting Services | Getting Help | About IS&T | Accessibility
Ask a technology question or send a comment about this web page.