# File to `source' from within a `[t]csh' script to define key bindings # (by default, emacs-like bindings are defined; the vi-like # equivalents haven't been completely figgured out yet!) # For `tcsh' (but not `csh') script options may be provided to override # the defaults (options may not be bundled, the leading '-' is optional, # and only the first letter of an option argument is actually examined): # -d use default bindings (-e or -v if $version =~ *vi*) # -D use default bindings (-E or -V if $version =~ *vi*) # -e use default emacs-style bindings # -Emacs use default emacs-style bindings plus enhancements # -v use default vi-style bindings # -Vi use default vi-style bindings plus enhancements # If no options are present (or if `csh'), the defaults are: # -E if $?Emacs, else -V if $?Vi, else -D; # -[bm] if (! $?LANG && ! $?LC_TYPE) || $?NOREBIND # -[56] if $TERM =~ *vt{52,61}*; # -7b if $TERM =~ *vt{100,102,125}* || $_8b; # -8b if $TERM =~ *vt{200,201,220,240,300,320,400,420}* || # $TERM =~ {dtterm,vs100*,xpcterm*,xterm*} # Note: the -[dDeEvV]* options are replacive but # the -[bm5678]* options are accumulative. # # Uses: $debug # [if defined, display some debugging info] # $version # [`tcsh' only: check for default `vi' binding] # $Emacs # [if defined, emacs-like bindings are used] # $Uptime # [if defined, $Uptime is bound to C-M-T] # $Stty # [if defined, used to set tty editing chars] # $Vi # [if defined, vi-like bindings are used] # $LANG # [if defined, meta chars are not bound] # $LC_CTYPE # [if defined, meta chars are not bound] # $NOREBIND # [if defined, meta chars bound for ESC seqs] # $TERM # [if defined, determines VT52|VT100|VT200 mode # # and, indirectly, 7|8-bit mode; # # the default is VT100|VT200 in 7-bit mode] # Sets: _52 # VT52 flag # _7b # 7-bit flag # _8b # 8-bit flag # _bm # Bind-Meta flag # _[dD]opt # Use default key bindings # _[eE]opt # Use emacs-style key bindings # _stty # Stty program (or /bin/stty) # _term # Terminal type (or "unknown") # _[vV]opt # Use vi-style key bindings # Unsets: _52 _7b _8b _bm _[dDeEvV]opt _stty _term # Note: VT200 8-bit mode determines whether the 8-bit prefixes # SS3 (\217) and CSI (\233) may be used for the equivalent # two-character ESC prefixes required in VT100 7-bit mode # (namely, the prefixes 'ESC O' and 'ESC ['). # Note: Do NOT confuse 8-bit mode with meta-mode (general 8-bit chars), # but do note that in 8-bit mode the two characters \217 and \233 # cannot be used as meta-characters (i.e., as the meta-character # alternatives for the sequences 'ESC ^O' and 'ESC ESC'); # in VT52-mode, a similar comments apply for \277 as the # meta-character alternative for the sequence 'ESC ?'. # # set _dopt=1; set _Dopt=1 # Default is to do the default! set _eopt=0; set _Eopt=0 set _vopt=0; set _Vopt=0 if ($?Emacs) then set _dopt=0; set _Dopt=0 set _eopt=1; set _Eopt=1 else if ($?Vi) then set _dopt=0; set _Dopt=0 set _vopt=1; set _Vopt=1 endif # if ($?Stty) then set _stty="$Stty" else set _stty='/bin/stty' endif # if ($?LANG || $?LC_CTYPE) then set _bm=0 # Don't bind any meta char for an ESC sequence. else set _bm=1 # Bind the equivalent meta char for an ESC seq. endif if ($?NOREBIND) set _bm=1 # Override? # if ($?TERM) then set _term="$TERM" else set _term='unknown' endif switch ("$_term") case {,[Dd][Ee][Cc]-}[Vv][Tt]{52,61}*: set _52=1 # Bind VT52 ESC sequences. set _7b=0 set _8b=0 breaksw case {,[Dd][Ee][Cc]-}[Vv][Tt]{100,102,125}*: set _52=0 set _7b=1 # Bind VT100 7-bit sequences. set _8b=0 breaksw case {,[Dd][Ee][Cc]-}[Vv][Tt]{200,201,220,240,300,320,400,420}*: set _52=0 set _7b=1 # Bind VT100/200 7-bit sequences. set _8b=1 # Bind VT200 8-bit sequences. breaksw case dtterm: case vs100*: case xpcterm*: case xterm*: # xterm-like generally means VT200-like ... set _52=0 set _7b=1 # Bind VT100/200 7-bit sequences. set _8b=1 # Bind VT200 8-bit sequences. breaksw default: set _52=0 set _7b=1 ### Default ### Emulating VT100/200 7-bit is usually good! set _8b=0 # Don't bother ... endsw # # if ($?tcsh) then while ($#) switch ("$1") case {,-}d*: set _dopt=1; set _Dopt=0 set _eopt=0; set _Eopt=0 set _vopt=0; set _Vopt=0 breaksw case {,-}D*: set _dopt=1; set _Dopt=1 # -D => -d set _eopt=0; set _Eopt=0 set _vopt=0; set _Vopt=0 breaksw case {,-}e*: set _dopt=0; set _Dopt=0 set _eopt=1; set _Eopt=0 set _vopt=0; set _Vopt=0 breaksw case {,-}E*: set _dopt=0; set _Dopt=0 set _eopt=1; set _Eopt=1 # -E => -e set _vopt=0; set _Vopt=0 breaksw case {,-}v*: set _dopt=0; set _Dopt=0 set _eopt=0; set _Eopt=0 set _vopt=1; set _Vopt=0 breaksw case {,-}V*: set _dopt=0; set _Dopt=0 set _eopt=0; set _Eopt=0 set _vopt=1; set _Vopt=1 # -V => -v breaksw case {,-}[bm]*: set _bm=1 breaksw case {,-}[56]*: set _52=1 breaksw case {,-}7*: set _7b=1 breaksw case {,-}8*: set _8b=1 breaksw default: echo "[.bindkey: unrecognized option argument: '$1']" # Error! endsw shift # Advance to next option argument ... end endif if ($_8b) set _7b=1 # This is usually the right thing to do since # many VT200 emulators simply send the 7-bit # sequences rather than the 8-bit ones ... # # if ($_8b) then # Allow 8-bit characters? if ($?debug) echo "[.bindkey: setting 8-bit tty modes (-parenb -istrip cs8)]" $_stty -parenb -istrip cs8 # Yes. endif if ($_eopt || $_Eopt) then # # Set emacs-style tty editing characters # if ($?debug) echo "[.bindkey: setting emacs-style tty editing characters]" $_stty isig icanon iexten \ -ixon -ixoff start '^-' stop '^-' \ intr '^C' quit '^\' erase '^?' kill '^G' \ eof '^D' eol '^M' eol2 '^J' \ swtch '^^' susp '^Z' dsusp '^]' \ rprnt '^L' werase 'ÿ' lnext '^Q' flush '^O' # else if ($_vopt || $_Vopt) then # # Set vi-style tty editing characters # if ($?debug) echo "[.bindkey: setting vi-style tty editing characters]" endif # # if ($?tcsh) then # Skip this if it ain't `tcsh'! # # Define `tcsh' key bindings for command line editing: # if ($_eopt || $_Eopt) then bindkey -e # [Use `emacs'-style key-bindings by default] # [`tcsh' 6.06.00 defaults are marked by #Def!#] # The following functions are available but are not bound # (nor otherwise mentioned) below: # vi-* # # In the following tables, these notations are used to describe the # default, reasonable, redefined, and some speculative key bindings: # *macro -- the (upper-case only) binding is redefined # in VT52-mode (affects some ESC-char seqs) # ¯o -- the (8-bit) binding is redefined # in VT200-mode (affects some M-char seqs) # #macro -- the `tcsh' macro doesn't exist (but should); # may need to be set via `stty' # macro -- the default (and currently used) key binding # -macro -- a removed (or redefined) default key binding # !macro -- an unreasonable (and not used!) key binding # ?macro -- a reasonable (but not used) key binding # +macro -- the redefined binding is a `tcsh' macro # +[command] -- the redefined binding is a unix command # +"string" -- the redefined binding is a text string # +'string' -- the redefined binding is a keystroke sequence # +`command` -- the redefined binding is the output from a # unix command (not fully implemented -- yet!) # =whatever -- some tentative (half-baked?) idea ... # Ahem! # Note that `tcsh' does NOT distinguish between # bindkey -s key "string" # and # bindkey -s key 'string' # or even the simpler (but deprecated) unquoted form # bindkey -s key string # -- O'Reilly's "Using csh & tcsh" (p.92, 1st ed.) is in error here! # The string argument for `bindkey -s' is ALWAYS interpretted as a # keystroke sequence -- the aforementioned notational distinction # between "string" and 'string' is simply to remind us to backslash # all `^'s and `\'s in the former but not in the latter! # Ahem! # Note that `bindkey -s' compiles its argument string (of keystrokes) # into an internal character string. This string is presumably NUL- # terminated, so any internal NUL ('^@' or '\000') will terminate this # string prematurely! To correct for this bug (or is it a feature?), # a definition is made (below) for the keystroke sequence '^[@' which # will be handled as the keystroke '^@' (conventionially bound to the # internal 'set-mark-command') [in 8-bit mode, either '\200' or '\300' # may also be used, but their use is deprecated]. # # Unless otherwise indicated, all graphic characters are bound to # self-insert-command # and, unless otherwise indicated, all non-graphic characters # (which includes all C-, M-, C-M-, and ^X- prefixes) are bound to # undefined-key # Note that C-SPC is a conventional alternative for C-@ (at least # for most VT100 emulators, e.g. `telnet') and that C-? is the usual # shorthand for DEL (which isn't really a control character at all!); # also note that M-x represents either 0200+x (the "meta-bit" set) # or the more conventional two-character sequence ESC-x; similarly, # M-C-x (usually written C-M-x) represents either 0200+^x or ESC-^x). # [It should not need any explaining that ^x simply means C-x, # that C-X and C-x are the same (as are C-M-X and C-M-x), # that M-X and M-x are different (but usually handled similarly), or # that \200 is just another way of representing 0200 -- right?] # # VT200 terminals (and emulators) may send single-character prefixes # when running in 8-bit mode as alternatives to the standard VT100 # two-character prefixes. The important ones are listed below: # # code 7-bit 8-bit # VT100/200 Control Code # ---- ------- ------- ------------------------ # SS3 ESC O \217 (=x8F) # Single Shift G3 # CSI ESC [ \233 (=x9B) # Control Sequence Introducer # ESC ? \277 (=xBF) # [VT52 only!] # The VT52 sequence `ESC ?' may be rendered as `M-?' by some terminal # emulation software; we try to take care of this possibility below ... # if ($_8b) then # $_8b overrides $_bm in the following cases: bindkey -r '\217' # `\217' is needed as a sequence-lead-in bindkey -r '\233' # `\233' is needed as a sequence-lead-in endif if ($_52) then bindkey -r '^[?' # `ESC ?' is needed as a sequence-lead-in if ($_bm) bindkey -r '\277' # `\277' is needed as sequence-lead-in endif # # # Cursor Normal Application VT52 Action # -------- -------- ----------- ------ -------- # Up CSI A SS3 A ESC A up-history # Down CSI B SS3 B ESC B down-history # Right CSI C SS3 C ESC C forward-char # Left CSI D SS3 D ESC D backward-char # # (Non-Normal) # Keypad Normal Application VT52 Action # -------- -------- ----------- ------ -------- # Tab ^I SS3 I ESC ? I +'^I' # Enter ^M SS3 M ESC ? M +'^M' # PF1 SS3 P SS3 P ESC P # PF2 SS3 Q SS3 Q ESC Q # PF3 SS3 R SS3 R ESC R # PF4 SS3 S SS3 S ESC S # KP* * SS3 j ESC ? j # KP+ + SS3 k ESC ? k # KP, , SS3 l ESC ? l # KP- - SS3 m ESC ? m # KP. . SS3 n ESC ? n +overwrite-mode # KP/ / SS3 o ESC ? o # KP0 0 SS3 p ESC ? p +'^[0' # KP1 1 SS3 q ESC ? q +'^[1' # KP2 2 SS3 r ESC ? r +'^[2' # KP3 3 SS3 s ESC ? s +'^[3' # KP4 4 SS3 t ESC ? t +'^[4' # KP5 5 SS3 u ESC ? u +'^[5' # KP6 6 SS3 v ESC ? v +'^[6' # KP7 7 SS3 w ESC ? w +'^[7' # KP8 8 SS3 x ESC ? x +'^[8' # KP9 9 SS3 y ESC ? y +'^[9' # # # Editing Normal Application Action # --------- -------- ----------- -------- # E1(Find) CSI 1 ~ CSI 1 ~ +complete-word-raw # E2(Paste) CSI 2 ~ CSI 2 ~ +yank # E3(Cut) CSI 3 ~ CSI 3 ~ +kill-region # E4(Select) CSI 4 ~ CSI 4 ~ +set-mark-command # E5(Prev) CSI 5 ~ CSI 5 ~ +complete-word-back # E6(Next) CSI 6 ~ CSI 6 ~ +complete-word-fwd # # # Function Normal Application Action # ---------- -------- ----------- -------- # F1(NoScroll) (local function only) # F2 (local function only) # F3 (local function only) # F4 (local function only) # F5(Break) (local function only) # (Ctrl-F5 sends an "answerback" message indentifying the type of terminal) # # F6(Interrupt) CSI 17 ~ CSI 17 ~ +tty-sigintr # F7 CSI 18 ~ CSI 18 ~ # F8 CSI 19 ~ CSI 19 ~ # F9 CSI 20 ~ CSI 20 ~ # F10(Exit) CSI 21 ~ CSI 21 ~ +end-of-file # # F11(Escape) CSI 23 ~ CSI 23 ~ +complete-word # F12(Backspace)CSI 24 ~ CSI 24 ~ +backward-delete-char # F13(Linefeed) CSI 25 ~ CSI 25 ~ +newline # F14(Insert) CSI 26 ~ CSI 26 ~ +overwrite-mode # # F15(Help) CSI 28 ~ CSI 28 ~ +run-help # F16(Do) CSI 29 ~ CSI 29 ~ # # F17 CSI 31 ~ CSI 31 ~ # F18 CSI 32 ~ CSI 32 ~ # F19 CSI 33 ~ CSI 33 ~ # F20 CSI 34 ~ CSI 34 ~ # # # The following table only includes characters that are Control-ifiable; # the desired C-char, M-char, and C-M-char bindings are listed # (these are referred to in the more general table that follows): # # char C-char M-char C-M-char # ---- -------- -------- ---------- # @ set-mark-command +set-mark-command # ` set-mark-command # Aa beginning-of-line *-undefined-key # *+beginning-of-line # Bb backward-char *backward-word +complete-word-back # Cc tty-sigintr *capitalize-word # Dd delete-char-or-list-or-eof *delete-word list-choices # ?delete-char-or-list ?list-choices-raw # ?delete-char-or-eof ?list-or-eof # ?delete-char ?end-of-file # ?end-of-file # Ee end-of-line +end-of-line # Ff forward-char forward-word +complete-word-fwd # Gg -undefined-key # +keyboard-quit # Hh backward-delete-char -run-help -backward-delete-word # +backward-delete-word +run-help # Ii complete-word complete-word # ?complete-word-raw # Jj newline # Kk kill-line +backward-kill-line +kill-whole-line # Ll -clear-screen downcase-word clear-screen # +redisplay # Mm newline +beginning-of-line # Nn down-history history-search-forward ?down-history # ?history-search-forward +history-search-forward # ?i-search-fwd # Oo tty-flush-output &undefined-key # Pp up-history *history-search-backward ?up-history # ?history-search-backward +history-search-backward # ?i-search-back # Qq -tty-start-output *-undefined-key -undefined-key # +quoted-insert *+prefix-meta +stuff-char # Rr -redisplay *toggle-literal-history # +i-search-back +history-search-backward # Ss -tty-stop-output *spell-word # +i-search-fwd +history-search-forward # Tt transpose-chars ?gosmacs-transpose-chars ?load-average # +transpose-gosling +[uptime] # Uu -kill-whole-line upcase-word # ?keyboard-quit # +universal-argument # Vv -quoted-insert # +down-history +up-history # Ww kill-region copy-region-as-kill # !backward-delete-word # Xx sequence-lead-in +change-case +change-till-end-of-line # Yy yank # !#tty-sigdsusp # Zz -tty-sigtsusp run-fg-editor # ?run-fg-editor # +[suspend] # [ sequence-lead-in ?sequence-lead-in &complete-word # &?complete-word-raw # { sequence-lead-in &complete-word # &?complete-word-raw # \ tty-sigquit # | tty-sigquit # ] #tty-sigdsusp # } #tty-sigdsusp # ^ undefined-key # #tty-sigswitch # ~ undefined-key # #tty-sigswitch # _ -undefined-key insert-last-word copy-prev-word # +dabbrev-expand # DEL is the "lower-case" of '_' (see DEL below) # # # The following table lists (almost) all characters; # the desired char, M-char, and ^X-char bindings are listed but all # Control-ified (C-char or C-M-char) or Meta-Control-ifiable (M-char) # bindings are referred back to the previous table (see above): # # char M-char ^X-char # ---- -------- --------- ### Resume editing (for ^X-chars) here! [See similar ###comment### below] ### # ^@ (see above) (see above) undefined-key # ^C (see above) (see above) =[history -S ; exit] # ^D (see above) (see above) list-choices-raw # ^I (see above) (see above) complete-word-raw # ^S (see above) (see above) +[history -S] # ^W (see above) (see above) +[history -S "$<"] # ^X (see above) (see above) exchange-point-and-mark # ^Z (see above) (see above) +[suspend] # # SPC -self-insert-command expand-history ?expand-history # +magic-space +expand-line # ! self-insert-command expand-history +expand-history # ?`$<` ?expand-line # " self-insert-command # # self-insert-command # !backward-delete-char # $ self-insert-command -spell-line expand-variables # +spell-word # % self-insert-command # & self-insert-command # ' self-insert-command # ( self-insert-command # ) self-insert-command # * self-insert-command +list-glob expand-glob # + self-insert-command # , self-insert-command # - self-insert-command # . self-insert-command +overwrite-mode ?normalize-path # / self-insert-command dabbrev-expand +normalize-path # 0 digit digit-argument # ... ... ... # 9 digit digit-argument # : self-insert-command # ; self-insert-command # < self-insert-command +beginning-of-line # = self-insert-command +which-command +normalize-command # > self-insert-command +end-of-line # ? self-insert-command *which-command normalize-command # # @ self-insert-command (see above) # !keyboard-quit # ` self-insert-command (see above) # Gg self-insert-command (see above) list-glob # Nn self-insert-command (see above) normalize-path # Ss self-insert-command (see above) +spell-line # # DEL backward-delete-char backward-delete-word # # ## ### Cursors (usually ESC-sequences) fetched from the TERMCAP entry ## # Nonetheless, define them here to include both the VT200 8-bit # and (if needed) the VT52 cursor sequences. # [Note that the ANSI/VT100 sequences are defined by default.] # if ($_52) bindkey '^[A' up-history # [VT52 "up" arrow] if ($_52 && $_bm) bindkey '\301' up-history # [VT52 meta mode] #Def!# if ($_7b) bindkey '^[[A' up-history # [VT100 (norm) "up" arrow] if ($_8b) bindkey '\233A' up-history # [VT200 8-bit mode] #Def!# if ($_7b) bindkey '^[OA' up-history # [VT100 (appl) "up" arrow] if ($_8b) bindkey '\217A' up-history # [VT200 8-bit mode] # if ($_52) bindkey '^[B' down-history # [VT52 "down" arrow] if ($_52 && $_bm) bindkey '\302' down-history # [VT52 meta mode] #Def!# if ($_7b) bindkey '^[[B' down-history # [VT100 (norm) "down" arrow] if ($_8b) bindkey '\233B' down-history # [VT200 8-bit mode] #Def!# if ($_7b) bindkey '^[OB' down-history # [VT100 (appl) "down" arrow] if ($_8b) bindkey '\217B' down-history # [VT200 8-bit mode] # if ($_52) bindkey '^[C' forward-char # [VT52 "right" arrow] if ($_52 && $_bm) bindkey '\303' forward-char # [VT52 meta mode] #Def!# if ($_7b) bindkey '^[[C' forward-char # [VT100 (norm) "right" arrow] if ($_8b) bindkey '\233C' forward-char # [VT200 8-bit mode] #Def!# if ($_7b) bindkey '^[OC' forward-char # [VT100 (appl) "right" arrow] if ($_8b) bindkey '\217C' forward-char # [VT200 8-bit mode] # if ($_52) bindkey '^[D' backward-char # [VT52 "left" arrow] if ($_52 && $_bm) bindkey '\304' backward-char # [VT52 meta mode] #Def!# if ($_7b) bindkey '^[[D' backward-char # [VT100 (norm) "left" arrow] if ($_8b) bindkey '\233D' backward-char # [VT200 8-bit mode] #Def!# if ($_7b) bindkey '^[OD' backward-char # [VT100 (appl) "left" arrow] if ($_8b) bindkey '\217D' backward-char # [VT200 8-bit mode] # ## ### Keypad keys (usually ESC-sequences in "application mode") ## # Define the VT100 7-bit, the VT200 8-bit, and (if needed) # the VT52 "application mode" keypad sequences. # [Note that PF1 through PF4 are always in "application mode".] # if ($_52) bindkey -s '^[?I' '^I' # [VT52 (appl) "Tab"] if ($_52 && $_bm) bindkey -s '\277I' '^I' # [VT52 meta mode] if ($_7b) bindkey -s '^[OI' '^I' # [VT100 (appl) "Tab"] if ($_8b) bindkey -s '\217I' '^I' # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?M' '^M' # [VT52 (appl) "Enter"] if ($_52 && $_bm) bindkey -s '\277M' '^M' # [VT52 meta mode] if ($_7b) bindkey -s '^[OM' '^M' # [VT100 (appl) "Enter"] if ($_8b) bindkey -s '\217M' '^M' # [VT200 8-bit mode] # #PF1# if ($_52) bindkey '^[P' whatever # [VT52 keypad "PF1"] #PF1# if ($_52 && $_bm) bindkey '\320' whatever # [VT52 meta mode] #PF1# if ($_7b) bindkey '^[OP' whatever # [VT100 keypad "PF1"] #PF1# if ($_8b) bindkey '\217P' whatever # [VT200 8-bit mode] # #PF2# if ($_52) bindkey '^[Q' whatever # [VT52 keypad "PF2"] #PF2# if ($_52 && $_bm) bindkey '\321' whatever # [VT52 meta mode] #PF2# if ($_7b) bindkey '^[OQ' whatever # [VT100 keypad "PF2"] #PF2# if ($_8b) bindkey '\217Q' whatever # [VT200 8-bit mode] # #PF3# if ($_52) bindkey '^[R' whatever # [VT52 keypad "PF3"] #PF3# if ($_52 && $_bm) bindkey '\322' whatever # [VT52 meta mode] #PF3# if ($_7b) bindkey '^[OR' whatever # [VT100 keypad "PF3"] #PF3# if ($_8b) bindkey '\217R' whatever # [VT200 8-bit mode] # #PF4# if ($_52) bindkey '^[S' whatever # [VT52 keypad "PF4"] #PF4# if ($_52 && $_bm) bindkey '\323' whatever # [VT52 meta mode] #PF4# if ($_7b) bindkey '^[OS' whatever # [VT100 keypad "PF4"] #PF4# if ($_8b) bindkey '\217S' whatever # [VT200 8-bit mode] # #KP,# if ($_52) bindkey '^[?l' whatever # [VT52 (appl) "KP,"] #KP,# if ($_52 && $_bm) bindkey '\277l' whatever # [VT52 meta mode] #KP,# if ($_7b) bindkey '^[Ol' whatever # [VT100 (appl) "KP,"] #KP,# if ($_8b) bindkey '\217l' whatever # [VT200 8-bit mode] # #KP-# if ($_52) bindkey '^[?m' whatever # [VT52 (appl) "KP-"] #KP-# if ($_52 && $_bm) bindkey '\277m' whatever # [VT52 meta mode] #KP-# if ($_7b) bindkey '^[Om' whatever # [VT100 (appl) "KP-"] #KP-# if ($_8b) bindkey '\217m' whatever # [VT200 8-bit mode] # if ($_52) bindkey '^[?n' overwrite-mode # [VT52 (appl) "KP."] if ($_52 && $_bm) bindkey '\277n' overwrite-mode # [VT52 meta mode] if ($_7b) bindkey '^[On' overwrite-mode # [VT100 (appl) "KP."] if ($_8b) bindkey '\217n' overwrite-mode # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?p' '^[0' # [VT52 (appl) "KP0"] if ($_52 && $_bm) bindkey -s '\277p' '^[0' # [VT52 meta mode] if ($_7b) bindkey -s '^[Op' '^[0' # [VT100 (appl) "KP0"] if ($_8b) bindkey -s '\217p' '^[0' # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?q' '^[1' # [VT52 (appl) "KP1"] if ($_52 && $_bm) bindkey -s '\277q' '^[1' # [VT52 meta mode] if ($_7b) bindkey -s '^[Oq' '^[1' # [VT100 (appl) "KP1"] if ($_8b) bindkey -s '\217q' '^[1' # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?r' '^[2' # [VT52 (appl) "KP2"] if ($_52 && $_bm) bindkey -s '\277r' '^[2' # [VT52 meta mode] if ($_7b) bindkey -s '^[Or' '^[2' # [VT100 (appl) "KP2"] if ($_8b) bindkey -s '\217r' '^[2' # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?s' '^[3' # [VT52 (appl) "KP3"] if ($_52 && $_bm) bindkey -s '\277s' '^[3' # [VT52 meta mode] if ($_7b) bindkey -s '^[Os' '^[3' # [VT100 (appl) "KP3"] if ($_8b) bindkey -s '\217s' '^[3' # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?t' '^[4' # [VT52 (appl) "KP4"] if ($_52 && $_bm) bindkey -s '\277t' '^[4' # [VT52 meta mode] if ($_7b) bindkey -s '^[Ot' '^[4' # [VT100 (appl) "KP4"] if ($_8b) bindkey -s '\217t' '^[4' # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?u' '^[5' # [VT52 (appl) "KP5"] if ($_52 && $_bm) bindkey -s '\277u' '^[5' # [VT52 meta mode] if ($_7b) bindkey -s '^[Ou' '^[5' # [VT100 (appl) "KP5"] if ($_8b) bindkey -s '\217u' '^[5' # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?v' '^[6' # [VT52 (appl) "KP6"] if ($_52 && $_bm) bindkey -s '\277v' '^[6' # [VT52 meta mode] if ($_7b) bindkey -s '^[Ov' '^[6' # [VT100 (appl) "KP6"] if ($_8b) bindkey -s '\217v' '^[6' # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?w' '^[7' # [VT52 (appl) "KP7"] if ($_52 && $_bm) bindkey -s '\277w' '^[7' # [VT52 meta mode] if ($_7b) bindkey -s '^[Ow' '^[7' # [VT100 (appl) "KP7"] if ($_8b) bindkey -s '\217w' '^[7' # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?x' '^[8' # [VT52 (appl) "KP8"] if ($_52 && $_bm) bindkey -s '\277x' '^[8' # [VT52 meta mode] if ($_7b) bindkey -s '^[Ox' '^[8' # [VT100 (appl) "KP8"] if ($_8b) bindkey -s '\217x' '^[8' # [VT200 8-bit mode] # if ($_52) bindkey -s '^[?y' '^[9' # [VT52 (appl) "KP9"] if ($_52 && $_bm) bindkey -s '\277y' '^[9' # [VT52 meta mode] if ($_7b) bindkey -s '^[Oy' '^[9' # [VT100 (appl) "KP9"] if ($_8b) bindkey -s '\217y' '^[9' # [VT200 8-bit mode] # ## ### Editing keys (usually ESC-sequences) ## # Define both the 7-bit and 8-bit VT200 edit-pad sequences. # if ($_7b) bindkey '^[[1~' complete-word-raw # [7-bit "Find"] if ($_8b) bindkey '\2331~' complete-word-raw # [8-bit "Find"] # if ($_7b) bindkey '^[[2~' yank # [7-bit "Paste"] if ($_8b) bindkey '\2332~' yank # [8-bit "Paste"] # if ($_7b) bindkey '^[[3~' kill-region # [7-bit "Cut"] if ($_8b) bindkey '\2333~' kill-region # [8-bit "Cut"] # if ($_7b) bindkey '^[[4~' set-mark-command # [7-bit "Select"] if ($_8b) bindkey '\2334~' set-mark-command # [8-bit "Select"] # if ($_7b) bindkey '^[[5~' complete-word-back # [7-bit "Prev"] if ($_8b) bindkey '\2335~' complete-word-back # [8-bit "Prev"] # if ($_7b) bindkey '^[[6~' complete-word-fwd # [7-bit "Next"] if ($_8b) bindkey '\2336~' complete-word-fwd # [8-bit "Next"] # ## ### Function keys (usually ESC-sequences) ## # Define both the 7-bit and 8-bit VT200 function-key sequences. # #F1# if ($_7b) bindkey '^[[11~' whatever # [7-bit "F1"] #F1# if ($_8b) bindkey '\23311~' whatever # [8-bit "F1"] # #F2# if ($_7b) bindkey '^[[12~' whatever # [7-bit "F2"] #F2# if ($_8b) bindkey '\23312~' whatever # [8-bit "F2"] # #F3# if ($_7b) bindkey '^[[13~' whatever # [7-bit "F3"] #F3# if ($_8b) bindkey '\23313~' whatever # [8-bit "F3"] # #F4# if ($_7b) bindkey '^[[14~' whatever # [7-bit "F4"] #F4# if ($_8b) bindkey '\23314~' whatever # [8-bit "F4"] # #F5# if ($_7b) bindkey '^[[15~' whatever # [7-bit "F5"] #F5# if ($_8b) bindkey '\23315~' whatever # [8-bit "F5"] # if ($_7b) bindkey '^[[17~' tty-sigintr # [7-bit "F6(Interrupt)"] if ($_8b) bindkey '\23317~' tty-sigintr # [8-bit "F6(Interrupt)"] # #F7# if ($_7b) bindkey '^[[18~' whatever # [7-bit "F7"] #F7# if ($_8b) bindkey '\23318~' whatever # [8-bit "F7"] # #F8# if ($_7b) bindkey '^[[19~' whatever # [7-bit "F8"] #F8# if ($_8b) bindkey '\23319~' whatever # [8-bit "F8"] # #F9# if ($_7b) bindkey '^[[20~' whatever # [7-bit "F9"] #F9# if ($_8b) bindkey '\23320~' whatever # [8-bit "F9"] # if ($_7b) bindkey '^[[21~' end-of-file # [7-bit "F10(Exit)"] if ($_8b) bindkey '\23321~' end-of-file # [8-bit "F10(Exit)"] # if ($_7b) bindkey '^[[23~' complete-word # [7-bit "F11(Escape)"] if ($_8b) bindkey '\23323~' complete-word # [8-bit "F11(Escape)"] # if ($_7b) bindkey '^[[24~' backward-delete-char # [7-bit "F12(Backspace)"] if ($_8b) bindkey '\23324~' backward-delete-char # [8-bit "F12(Backspace)"] # if ($_7b) bindkey '^[[25~' newline # [7-bit "F13(Linefeed)"] if ($_8b) bindkey '\23325~' newline # [8-bit "F13(Linefeed)"] # if ($_7b) bindkey '^[[26~' overwrite-mode # [7-bit "F14(Insert)"] if ($_8b) bindkey '\23326~' overwrite-mode # [8-bit "F14(Insert)"] # if ($_7b) bindkey '^[[28~' run-help # [7-bit "F15(Help)"] if ($_8b) bindkey '\23328~' run-help # [8-bit "F15(Help)"] # #F16# if ($_7b) bindkey '^[[29~' whatever # [7-bit "F16(Do)"] #F16# if ($_8b) bindkey '\23329~' whatever # [8-bit "F16(Do)"] # #F17# if ($_7b) bindkey '^[[31~' whatever # [7-bit "F17"] #F17# if ($_8b) bindkey '\23331~' whatever # [8-bit "F17"] # #F18# if ($_7b) bindkey '^[[32~' whatever # [7-bit "F18"] #F18# if ($_8b) bindkey '\23332~' whatever # [8-bit "F18"] # #F19# if ($_7b) bindkey '^[[33~' whatever # [7-bit "F19"] #F19# if ($_8b) bindkey '\23333~' whatever # [8-bit "F19"] # #F20# if ($_7b) bindkey '^[[34~' whatever # [7-bit "F20"] #F20# if ($_8b) bindkey '\23334~' whatever # [8-bit "F20"] # ## ### Control-characters ## # #Def!# bindkey '^@' set-mark-command # [See also M-@ (below)] #Def!# bindkey '^A' beginning-of-line #Def!# bindkey '^B' backward-char #Def!# bindkey '^C' tty-sigintr # Consider `stty intr "^C"' # [This is the usual default] #Def!# bindkey '^D' delete-char-or-list-or-eof # Consider `stty eof "^D"' # [This is the usual default] #Def!# bindkey '^E' end-of-line #Def!# bindkey '^F' forward-char #Def!# bindkey '^G' undefined-key # [But see below ...] #Def!# bindkey '^H' backward-delete-char # Consider `stty erase "^H"' # [BS is a common default] # or `stty erase "^?"' # [DEL is a common default] #Def!# bindkey '^I' complete-word #Def!# bindkey '^J' newline # Consider `stty eol2 "^J"' # [This is the usual default] #Def!# bindkey '^K' kill-line # [Save in cut buffer] #Def!# bindkey '^L' clear-screen # [But see below ...] #Def!# bindkey '^M' newline # Consider `stty eol "^M"' # [This is the usual default] #Def!# bindkey '^N' down-history # [The "down-arrow" also works here!] #Def!# bindkey '^O' tty-flush-output # Consider `stty flush "^O"' # [This is the usual default] #Def!# bindkey '^P' up-history # [The "up-arrow" also works here!] #Def!# bindkey '^Q' tty-start-output # Consider `stty start "^Q"' # [But see below ...] #Def!# bindkey '^R' redisplay # Consider `stty rprnt "^R"' # [But see below ...] #Def!# bindkey '^S' tty-stop-output # Consider `stty stop "^S"' # [But see below ...] #Def!# bindkey '^T' transpose-chars #Def!# bindkey '^U' kill-whole-line # [Save in cut buffer] # Consider `stty erase "^U"' # [But see below ...] # Should ^U save the discarded input line in the cut buffer? # If "yes", comment out the following `bindkey ^U' definition; # if "no", uncomment the following `bindkey ^U' definition: bindkey '^U' keyboard-quit # [Don't save line in the cut buffer] #Def!# bindkey '^V' quoted-insert # Consider `stty lnext "^V"' # [But see below ...] #Def!# bindkey '^W' kill-region # [NOT 'backward-delete-word'!] # Consider `stty werase "^W"' # [But see below ...] #Def!# bindkey '^X' sequence-lead-in # [All of the ^X-thingies ...] #Def!# bindkey '^Y' yank # [NOT 'tty-sigdsusp'!] # Consider `stty dsusp "^Y"' # [But see below ...] #Def!# bindkey '^Z' tty-sigtsusp # Consider `stty susp "^Z"' # [This is the usual default] # Should ^Z be used for something useful? # Since `tcsh' won't actually honor ^Z for itself, # select one of the following alternative definitions for ^Z: #Edit?# bindkey '^Z' run-fg-editor # [A cheap way back to the "editor"] bindkey -c '^Z' 'suspend' # [Make `tcsh' suspend itself!] #Def!# bindkey '^[' sequence-lead-in # [All of the ESC-thingies ...] #Def!# bindkey '^\' tty-sigquit # Consider `stty quit "^\"' # [This is the usual default] #Def!# bindkey '^]' tty-sigdsusp # [The "delayed suspend" signal] # Consider `stty dsusp "^]"' # ["^Y" is the usual default] #Def!# bindkey '^^' undefined-key ### Consider `stty swtch "^^"' # [I really dunno about this!] #Def!# bindkey '^_' undefined-key bindkey '^_' dabbrev-expand # [Compare 'M-_' and 'C-M-_'] # Note: 'dabbrev-expand' (C-_) completes the current word from words in # the history stack (may be repeated to access older history); # 'insert-last-word' (M-_) simply inserts the final word of the # previous command (i.e., !$) without surrounding whitespace; # 'copy-prev-word' (C-M-_) either duplicates the current word # (without trailing whitspace) or copies the previous word # (with trailing whitespace) if the current word is nil. # ## ### Emacs vs. shell traditions ... ## # # ^N and ^P are (by default) used in `tcsh' for moving to the # next and previous lines of history (much like `emacs'); # ^R and ^S are used in `emacs' for incremental-searches # but are traditionally used for other things in shells # (or by the 'tty'-handler itself); # ^Q and ^S are conventionally used for (re)starting and stopping # output (an old convention that is no longer much needed); # ^L is used in most programs for redisplay purposes but # ^R is used in shells for redisplaying the current input line # (although this is often done by the 'tty'-handler itself); # ^Q is used in `emacs' for quoting the next character but # ^V is used in shells for the identical quoting function # (although this may actually be done by the 'tty'-handler) # and `emacs' uses C-V (and M-V) for scrolling down (and up); # ^G, ^U, ^W, and ^Y also present some `emacs' vs. shell # compatibility problems (but to a somewhat lesser degree). # In general, `tcsh' ignores any 'tty'-handler special character # if it has its own internal definition for that character; # in particular, `tcsh' by default uses ^W for kill-region # (ather than werase), ^Y for yank (rather than dsusp), and # substitutes ^] for the default 'tty'-handler's dsusp function. # # Traditionalists may comment out the following `bindkey' lines # to leave everything more-or-less as Cornell envisioned things! # #Trad!# bindkey '^N' history-search-forward # [Use "down-" or "up-arrow" to #Trad!# bindkey '^P' history-search-backward # traverse the history stack] # # Note that 'history-search-forward' is exactly equivalent to # 'down-history' (and 'history-search-backward' to 'up-history') # whenever the command-typed-so-far has no characters (i.e., # whenever the cursor is at the beginning of the line). # # Note that `tcsh' requires that incremental-searches be bound # to single characters in order to be incrementally repeatable; # should one stay with tradition (mostly) or abandon tradition # and make the shell (and 'tty'-handler) more `emacs'-like? # # Traditionalists may also un-comment the next two `bindkey' # lines (and comment out those that follow) in order to use # ^N and ^P for `emacs'-like incremental-searches of history; # `emacs' afficionados should do the opposite (and should also # consider doing some `stty'-shenanigans in the .login file): # #Trad?# bindkey '^N' i-search-fwd # [Use "down-arrow" or "up-arrow" to #Trad?# bindkey '^P' i-search-back # traverse the history sequentially] # #Emacs# # Emacs afficionados may want to use (uncomment) the following: # bindkey '^G' keyboard-quit # [Don't save line in the cut buffer] # Also consider `stty kill "^G"' bindkey '^L' redisplay # Also consider `stty rprnt "^L"' bindkey '^Q' quoted-insert # Also consider `stty start "^-" lnext "^Q"' bindkey '^R' i-search-back # [Use "up-arrow" or "down-arrow" to bindkey '^S' i-search-fwd # traverse the history sequentially] # Also consider `stty stop "^-"' bindkey '^U' universal-argument # [Another choice -- like `emacs'!] # Note that ^G (defined above) and C-M-K (defined below) allow # one to respectively "discard" the entire line or "kill" it into # the cut buffer (independent of any above definition for ^U). bindkey '^V' down-history # [Use ^Q (above) to quote characters] bindkey '^[V' up-history if ($_bm) bindkey '\326' up-history bindkey '^[v' up-history if ($_bm) bindkey '\366' up-history #Def!# bindkey '^W' kill-region # [Save in cut buffer] #Def!# bindkey '^Y' yank # [Paste from cut buffer] # ## ### Graphic-characters ## # #Def!# ' ' through '/' self-insert-command bindkey ' ' magic-space # [A cute idea, but ... your call!] # If you use 'magic-space', you will probably want to # set autoexpand # as well. #Def!# '0' through '9' digit # [But also see M-0 through M-9 ...] #Def!# ':' through '~' self-insert-command # ## ### Delete (a.k.a. DEL, RUBOUT, or ^? -- i.e., ASCII code 127) ## # #Def!# bindkey '^?' backward-delete-char # ## ### ESC-characters (and any corresponding "meta"-characters) ## # # Note: An ESC-control character corresponds to a M-C-character, but # the latter is conventionally indicated as C-M-character instead. # # Note: ESC-thingie and M-thingie (8th bit set) are actually handled # separately -- both need definitions (but we only do the latter # if the "bind-meta" flag is set). Both upper- and lower-case # (graphic) characters need to be considered here ... # #Def!# bindkey '^[^@' undefined-key #Def!# if ($_bm) bindkey '\200' undefined-key # Arrgghhh! `tcsh' has problems dealing with a '^@' (=NUL) in # bindkey -s key 'keystroke(s)' # definitions (some sort of C-program? :-) -- hence this C-M-@ # binding (it's even somewhat `emacs'-appropriate)! You may # use '\200' instead of '^@' in `bindkey -s' definitions ... if ($_bm) bindkey '\200' set-mark-command # [8-bit mode only!] # ... but see '^[@' (or '\300') below for the recommended # alternative definition that will work even in 7-bit mode! # bindkey '^[^B' complete-word-back if ($_bm) bindkey '\202' complete-word-back # #Def!# bindkey '^[^D' list-choices # [Compare '^X-^D' list-choices-raw] #Def!# if ($_bm) bindkey '\204' list-choices #Raw?# bindkey '^[^D' list-choices-raw # [Same as '^X-^D'] #Raw?# if ($_bm) bindkey '\204' list-choices-raw # [Same as '^X-^D'] # bindkey '^[^F' complete-word-fwd if ($_bm) bindkey '\206' complete-word-fwd # #Def!# bindkey '^[^H' backward-delete-word # [Save in cut buffer] #Def!# if ($_bm) bindkey '\210' backward-delete-word bindkey '^[^H' run-help if ($_bm) bindkey '\210' run-help # #Def!# bindkey '^[^I' complete-word # [ESC-TAB => TAB (complete-word) #Def!# if ($_bm) bindkey '\211' complete-word # for those with `csh' habits] #Raw?# bindkey '^[^I' complete-word-raw # [Same as '^X-^I'] #Raw?# if ($_bm) bindkey '\211' complete-word-raw # [Same as '^X-^I'] # bindkey '^[^K' kill-whole-line # [Save in cut buffer] if ($_bm) bindkey '\213' kill-whole-line # [Note: C-M-K combines both C-K and M-K (see M-K below)] # #Def!# bindkey '^[^L' clear-screen # [ESC-FF => FF (clear-screen)] #Def!# if ($_bm) bindkey '\214' clear-screen # bindkey '^[^N' history-search-forward if ($_bm) bindkey '\216' history-search-forward # #Def!# bindkey '^[^O' undefined-key #Def!# if ($_bm) bindkey '\217' undefined-key if ($_8b) then #Don't# if ($_bm) bindkey '\217' xxx # [Needed for VT200 sequence-lead-in] else #OK# if ($_bm) bindkey '\217' whatever endif # bindkey '^[^P' history-search-backward if ($_bm) bindkey '\220' history-search-backward # bindkey '^[^Q' stuff-char if ($_bm) bindkey '\221' stuff-char ### This needs more "understanding" -- is `stuff-char' broke? # bindkey '^[^R' history-search-backward if ($_bm) bindkey '\222' history-search-backward # bindkey '^[^S' history-search-forward if ($_bm) bindkey '\223' history-search-forward # #Def!# bindkey '^[^T' undefined-key #Def!# if ($_bm) bindkey '\224' undefined-key if ($?Uptime) then bindkey -c '^[^T' $Uptime if ($_bm) bindkey -c '\224' $Uptime ### [bug fixed in tcsh-6.06.00] #Argh!# There's a bug in `tcsh' here! The above (with -c) is interpretted as #Argh!# bindkey -c '\\2\22\224' (or equivalently '\^B^R^T) -- gads!! else # [`tcsh's 'load-average' doesn't seem to work on SUNs] bindkey '^[^T' load-average if ($_bm) bindkey '\224' load-average endif # bindkey '^[^X' change-till-end-of-line # [... change-case till EOL] if ($_bm) bindkey '\230' change-till-end-of-line # #Def!# bindkey '^[^Z' run-fg-editor #Def!# if ($_bm) bindkey '\232' run-fg-editor # #Def!# bindkey '^[^[' complete-word # [ESC-ESC => TAB (complete-word) #Def!# if ($_bm) bindkey '\233' complete-word # for those with `csh' habits!] #Raw?# bindkey '^[^[' complete-word-raw # [Same as '^X-^I'] if ($_8b) then #Don't# if ($_bm) bindkey '\233' xxx # [Needed for VT200 sequence-lead-in] else #Raw?# if ($_bm) bindkey '\233' complete-word-raw # [Same as '^X-^I'] endif # #Def!# bindkey '^[^_' copy-prev-word # [Compare 'M-_' insert-last-word #Def!# if ($_bm) bindkey '\237' copy-prev-word # which inserts history `!$'] # ## M-special commands only need entries for a single-case. # #Def!# bindkey '^[ ' expand-history # [See also '^X- ' expand-line] #Def!# if ($_bm) bindkey '\240' expand-history # M-SPC expands history references in-line; # a cute idea is to also bind just a simple SPC to a function # that expands history references and then appends a space # (see ' ' magic-space function, above). # #Def!# bindkey '^[\!' expand-history # [See also '^X-!' expand-line] #Def!# if ($_bm) bindkey '\241' expand-history # Emacs binds M-! to a shell-command (i.e., to its associated # output); mimicing that behavior in `tcsh' is difficult (if # not impossible) -- just let M-! expand-history references ... # bindkey -s '^[\!' `$<` # (or something like that) # just does NOT work as one would hope that it might! # #Def!# bindkey '^[$' spell-line # [Compare with 'M-S' and '^X-S' below] #Def!# if ($_bm) bindkey '\244' spell-line bindkey '^[$' spell-word # [Emacs binds 'M-$' to spell-word ... if ($_bm) bindkey '\244' spell-word # ... we do likewise here] # bindkey '^[*' list-glob # List the glob (but don't expand it!) if ($_bm) bindkey '\252' list-glob # -- use '^X-*' to expand a glob. # bindkey '^[.' overwrite-mode # Toggle between overwrite if ($_bm) bindkey '\256' overwrite-mode # and insert modes. # #Def!# bindkey '^[/' dabbrev-expand # Expand current word to preceding word #Def!# if ($_bm) bindkey '\257' dabbrev-expand # for which this is a prefix. # #Def!# '^[0' through '^[9' digit-argument # [Starts a numeric argument] #Def!# if ($_bm) '\260' through '\271' digit-argument # bindkey '^[<' beginning-of-line if ($_bm) bindkey '\274' beginning-of-line # bindkey '^[=' which-command # [Compare '^X-=' normalize-command ... if ($_bm) bindkey '\275' which-command # ... but see comments below!] # bindkey '^[>' end-of-line if ($_bm) bindkey '\276' end-of-line # #Def!# bindkey '^[?' which-command # [Compare '^X-?' normalize-command ... #Def!# if ($_bm) bindkey '\277' which-command # ... but see comments below!] if ($_52) then #Don't# bindkey '^[?' xxx # [Needed for VT52 sequence-lead-in] #Don't# if ($_bm) bindkey '\277' xxx # [Needed for VT52 sequence-lead-in] else #OK# bindkey '^[?' whatever # [Probably OK, but DON'T redefine M-? #OK# if ($_bm) bindkey '\277' whatever # -- just use something else!] endif # ## M-letter commands need entries for both upper- and lower-case. # #Def!# bindkey '^[@' undefined-key #Def!# if ($_bm) bindkey '\300' undefined-key #Def!# bindkey '^[`' undefined-key #Def!# if ($_bm) bindkey '\340' undefined-key # Arrgghhh! `tcsh' has problems dealing with a '^@' (=NUL) in # bindkey -s key 'keystroke(s)' # definitions (some sort of C-program? :-) -- hence this M-@ # binding (it's even somewhat `emacs'-appropriate)! # Use '^[@' instead of '^@' in `bindkey -s' definitions ... bindkey '^[@' set-mark-command # [Works in 7-bit mode if ($_bm) bindkey '\300' set-mark-command # or 8-bit mode] # Even though '`' is the "official" lower-case version of '@', # let M-` be defined as needed -- just like `emacs' does! #OK# bindkey '^[`' whatever #OK# if ($_bm) bindkey '\340' whatever # #Def!# bindkey '^[A' undefined-key #Def!# if ($_bm) bindkey '\301' undefined-key #Def!# bindkey '^[a' undefined-key #Def!# if ($_bm) bindkey '\341' undefined-key if ($_52) then # VT52 needs special consideration for `M-A' #Don't# bindkey '^[A' xxx # [Needed for VT52 up-arrow] #Don't# if ($_bm) bindkey '\301' xxx # [Needed for VT52 up-arrow] else # Not a VT52 ... bindkey '^[A' beginning-of-line if ($_bm) bindkey '\301' beginning-of-line endif bindkey '^[a' beginning-of-line if ($_bm) bindkey '\341' beginning-of-line # #Def!# bindkey '^[B' backward-word #Def!# if ($_bm) bindkey '\302' backward-word #Def!# bindkey '^[b' backward-word #Def!# if ($_bm) bindkey '\342' backward-word if ($_52) then # VT52 needs special consideration for `M-B' #Don't# bindkey '^[B' xxx # [Needed for VT52 down-arrow] #Don't# if ($_bm) bindkey '\302' xxx # [Needed for VT52 down-arrow] else # Not a VT52 ... #OK# bindkey '^[B' whatever #OK# if ($_bm) bindkey '\302' whatever endif #OK# bindkey '^[b' whatever #OK# if ($_bm) bindkey '\342' whatever # #Def!# bindkey '^[C' capitalize-word #Def!# if ($_bm) bindkey '\303' capitalize-word #Def!# bindkey '^[c' capitalize-word #Def!# if ($_bm) bindkey '\343' capitalize-word if ($_52) then # VT52 needs special consideration for `M-C' #Don't# bindkey '^[C' xxx # [Needed for VT52 right-arrow] #Don't# if ($_bm) bindkey '\303' xxx # [Needed for VT52 right-arrow] else # Not a VT52 ... #OK# bindkey '^[C' whatever #OK# if ($_bm) bindkey '\303' whatever endif #OK# bindkey '^[c' whatever #OK# if ($_bm) bindkey '\343' whatever # #Def!# bindkey '^[D' delete-word # [Save in cut buffer] #Def!# if ($_bm) bindkey '\304' delete-word #Def!# bindkey '^[d' delete-word #Def!# if ($_bm) bindkey '\344' delete-word if ($_52) then # VT52 needs special consideration for `M-D' #Don't# bindkey '^[D' xxx # [Needed for VT52 left-arrow] #Don't# if ($_bm) bindkey '\304' xxx # [Needed for VT52 left-arrow] else # Not a VT52 ... #OK# bindkey '^[D' whatever #OK# if ($_bm) bindkey '\304' whatever endif #OK# bindkey '^[d' whatever #OK# if ($_bm) bindkey '\344' whatever # bindkey '^[E' end-of-line if ($_bm) bindkey '\305' end-of-line bindkey '^[e' end-of-line if ($_bm) bindkey '\345' end-of-line # #Def!# bindkey '^[F' forward-word #Def!# if ($_bm) bindkey '\306' forward-word #Def!# bindkey '^[f' forward-word #Def!# if ($_bm) bindkey '\346' forward-word # #Def!# bindkey '^[H' run-help #Def!# if ($_bm) bindkey '\310' run-help #Def!# bindkey '^[h' run-help #Def!# if ($_bm) bindkey '\350' run-help bindkey '^[H' backward-delete-word # [Save in cut buffer] if ($_bm) bindkey '\310' backward-delete-word bindkey '^[h' backward-delete-word # [Save in cut buffer] if ($_bm) bindkey '\350' backward-delete-word # bindkey '^[K' backward-kill-line # [Save in cut buffer] if ($_bm) bindkey '\313' backward-kill-line bindkey '^[k' backward-kill-line if ($_bm) bindkey '\353' backward-kill-line # [Note: `tcsh' doesn't handle M-0 like `emacs' does, i.e., # M-0 ^K doesn't backward-kill-line (hence this binding)] # #Def!# bindkey '^[L' downcase-word # [From point to end of current word] #Def!# if ($_bm) bindkey '\314' downcase-word #Def!# bindkey '^[l' downcase-word #Def!# if ($_bm) bindkey '\354' downcase-word # bindkey '^[M' beginning-of-line if ($_bm) bindkey '\315' beginning-of-line bindkey '^[m' beginning-of-line if ($_bm) bindkey '\355' beginning-of-line # #Def!# bindkey '^[N' history-search-forward # [Initial string only ...] #Def!# if ($_bm) bindkey '\316' history-search-forward #Def!# bindkey '^[n' history-search-forward #Def!# if ($_bm) bindkey '\356' history-search-forward # #Def!# bindkey '^[P' history-search-backward # [Initial string only ...] #Def!# if ($_bm) bindkey '\320' history-search-backward #Def!# bindkey '^[p' history-search-backward #Def!# if ($_bm) bindkey '\360' history-search-backward if ($_52) then # VT52 needs special consideration for `M-P' #Don't# bindkey '^[P' xxx # [Needed for VT52 PF1] #Don't# if ($_bm) bindkey '\320' xxx # [Needed for VT52 PF1] else # Not a VT52 ... #OK# bindkey '^[P' whatever #OK# if ($_bm) bindkey '\320' whatever endif #OK# bindkey '^[p' whatever #OK# if ($_bm) bindkey '\360' whatever # #Def!# bindkey '^[Q' undefined-key #Def!# if ($_bm) bindkey '\321' undefined-key #Def!# bindkey '^[q' undefined-key #Def!# if ($_bm) bindkey '\361' undefined-key if ($_52) then # VT52 needs special consideration for `M-Q' #Don't# bindkey '^[Q' xxx # [Needed for VT52 PF2] #Don't# if ($_bm) bindkey '\321' xxx # [Needed for VT52 PF2] else # Not a VT52 ... bindkey '^[Q' prefix-meta if ($_bm) bindkey '\321' prefix-meta endif bindkey '^[q' prefix-meta if ($_bm) bindkey '\361' prefix-meta # #Def!# bindkey '^[R' toggle-literal-history #Def!# if ($_bm) bindkey '\322' toggle-literal-history #Def!# bindkey '^[r' toggle-literal-history #Def!# if ($_bm) bindkey '\362' toggle-literal-history if ($_52) then # VT52 needs special consideration for `M-R' #Don't# bindkey '^[R' xxx # [Needed for VT52 PF3] #Don't# if ($_bm) bindkey '\322' xxx # [Needed for VT52 PF3] else # Not a VT52 ... #OK# bindkey '^[R' whatever #OK# if ($_bm) bindkey '\322' whatever endif #OK# bindkey '^[r' whatever #OK# if ($_bm) bindkey '\362' whatever # #Def!# bindkey '^[S' spell-word #Def!# if ($_bm) bindkey '\323' spell-word #Def!# bindkey '^[s' spell-word #Def!# if ($_bm) bindkey '\363' spell-word if ($_52) then # VT52 needs special consideration for `M-S' #Don't# bindkey '^[S' xxx # [Needed for VT52 PF4] #Don't# if ($_bm) bindkey '\323' xxx # [Needed for VT52 PF4] else # Not a VT52 ... #OK# bindkey '^[S' whatever #OK# if ($_bm) bindkey '\323' whatever endif #OK# bindkey '^[s' whatever #OK# if ($_bm) bindkey '\363' whatever # bindkey '^[T' transpose-gosling # [Switch chars before point] if ($_bm) bindkey '\324' transpose-gosling bindkey '^[t' transpose-gosling # [Switch chars before point] if ($_bm) bindkey '\364' transpose-gosling # #Def!# bindkey '^[U' upcase-word # [From point to end of current word] #Def!# if ($_bm) bindkey '\325' upcase-word #Def!# bindkey '^[u' upcase-word #Def!# if ($_bm) bindkey '\365' upcase-word # #Def?# bindkey '^[V' up-history # [See `emacs'-stuff above] #Def?# if ($_bm) bindkey '\326' up-history # [See `emacs'-stuff above] #Def?# bindkey '^[v' up-history # [See `emacs'-stuff above] #Def?# if ($_bm) bindkey '\366' up-history # [See `emacs'-stuff above] # #Def!# bindkey '^[W' copy-region-as-kill # [Save in cut buffer] #Def!# if ($_bm) bindkey '\327' copy-region-as-kill #Def!# bindkey '^[w' copy-region-as-kill # [Save in cut buffer] #Def!# if ($_bm) bindkey '\367' copy-region-as-kill # bindkey '^[X' change-case # [... and advance point] if ($_bm) bindkey '\330' change-case bindkey '^[x' change-case # [... and advance point] if ($_bm) bindkey '\370' change-case # # Some "letters" have no real upper/lower-case correspondence. # #Def!# if ($_bm) bindkey '\333' sequence-lead-in # [i.e., `M-[' in 8-bit mode] # [Is this really needed? or even used?] # #Def!# bindkey '^[_' insert-last-word # [Compare 'C-M-_' copy-prev-word; #Def!# if ($_bm) bindkey '\337' insert-last-word # inserts `!$' from history] # #Def!# bindkey '^[^?' backward-delete-word # [Save in cut buffer] #Def!# if ($_bm) bindkey '\377' backward-delete-word # ## ### ^X-sequences ## # # Note: The ^X prefix is completely under-(and mis-)utilized ... # # The following alias exists because there doesn't seem to be any # standard program that converts a relative pathname to an absolute one # (needed for dealing with history files, below). # The following is done with `perl' because it's just too damn hard to # do it with `sed' ... ### alias pathname "$Perl -e '"'require 5.0 ; $_=$ARGV[0] ; (-d) ? s%^((?:[^\\]|\\.|\\\n)*?)/*$%$1/$ARGV[1]% : s%^(/?(?:[^\\]|\\.|\\\n)*?)/*$%$1% ; $_="./$_" unless m%^(?:~|\.?/)% ; s%^\./%$ENV{'PWD'}/% ; print "$_\n"'"'" # Usage: pathname path [file [[.]ext] # Converts 'path' to an absolute pathname and prints it to STDOUT. # If 'path' is a directory, a trailing '/' is appended (if necessary) # followed by the optional (default) 'file' (if present); # if 'path' is not a directory, any trailing '/' is removed and the # optional 'file' and 'ext' arguments are ignored. # Bugs: No syntax checking is done on the optional 'file' or 'ext' arguments # (e.g., leading '/' or '~' removal, etc.). # No internal resolution of any '../' path components is performed. # ### Resume editing (for ^X-chars) here! [See similar ###comment### above] ### #Def!# bindkey '^X^@' undefined-key #Def!# bindkey '^X^D' list-choices-raw # [Compare 'C-M-D' list-choices] #Def!# bindkey '^X^I' complete-word-raw # Ignore "programmable" completions bindkey -c '^X^S' 'history -h >\! "$histfile" && echo "Wrote $histfile"' # Note: `history -S' NEVER indicates failure (bug or feature?)! ### bindkey -c '^X^V' 'echo -n "Find alternate history file: " ; set histfile=`echo "$<" | '"$Sed -e 's/^\.\//$cwd\//' -e 's/\/"'$'"//'"'` ; history -L' bindkey -c '^X^V' 'echo -n "Find alternate history file: " ; set histfile="$<" ; history -L' # Note: NEITHER `history -L' NOR `source -h' indicates failure! ### bindkey -c '^X^W' 'echo -n "Write history file: " ; history -S "$<"' ### bindkey -c '^X^W' 'echo -n "Write history file: " ; history -h >\! "$<"' bindkey -c '^X^W' 'echo -n "Write history file: " ; set histfile="$<" ; history -h >\! "$histfile" && echo "Wrote $histfile"' # Most `emacs'-like ... # Note: `history -S' NEVER indicates failure (bug or feature?)! #Def!# bindkey '^X^X' exchange-point-and-mark # [Just like `emacs' does!] bindkey -c '^X^Z' 'suspend' # [Make `tcsh' suspend like `emacs'] bindkey -c '^XI' 'echo -n "Merge history file: " ; history -M "$<" && echo "Merged into history"' bindkey -c '^Xi' 'echo -n "Append history file: " ; history -L "$<" && echo "Appended to history"' # ## Use ^X commands to eXpand various things ... # bindkey '^X ' expand-line # Expand ALL history references in the line # [See also ' ' magic-space] bindkey '^X\!' expand-history # Expand current history reference #Def!# bindkey '^X$' expand-variables # Expand current variable reference #Def!# bindkey '^X*' expand-glob # Expand current current glob #Def?# bindkey '^X.' normalize-path # Expand current file name bindkey '^X/' normalize-path # Expand current file name bindkey '^X=' normalize-command # Expand current command (from PATH) # [Compare 'M-=' which-command] #Def!# bindkey '^X?' normalize-command # Expand current command (from PATH) #Def!# # [Compare 'M-?' which-command] #Def!# bindkey '^XG' list-glob #Def!# bindkey '^Xg' list-glob #Def?# bindkey -r '^XG' # [Retain '^X-G' as list-glob? Your call!] #Def?# bindkey -r '^Xg' # [Retain '^X-g' as list-glob? Your call!] #Def!# bindkey '^XN' normalize-path #Def!# bindkey '^Xn' normalize-path #Def?# bindkey -r '^XN' # [Retain '^X-N' as normalize-path? Your call!] #Def?# bindkey -r '^Xn' # [Retain '^X-n' as normalize-path? Your call!] # Note that ^X- must suffice in some cases where `emacs' # would use M-X function for the equivalent command ... bindkey '^XS' spell-line # [Like `emacs's M-X spell-buffer] bindkey '^Xs' spell-line # [Compare M-s spell-word] # else if ($_vopt || $_Vopt) then # bindkey -v # [Better get used to `vi' if no `emacs'!] # endif # endif # $?tcsh # Any `source'ing from `csh' will be conveniently ignored! # unset _52 _7b _8b _bm _[dDeEvV]opt _stty _term # Clean up the variable space. ### Local Variables: ### ### mode:fundamental ### ### sh-shell:tcsh ### ### sh-shell-file:/bin/tcsh ### ### End: ###