tcsh OS/Dependent Options
tcsh [ -F ] [ -Dname[=value] ]
1) Command line editing using Emacs-style commands. 2) Visual step up/down through the history list. 3) Terminal mode sanity checking and resetting. 4) Interactive command, file name and user name completion. 5) File/directory/user list in the middle of a typed command. 6) Spelling correction of command, file, and user names. 7) Lookup of command documentation in the middle of a typed command. 8) Enhanced history mechanism. 9) Automatic locking/logout after long periods of idle time. 10) Automatic execution of a single command prior to printing each prompt. 11) Automatic periodic command execution. 12) A new syntax for the prompt, and the ability to set the prompt for "while" and "for" loops. 13) Time stamps in the history list. 14) An addition to the syntax of filenames to access entries in the directory stack, and the ability treat symbolic links in a sane way when changing directories. 15) The ability to watch for logins and logouts by user or terminal on the machine. 16) A scheduled event list, which specifies commands which are to be executed at given times. 17) A new builtin that does a subset of ls(1). 18) An addition to the file expression syntax for a character not in a set of characters and the ability to negate a globbing pattern. 19) New automatically initialized environment variables HOST and HOSTTYPE. 20) Commands for debugging terminal capabilities. 21) Searching for the visual history mechanism. 22) New builtins for the which(1) and where commands. 23) Restarting a stopped editor with two keystrokes. 24) Status line support 25) Automatic execution of a command when the current working directory is changed. 26) Native Language System support. 27) Automatic process time reporting. 28) OS Dependent Builtin Support 29) Automatic window size adjustment 30) Input files 31) Additional/Undocumented Options 32) Enhanced history/variable modifier expansion 33) Programmable completion. 34) Enhanced file inquiry operator.For a description of standard C-shell features, see the csh manual page.
There is a new shell command, bindkey, that allows the user to redefine what any key does, or find out what any or all of the keys do.
Syntax: bindkey [ -a ] [ -c ] [ -s ] [ -v ] [ -e ] [ -d ] [ -k ] [ -l ] [ -r ] [ -- ] [ [ in-string | key-name ] [ out-string | command ]]
If no values are given all bindings are listed. If only in-string is given, bindings for the in-string is listed.
Otherwise it binds the in-string to the given out-string or command. If out-string, this is treated as input to tcsh when in-string is typed. This may be used recursively to currently a level of 10 deep.
There are two basic key maps: the normal and alternative one. The alternative is used by VI command mode. For multi-character input the basic key maps contains a sequence-lead-in for the first character in the input.
Options: -a bind in-string in alternative key map
-s bind an out-string instead of a command
-c bind a unix command instead of a command
-v bind for default VI-mode
-e bind for default emacs-mode
-k interpret in-string as a symbolic arrow key name
-d bind to compiled in default
-l list functions available with short description
-r remove the binding of in-string
In strings control characters may be written as caret-<letter> and backslash ("\") is used to escape a character as follows:
In all other cases \ escapes the following character. Needed for escaping the special meaning of \ and ^. Delete is written as "^?" (caret-question mark).
- \a
- bell character
- \n
- line feed (new line)
- \b
- back space
- \t
- horizontal tab
- \v
- vertical tab
- \f
- form feed
- \r
- carriage return
- \e
- escape
- \nnn
- character code in octal
Tcsh always binds the arrow keys as defined by the termcap entry to:
except where these bindings would alter other single character bindings. If this is not desired one can avoid the automatic arrow key binding using settc to change the arrow key escape sequences to the empty string. The ansi/vt100 sequences for arrow keys are always bound.up arrow up-history down arrow down-history right arrow forward-char left arrow backward-char
The following is a list of the default emacs and vi bindings. Characters with the 8th bit set are written as M-<character>. Note however, that unlike with the old bind command (see below), the syntax M-<character> has no special meaning to the bindkey command, and the bindings for the sequence escape+<character> and M-<character> as given below are handled separately (although the the default bindings are the same). The printable ascii characters not mentioned in the list are bound to the self-insert-command function, which just inserts the given character literally into the input line. The remaining characters are bound to the undefined-key function, which only causes a beep (unless nobeep is set, of course).
EMACS bindings "^@" -> set-mark-command "^A" -> beginning-of-line "^B" -> backward-char "^C" -> tty-sigintr "^D" -> delete-char-or-list "^E" -> end-of-line "^F" -> forward-char "^G" -> is undefined "^H" -> backward-delete-char "^I" -> complete-word "^J" -> newline "^K" -> kill-line "^L" -> clear-screen "^M" -> newline "^N" -> down-history "^O" -> tty-flush-output "^P" -> up-history "^Q" -> tty-start-output "^R" -> redisplay "^S" -> tty-stop-output "^T" -> transpose-chars "^U" -> kill-whole-line "^V" -> quoted-insert "^W" -> kill-region "^X" -> sequence-lead-in "^Y" -> yank "^Z" -> tty-sigtsusp "^[" -> sequence-lead-in "^\" -> tty-sigquit "^]" -> tty-dsusp " " to "/" -> self-insert-command "0" to "9" -> digit ":" to "~" -> self-insert-command "^?" -> backward-delete-charEMACS Multi-character and 8 bit bindings "^[^D" or "M-^D" -> list-choices "^[^H" or "M-^H" -> backward-delete-word "^[^I" or "M-^I" -> complete-word "^[^L" or "M-^L" -> clear-screen "^[^Z" or "M-^Z" -> run-fg-editor "^[^[" or "M-^[" -> complete-word "^[^_" or "M-^_" -> copy-prev-word "^[ " or "M- " -> expand-history "^[!" or "M-!" -> expand-history "^[$" or "M-$" -> spell-line "^[0" or "M-0" -> digit-argument "^[1" or "M-1" -> digit-argument "^[2" or "M-2" -> digit-argument "^[3" or "M-3" -> digit-argument "^[4" or "M-4" -> digit-argument "^[5" or "M-5" -> digit-argument "^[6" or "M-6" -> digit-argument "^[7" or "M-7" -> digit-argument "^[8" or "M-8" -> digit-argument "^[9" or "M-9" -> digit-argument "^[?" or "M-?" -> which-command "^[B" or "M-B" -> backward-word "^[C" or "M-C" -> capitalize-word "^[D" or "M-D" -> delete-word "^[F" or "M-F" -> forward-word "^[H" or "M-H" -> run-help "^[L" or "M-L" -> downcase-word "^[N" or "M-N" -> history-search-forward "^[P" or "M-P" -> history-search-backward "^[R" or "M-R" -> toggle-literal-history "^[S" or "M-S" -> spell-word "^[U" or "M-U" -> upcase-word "^[W" or "M-W" -> copy-region-as-kill "^[_" or "M-_" -> insert-last-word "^[b" or "M-b" -> backward-word "^[c" or "M-c" -> capitalize-word "^[d" or "M-d" -> delete-word "^[f" or "M-f" -> forward-word "^[h" or "M-h" -> run-help "^[l" or "M-l" -> downcase-word "^[n" or "M-n" -> history-search-forward "^[p" or "M-p" -> history-search-backward "^[r" or "M-r" -> toggle-literal-history "^[s" or "M-s" -> spell-word "^[u" or "M-u" -> upcase-word "^[w" or "M-w" -> copy-region-as-kill "^[^?" or "M-^?" -> backward-delete-word "^X^X" -> exchange-point-and-mark "^X*" -> expand-glob "^X$" -> expand-variables "^XG" -> list-glob "^Xg" -> list-glob "^Xn -> normalize-path "^XN -> normalize-path
VI Insert Mode functions "^@" -> is undefined "^A" -> beginning-of-line "^B" -> backward-char "^C" -> tty-sigintr "^D" -> list-or-eof "^E" -> end-of-line "^F" -> forward-char "^G" -> list-glob "^H" -> backward-delete-char "^I" -> complete-word "^J" -> newline "^K" -> kill-line "^L" -> clear-screen "^M" -> newline "^N" -> down-history "^O" -> tty-flush-output "^P" -> up-history "^Q" -> tty-start-output "^R" -> redisplay "^S" -> tty-stop-output "^T" -> transpose-chars "^U" -> backward-kill-line "^V" -> quoted-insert "^W" -> backward-delete-word "^X" -> expand-line "^Y" -> tty-dsusp "^Z" -> tty-sigtsusp "^[" -> vi-cmd-mode "^\" -> tty-sigquit " " to "~" -> self-insert-command "^?" -> backward-delete-char
VI Command Mode functions "^@" -> is undefined "^A" -> beginning-of-line "^B" -> is undefined "^C" -> tty-sigintr "^D" -> list-choices "^E" -> end-of-line "^F" -> is undefined "^G" -> list-glob "^H" -> backward-char "^I" -> vi-cmd-mode-complete "^J" -> newline "^K" -> kill-line "^L" -> clear-screen "^M" -> newline "^N" -> down-history "^O" -> tty-flush-output "^P" -> up-history "^Q" -> tty-start-output "^R" -> redisplay "^S" -> tty-stop-output "^T" -> is undefined "^U" -> backward-kill-line "^V" -> is undefined "^W" -> backward-delete-word "^X" -> expand-line "^[" -> sequence-lead-in "^\" -> tty-sigquit " " -> forward-char "!" -> expand-history "$" -> end-of-line "*" -> expand-glob "+" -> down-history ";" -> vi-repeat-char-fwd "," -> vi-repeat-char-back "-" -> up-history "." -> is undefined "/" -> vi-search-back "0" -> vi-zero "1" to "9" -> digit-argument "?" -> vi-search-fwd "@" -> is undefined "A" -> vi-add-at-eol "B" -> vi-word-back "C" -> change-till-end-of-line "D" -> kill-line "E" -> vi-endword "F" -> vi-char-back "I" -> vi-insert-at-bol "J" -> history-search-forward "K" -> history-search-backward "N" -> vi-search-back "O" -> sequence-lead-in "R" -> vi-replace-mode "S" -> vi-substitute-line "T" -> vi-charto-back "U" -> is undefined "V" -> expand-variables "W" -> vi-word-fwd "X" -> backward-delete-char "[" -> sequence-lead-in "\^" -> beginning-of-line "a" -> vi-add "b" -> backward-word "c" -> is undefined "d" -> vi-delmeta "e" -> vi-eword "f" -> vi-char-fwd "h" -> backward-char "i" -> vi-insert "j" -> down-history "k" -> up-history "l" -> forward-char "m" -> is undefined "n" -> vi-search-fwd "r" -> vi-replace-char "s" -> vi-substitute-char "t" -> vi-charto-fwd "u" -> vi-undo "v" -> expand-variables "w" -> vi-beginning-of-next-word "x" -> delete-char "~" -> change-case "^?" -> backward-delete-char "M-?" -> run-help "M-[" -> sequence-lead-in "M-O" -> sequence-lead-in
VI Multi-character bindings "^[?" -> run-help
In tcsh there are two input modes: insert and overwrite. All characters that are bound to the self-insert-command either get inserted or overwrite what was under the cursor depending on the input mode. In emacs one can toggle between modes using the overwrite-mode function, and in VI one can use any of the replace mode commands. By default the mode is preserved between input lines. To specify a default mode that can be enforced at the beginning of each command line, the variable inputmode can be set to either insert or overwrite.
There is also an older version of bindkey called bind, that allows the user to redefine what any key does, or find out what any or all of the keys do. This is retained for compatibility reasons.
If given two arguments bind binds the function (first argument) to the given key (second argument). The key may be: the direct character or a caret-<letter> combination, which is converted to control-<letter>; M-<letter> for an escaped character; or F-<string> for a function key. For the last of these, the function key prefix must be bound to the function "sequence-lead-in" and the string specified to the bind command must not include this prefix.
If given one argument bind takes the argument as the name for a key and tells what that key does. As a special case, the user can say
bind emacsor
bind vito bind all the keys for Emacs or vi mode respectively.
If given no arguments bind tells what all of the keys do. If you give bind the single argument of 'defaults', it resets each key to its default value (see the above list).
then enters ^P, the shell will place "echo mumble" into the editing buffer, and will put the cursor at the end of the line. If another ^P is entered, then the editing line will change to "ls". More ^Ps will make the bell ring, since there are no more lines in the history. ^N works the same way, except it steps down (forward in time).> ls foo bar > echo mumble mumble >
An easy way to re-do a command is to type ^P followed by Return. Also, pieces of previous commands can be assembled to make a new command. The commands that work on regions are especially useful for this.
^P and ^N actually only copy commands from out of the history into the edit buffer; thus the user may step back into the history and then edit things, but those changes do not affect what is actually in tcsh history.
Another way to recall (parts of) history commands is via the 'expand-history' function. A variation of the 'expand-history' function is called 'magic-space'. This function expands csh history, and always appends a space. Magic-space thus can be bound to <space>, to automatically expand csh history. Expand-history is normally bound to M-<space> and magic-space is not bound.
The list of the tty modes that are always set or cleared by tcsh can be examined and modified using the setty builtin. The setty display is similar to stty(1), and varies depending on the system's tty driver. Modes that tcsh will always try to set are shown as +mode". Modes that tcsh will always try to clear are shown as -mode and modes that tcsh will track and allow to be modified are not shown by default, or if the -a flag is given, are shown without a leading sign. For tty characters, -char disables the tty character, while +char protects the tty character from being changed.
Setty can be used to control the three different modes tcsh uses for the tty. The default mode displayed is the "execute" mode which is used when tcsh executes commands. The two other modes are the "edit" mode and the "quote" mode. The "edit" mode is used for command line editing, and the "quote" mode is used when entering literal characters. The "execute" mode can be specified with -x", the "edit" mode with -d", and the "quote" mode with -q For example if one wants to set the echok flag and let the echoe pass unchanged:
> setty iflag:-inlcr -igncr +icrnl oflag:+opost +onlcr -onlret cflag: lflag:+isig +icanon +echo +echoe -echok -echonl -noflsh +echoctl -flusho +iexten chars: > setty +echok echoe > setty iflag:-inlcr -igncr +icrnl oflag:+opost +onlcr -onlret cflag: lflag:+isig +icanon +echo +echok -echonl -noflsh +echoctl -flusho +iexten chars:
Example
Assume the current directory contained the files:
The command:DSC.TXT bin cmd lib memos DSC.NEW chaos cmtest mail netnews bench class dev mbox new
> gnumacs ch[TAB]would cause tcsh to complete the command with the file name chaos. If instead, the user had typed:
> gnumacs D[TAB]tcsh would have extended the name to DSC and rung the terminal bell, indicating partial completion. However, if fignore had previously been set to a list containing .NEW as one element, e.g. ( .o .NEW ), tcsh would have completed the `D' to DSC.TXT.
File name completion works equally well when other directories are addressed. Additionally, tcsh understands the C shell tilde (~) convention for home directories. In addition it caches tilde name references for fast access. This cache can be flushed by using the builtin rehash. Thus,
> cd ~speech/data/fr[TAB]does what one might expect. This may also be used to expand login names only. Thus,
> cd ~sy[TAB]expands to
> cd ~synthesis
Command names may also be completed, for example,
> gnum[TAB]will expand to "gnumacs" (assuming that there are no other commands that begin with "gnum"). Shell and environment variables are recognized also and in addition they can be expanded:
> set local=/usr/localwill expand to "$local/". Note that a slash is appended because the expanded variable points to a directory. Also:> echo $lo[TAB]
> set local=/usr/localwill correctly list the contents of /usr/local. Shell and environment variables can also be expanded via the expand-variables function:> echo $local/[^D]
bin/ etc/ lib/ man/ src/
> echo $local/[^X$]> echo /usr/local/
Completion also works when the cursor is in the middle of the line, rather than just the end. All of the text after the cursor will be saved, the completion will work (possibly adding to the current name), and then the saved text will be restored in place, after the cursor.
The behavior of the completion can be changed by the setting of several shell variables:
Setting the recexact variable makes an exact command be expanded rather than just ringing the bell. For example, assume the current directory has two sub-directories called foo and food, then with recexact set the following could be done:
> cd fo[TAB]
to ...
> cd foo[TAB]
to ...
> cd foo/rather than beeping on the second TAB.
If the autolist variable is set, invoking completion when several choices are possible will automatically list the choices, effectively merging the functionality described in the next section into the completion mechanism. If autolist is set to "ambiguous", then tcsh will only list the choices if there were no new characters added in the completion operation.
The "noise level" can be controlled by the value that matchbeep is set to: With matchbeep=nomatch, completion will only beep if there are no matching names; with matchbeep=ambiguous, completion will also beep if there are many possible matches; with matchbeep=notunique, completion will also beep when there is an exact match but there are other, longer, matches (see recexact). With matchbeep=never or set to any other value completion will never beep. If matchbeep is not set it defaults to ambiguous.
If the autoexpand variable is set, the expand-history function will be invoked automatically before the completion attempt, expanding normal csh history substitutions.
For covert operation, the variable nobeep can be set; it will prevent the completion mechanism, as well as tcsh in general, from actually beeping. Finally, if the autocorrect variable is set, the spelling correction is attempted for any path components up to the completion point.
> cd ~speech/data/fritz/you may wish to know what files or sub-directories exist (in ~speech/data/fritz), without, of course, aborting the command you are typing. Typing the character Control-D (^D), will list the names (files, in this case) available. The files are listed in multicolumn format, sorted column-wise. Directories are indicated with a trailing `/', executable files with a `*', symbolic links with a '@', sockets with a '=', FIFOs (named pipes) with a '|', character devices with a '%', and block devices with a '#'. Once printed, the command is re-echoed for you to complete.
Additionally, one may want to know which files match a prefix. If the user had typed:
> cd ~speech/data/fr[^D]all files and sub-directories whose prefix was ``fr'' would be printed. Notice that the example before was simply a degenerate case of this with a null trailing file name. (The null string is a prefix of all strings.) Notice also, that a trailing slash is required to pass to a new directory for both file name completion and listing.
The degenerate
> ~[^D]will print a full list of login names on the current system. Note, however, that the degenerate
> <Spaces>[^D]does not list all of the commands, but only the files in the current working directory.
Listing/expanding of words that match a name containing wildcard characters can be done via the list-glob/expand-glob function:
> ls foo.c bar.c a.out > vi *.c[^Xg] foo.c bar.c > vi *.c[^X*] > vi foo.c bar.c
> newa[TAB]might expand to
> newaliasesAlso,
> new[^D]would list all commands (along PATH) that begin with "new".
Note that Control-D has three different effects on tcsh. On an empty line (one that contains nothing, not even spaces), ^D sends an EOF to tcsh just as it does for normal programs. When the cursor is in the middle of a line of text, ^D deletes the character that the cursor is under. Finally, a ^D at the end of a line of text lists the available names at that point. To get a list of available names when the cursor is in the middle of a line (or on an empty line), a Meta-Control-D should be typed (Escape followed by Control-D).
The spell-word function, normally bound to M-s (and M-S), will attempt to correct the word immediately before the cursor. For example, suppose that the user has typed:
> cd /uxr/spol/news[ESC s]Tcsh will check the path for spelling, correct the mistakes, and redraw the line as
> cd /usr/spool/newsleaving the cursor at the end of the line.
Spelling correction of the entire command line (independent of where the cursor is) can be done with the spell-line function, normally bound to M-$ (Escape Dollar-sign). It will check each word independently, but in order to avoid e.g. command options, no correction is attempted on words whose first character is found in the string "!.\^-*%".
Finally, automatic spelling correction will be done each time the Return key is hit, if the correct variable is set to an appropriate value: correct=cmd will cause the spelling of the command name only to be checked, while correct=all causes checking of all words on the line, like the spell-line function. If any part of the command line is corrected, the user will be given a special prompt as defined by the prompt3 variable, followed by the corrected line, e.g.
Answering 'y' or <space> at the prompt will cause the corrected line to be executed, 'e' will leave the uncorrected command in the input buffer and anything else will execute the original line unchanged.> lz /usr/bin CORRECT>ls /usr/bin (y|n|e)?
Automatic correction is not guaranteed to work the way the user intended. Command line parsing is done in a rudimentary fashion. It is mostly provided as an experimental feature. Suggestions and improvements are welcome.
> set history=25 savehist=20tells tcsh to save the last 25 commands on the history list, and to save the last 20 of them between logins. The "savehist" variable may be set up to the size of history, although it is an error to have savehist larger than history. In addition to the above tcsh, keeps unparsed (literal) versions of the history if the variable histlit is set. Also the toggle-history function toggles between the parsed and literal version of the recalled history in the editor buffer. For example:
Tcsh also supports the history escape !#. This undocumented csh escape holds the words of the current line. This is useful in renaming commands:> set histlit > echo !:s/foo/bar; ls Modifier failed. > ^P > echo !:s/foo/bar; ls > unset histlit > echo !:s/foo/bar; ls Modifier failed. > ^P > echo unset histlit[M-r] > echo !:s/foo/bar; ls
Care should be taken when using this history expansion in csh since there is no check for recursion. In tcsh up to 10 levels of recursion are allowed.> mv foo bar!#:1 mv foo barfoo
Another difference between tcsh and csh history expansion, is the treatment of history arguments. In csh !3d expands to event 3 with the letter "d" appended to it. There is no way to repeat a command that begins with a number using the name of the command in the history escape. In tcsh only numeric arguments are treated as event numbers; therefore !3d is interpreted as: repeat the last command that started with the string "3d". To mimic the csh behavior !3\d can be used.
The value of the optional second word indicates the number of minutes of inactivity after which the user will be prompted for his login password to continue working. Failure to enter the correct password 5 times, results in auto-logout.
> alias precmd datethen the program date will be run just before the shell prompts for each command. There are no limitations on what precmd can be set to do, although discretion should be used.
This will cause the checknews(1) program to be run every 30 minutes. Having the alias periodic set but with an unset tperiod (or a value of 0 for tperiod) will cause periodic to degenerate to another form of precmd.> set tperiod = 30 > alias periodic checknews
On %C, %c and %., if the optional digit is 0, then then next digit is interpreted as the number of directory components to be skipped, and the number of components skipped are reported as: /<num-skipped>path/path. The sequences for standout are often used to indicate that this is an enabled (running as root) shell. An example:%/ Current working directory. %~ cwd. If it starts with $HOME, that part is replaced by a ~. In addition if a directory name prefix matches a user's home directory, that part of the directory will be substituted with ~user. NOTE: The ~user substitution will only happen if the shell has performed a ~ expansion for that user name in this session. %c or %. Trailing component of cwd, may be followed by by a digit to get more than one component, if it starts with $HOME, that part is replaced with a ~. %C Trailing component of cwd, may be followed by a digit to get more than one component, no ~ substitution. %h, %!, ! Current history event number. %M The full machine hostname. %m The hostname up to the first ".". %S (%s) Start (stop) standout mode. %B (%b) Start (stop) boldfacing mode. (Only if tcsh was compiled to be eight bit clean.) %U (%u) Start (stop) underline mode. (Only if tcsh was compiled to be eight bit clean.) %t or %@ Current time of day, in 12-hour, am/pm format. %T Current time of day, in 24-hour format. (But see the ampm shell variable below.) \c `c' is parsed the same way as in bindkey. ^c `c' is parsed the same way as in bindkey. %% A single %. %n The user name, contents of $user. %d The weekday in <Day> format. %D The day in dd format. %w The month in <Mon> format. %W The month in mm format. %y The year in yy format. %Y The year in yyyy format. %l The line (tty) the user is logged on. %L clear from prompt to end of display or end of line. %# A `#' if tcsh is run as a root shell, a `>' if not. %{..%} Include string as a literal escape sequence. Note that the enclosed escape sequence, should only be used to change terminal attributes and should not move the cursor location. Also, this cannot be the last character in the prompt string. (Available only if tcsh was compiled to be eight bit clean.) %? return code of the last command executed just before the prompt. %R In prompt3 this is the corrected string; in prompt2 it is the status of the parser.
In addition, there is a new variable, prompt2, which is used to prompt for the body of while and for loops (wherever normal csh prompts with a question mark). The default for prompt2 is "%R? ": the status of the parser followed by a question mark. This alternate prompt is also used when the parser is waiting for more input; i.e. when the previous line ended in a \. The prompt3 variable is used when displaying the corrected command line when automatic spelling correction is in effect; it defaults to "CORRECT>%R (y|n|e)? ".> set prompt="%m [%h] %B[%@]%b [%/] you rang? " tut [37] [2:54pm] [/usr/accts/sys] you rang? _ .\} > set prompt="%m [%h] %U[%@]%u [%/] you rang? " tut [37] [2:54pm] [/usr/accts/sys] you rang? _ .\}
history
history The 'S' flag saves the current history, the 'L' flags loads the history, and the 'c' flag clears the history. If a filename is not specified, then $HOME/.history is used.
Tcsh always saves the last directory visited. Changing to the previous directory can be done by using 'cd or 'pushd
Tcsh will now allow the user to access all elements in the directory stack directly. The syntax "=<digit>" is recognized by tcsh as indicating a particular directory in the stack. (This works for the file/command name recognition as well.) This syntax is analogous to the ~ syntax for access to users' home directories. The stack is viewed as zero-based, i.e., =0 is the same as $cwd, which is the same as ".". As a special case, the string "=-" is recognized as indicating the last directory in the stack. Thus,
Tcsh will complain if you ask for a directory stack item which does not exist.> dirs -v 0 /usr/net/bin 1 /usr/spool/uucp 2 /usr/accts/sys > echo =2 /usr/accts/sys > ls -l =1/LOGFILE -rw-r--r-- 1 uucp 2594 Jan 19 09:09 /usr/spool/uucp/LOGFILE > echo =-/.cs* /usr/accts/sys/.cshrc > echo =4 Not that many dir stack entries. >
In the normal csh, saying "pushd +2" would rotate the entire stack around through 2 stack elements, placing the entry found there at the top of the stack. If, however, the new shell variable dextract is set, then issuing "pushd +n" will cause the nth directory stack element to be extracted from its current position, which will then be pushed onto the top of the stack. Example:
> dirs ~ /usr/spool/uucp /usr/net/bin /sys/src > set dextract > pushd +2 /usr/net/bin ~ /usr/spool/uucp /sys/src > unset dextract > pushd +2 /usr/spool/uucp /sys/src /usr/net/bin ~
Tcsh provides a way to save, restore and clear the directory stack in a file. dirs
dirs
dirs The 'S' flag saves the current directory stack, the 'L' flags loads the directory stack, and the 'c' flag clears the directory stack. If a filename is not specified, then $HOME/.cshdirs is used.
In addition, if the shell variable dunique is set, only directories that are not already in the directory stack will be added when push is invoked.
The way symbolic links that point to directories are crossed is determined by the symlinks variable. By default, it is not set to anything and symbolic links are not treated specially. However, it can be set to either: chase, ignore, or expand. If symlinks is set to chase, then every time the directory changes, $cwd reflects the real directory name, and not the name through the link. A notable exception is the user's home directory, but that should be fixed. If symlinks is set to either ignore or expand, then tcsh tries to determine the current directory name relative to the name of the current directory before the link was crossed. In simple terms, if you chdir through a symbolic link and then cd .., you will end .. relatively to where you were before you crossed the link and not .. relatively to where the symbolic link points. While ignore affects only builtin commands and completion, expand affects command execution too, by `fixing' arguments that it considers to be path names. Unfortunately this does not work in every case, specially when file arguments are embedded in command line options. Expand also allows to specify the `real' (as opposed to the one determined relatively to $cwd),
For example:
While the expand setting is the most convenient, and makes symbolic links invisible, it can sometimes be misleading and confusing in cases where it fails to recognize arguments. A compromise is to use the ignore setting and use the editor functions "normalize-path", bound by default to ^Xn.> cd /tmp > mkdir from from/src to > ln -s ../from/src to/dst > unset symlinks > cd /tmp/to/dst; echo $cwd /tmp/to/dst > cd ..; echo $cwd /tmp/from > set symlinks=chase > cd /tmp/to/dst; echo $cwd /tmp/from/src > cd ..; echo $cwd /tmp/from > set symlinks=ignore > cd /tmp/to/dst; echo $cwd /tmp/to/dst > cd ..; echo $cwd /tmp/to > set symlinks=expand > cd /tmp/to/dst; echo $cwd /tmp/to/dst > cd ..; echo $cwd # builtin /tmp/to > cd /tmp/to/dst; echo $cwd /tmp/to/dst > cd ".."; echo $cwd # quoted /tmp/from > /bin/echo .. # rewrites non builtin commands. /tmp/to > /bin/echo ".." ..
This setting will allow the user to check on when the user "sys" logs in on /dev/ttyjd. Similarly, it will inform the user of root's activity on the console. In order to be more general, the word "any" may be substituted for either a user's or a terminal's name, thus allowing> set watch=(sys ttyjd root console)
which will check for users that match the pattern 'b*' logging in or out of the system on any terminal, as well as anyone logging in to /dev/ttyh0. Naturally, the completely general case> set watch=('b*' any any ttyh0)
allows the user to check on any and all login/logout activity in the the system.> set watch=(any any)
By default, the interval between checks of users on the system is 10 minutes; this can be changed by making the first element of watch a number of minutes which should be used instead, as in
which will check for any users logging in or out every 40 minutes.> set watch=(40 any any)
There is also a new command, log, which is used to cause tcsh to inform the user of all users/terminals affected by watch whether they have been announced before or not. This is useful if a user has been on for some time and cannot remember if a particular person/terminal is online right now or not. Log will reset all indication of previous announcement and give the user the login list all over again, as well as printing the current value of watch.
The first time that watch is set at tcsh startup, all affected users and terminals will be printed as though those users/terminals had just logged on. This may appear to be a bug, but is generally considered a feature, since it allows the user to see who is on when he first logs in.
The format of the printouts can be tailored via setting of the variable who. In addition to the standard prompt % escapes, the following sequences are available for the format specification:
The %M and %m sequences are only available on systems that store the remote hostname in /etc/utmp. If who is not set, the format defaults to "%n has %a %l from %m.", or "%n has %a %l." on systems that don't store the hostname.%n The name of the user that logged in/out. %a The observed action, i.e. "logged on", "logged off", or "replaced <olduser> on". %l The line (tty) the user is logged on. %M The full hostname of the remote host ("local" if non-remote). %m The hostname up to the first ".". If only the ip address is available or the utmp field contains the name of an x-windows display, the whole name is printed.
as in> sched [+]hh:mm <command>
This will make an entry in the list at 11am for the echo command to be run with the given arguments. The time may be specified in either absolute or relative time, and absolute times may have a morning/afternoon specification as well, using "am" or "pm." For example,> sched 11:00 echo It\'s eleven o\'clock.
Note that tcsh will complain if you try to make faulty time specifications.> sched +2:15 /usr/lib/uucp/uucico -r1 -sother > sched 5pm set prompt='[%h] It\'s after 5; go home: >' > sched +3am echo This syntax doesn\'t work. Relative time inconsistent with am/pm. >
Printing the current time-event list is accomplished by giving the sched command with no arguments:
There is also a mechanism by which the user can remove an item from the list:> sched 1 Wed Apr 4 15:42 /usr/lib/uucp/uucico -r1 -sother 2 Wed Apr 4 17:00 set prompt=[%h] It's after 5; go home: > >
All commands specified on the scheduled-event list will be executed just prior to printing the first prompt immediately following the time when the command is to be run. Hence, it is possible to miss the exact time when the command is to be run, but tcsh will definitely get around to all commands which are overdue at its next prompt. Scheduled-event list items which come due while tcsh is waiting for user input will be executed immediately. In no case, however, will normal operation of already-running commands be interrupted so that a scheduled-event list element may be run.> sched --3 Usage for delete: sched -<item#>. > sched -3 Not that many scheduled events. > sched -2 > sched 1 Wed Apr 4 15:42 /usr/lib/uucp/uucico -r1 -sother >
This mechanism is similar to, but not the same as, the at(1) command on some Unix systems. Its major disadvantage is that it does not necessarily run a command at exactly the specified time (but only if another command is already being run). Its major advantage is that commands which run directly from tcsh, as sched commands are, have access to shell variables and other structures. This provides a mechanism for changing one's working environment based on the time of day.
On systems that support symbolic links the variable listlinks controls the way symbolic links are identified. If listlinks is not set then the character '@' is appended to the file. If listlinks is set then the following characters are appended to the filename depending on the type of file the symbolic links points to:= File is an AF_UNIX domain socket. [if system supports sockets] | File is a named pipe (fifo) [if system supports named pipes] % File is a character device # File is a block device / File is a directory * File is executable + File is a hidden directory [aix] or context dependent [hpux] : File is network special [hpux]
While setting listlinks can be helpful while navigating around the file system, it slows down ls-F and it causes mounting of file systems if the symbolic links point to an NFS auto-mounted partition.@ File is a symbolic link pointing to a non-directory > File is a symbolic link pointing to a directory & File is a symbolic link pointing to nowhere
Note that the second form includes .Xdefaults and .Xinit because 'X' (and all the lower case letters) are outside of the range of a single '.'.> cd ~ > echo .[a-z]* .cshrc .emacs .login .logout .menuwmrc > echo .[^.]* .Xdefaults .Xinit .cshrc .emacs .login .logout .menuwmrc >
Also the ability to negate a globbing pattern has been added:
Note that this does not work correctly if the expression does not have any wildcard characters (?*[]) or if the expression has braces {}.> echo * foo foobar bar barfoo > echo ^foo* bar barfoo
Tcsh also initializes the environment variable HOSTTYPE to a symbolic name for the type of computer that it is running on. This is useful when sharing a single physical directory between several types of machines (running NFS, for instance). For example, if the following is in .login:
set path = (~/bin.$HOSTTYPE /usr/ucb /bin /usr/bin /usr/games .)and the user has directories named "bin.machine" (where machine is a name from the list below), then the user can have the same programs compiled for different machines in the appropriate "bin.machine" directories and tcsh will run the binary for the correct machine. The current possible values are:
386BSD an Intel 386, running 386BSD aix370 an IBM 370, running aix aixESA an IBM ESA, running aix alliant an Alliant FX series alliant-fx80 an Alliant FX80 (mc68000 based) alliant-fx2800 an Alliant FX2800 (i860 based) alpha an DEC Alpha running OSF/1 amdahl an Amdahl running uts 2.1 amiga an amiga running amix 2.02 apollo an Apollo running DomainOS att3b15 an AT&T 3b15 att3b2 an AT&T 3b2 att3b20 an AT&T 3b20 att3b5 an AT&T 3b5 balance a Sequent Balance (32000 based) bsd386 an Intel 386, running BSDI's bsd386 butterfly a BBN Computer Butterfly 1000 coh386 a 386 running Coherent 4.0 coherent an unknown machine running Coherent convex a Convex cray a Cray running Unicos decstation a DecStation XXXX eta10 an ETA 10 running SVR3 gould-np1 a Gould NP1 hk68 a Heurikon HK68 running Uniplus+ 5.0 hp300 an HP 9000, series 300, running mtXinu hp800 an HP 9000, series 800, running mtXinu hp9000s300 an HP 9000, series 300, running hpux hp9000s500 an HP 9000, series 500, running hpux hp9000s700 an HP 9000, series 700, running hpux hp9000s800 an HP 9000, series 800, running hpux hp an HP, running hpux i386 an Intel 386, generic i386-mach an Intel 386, running mach i386-linux an Intel 386, running Linux i386-emx an Intel 386, running emx [unix emulation under OS/2] intel386 an Intel 386, running INTEL's SVR3 iris3d a Silicon Graphics Iris 3000 iris4d a Silicon Graphics Iris 4D isc386 an Intel 386, running ISC m88k an mc88000 CPU machine mac2 an Apple Computer Macintosh II, running AUX masscomp a Concurrent (Masscomp), running RTU minix386 an i386 running minix minix a mac or an amiga running minix mips another mips CPU multimax an Encore Computer Corp. Multimax (32000 based) news a Sony NEWS 800 or 1700 workstation news_mips a NeWS machine with mips CPU nd500 a Norsk Data ND 500/5000 running Ndix ns32000 an NS32000 CPU machine next a NeXT computer pfa50 a PFU/Fujitsu A-xx computer ps2 an IBM PS/2, running aix ptx a Sequent Symmetry running DYNIX/ptx (386/486 based) pyramid a Pyramid Technology computer (of any flavor) rs6000 an IBM RS6000, running aix rt an IBM PC/RT, running BSD (AOS 4.3) or mach rtpc an IBM PC/RT, running aix sco386 an Intel 386, running SCO stellar a stellar running stellix sun a Sun workstation of none of the above types sun2 a Sun Microsystems series 2 workstation (68010 based) sun3 a Sun Microsystems series 3 workstation (68020 based) sun386i a Sun Microsystems 386i workstation (386 based) sun4 a Sun Microsystems series 4 workstation (SPARC based) symmetry a Sequent Symmetry running DYNIX 3 (386/486 based) sysV88 a Motorola MPC running System V/88 R32V2 (SVR3/88100 based) tahoe a tahoe running 4BSD tek4300 a Tektronix 4300 running UTek (BSD 4.2 / 68020 based) tekXD88 a Tektronix XD88/10 running UTekV 3.2e (SVR3/88100 based) titan an Stardent Titan unixpc an UNIX/PC running SVR1 att7300 aka att3b1 vax a Digital Equipment Corp. Vax (of any flavor) vistra800 a Stardent Vistra 800 running SVR4 VMS-POSIX a vax? running VMS/POSIX(The names of the machines are usually trade marks of the corresponding companies.)
Tcsh also initializes the shell variables uid and gid to the value of the current real user ID/GID. This is useful for telling what user/group the shell is running as. Under Domain/OS tcsh will also set oid indicating the current real organization id.
telltc tells you, politely, what tcsh thinks of your terminal, and settc `cap' `value' tells tcsh to believe that the termcap capability `cap' ( as defined in termcap(5) ) has the value `value'. No checking for sanity is performed, so beware of improper use.
Note that Concept terminal users may have to "settc xn no" to get proper wrapping at the rightmost column.
History-search-backward (history-search-forward) searches backward (forward) through the history list for previous (next) occurrence of the beginning of the input buffer as a command. That is, if the user types:
and then types "echo<ESC>p", the shell will place "echo bar" in the editing buffer. If another M-p was entered, the editing buffer would change to "echo foo". This capability is compatible with the plain visual history; if the user were to then enter ^P the editing buffer would be changed to "ls". The pattern used to search through the history is defined by the characters from the beginning of the line up to the current cursor position and may contain a shell globbing pattern. Successive history searches use the same pattern.> echo foo foo > ls filea fileb > echo bar bar >
When the incremental search functions are used, a prompt - "bck:" or "fwd:", depending on the chosen direction - appears, and characters typed are appended to the search pattern. The matching command line is placed in the editing buffer, with the cursor positioned at the point where the pattern was found (the incremental search will also do searching within a command line). If the search fails, the terminal bell is rung, and the ':' in the prompt is changed to '?'.
If these functions are bound to single characters, and one of those is typed again during the incremental search, the search continues in the corresponding direction, with the pattern unchanged; if the previous search failed, this will also cause it to "wrap around" the history list. Finally, the following characters also have a special meaning during the search:
Any other character, that isn't bound to self-insert-command, terminates the search, leaving the current command line in the editing buffer, after which tcsh interprets the character as if it was normal input - notably Return will cause the current command line to be executed.Delete (or any character bound to backward-delete-char) Undo the effect of the last character typed, deleting a character from the pattern if appropriate. ^G Abort the search, back to the last successful one if previous search failed, otherwise entire search. ^W Append the rest of the current word to the pattern. ESC Terminate the search, leaving current line in buffer.
In vi mode "vi-search-fwd" (bound to '/') and "vi-search-back" (bound to '?') can be used to search the visual history. In command mode '/' or '?' followed by a shell pattern, searches the visual history for the pattern. The pattern can be terminated either with a Return, in which case the matched history event is placed in the command buffer or an Escape, in which case the matched history event is executed. If no history event matches the shell pattern then the bell is rung.
Similarly where will report all known instances of the command: aliases, builtins, as well as all references in the path.
> echotc homePlaces the cursor at the home position and
> echotc cm 3 10places the cursor at column 3 row 10. This command replaces the el and sl variables that used contain the escape sequences to begin and end status line changes. The command:
> echo $sl this is a test $elis replaced by:
> echotc ts 0; echo "this is a test"; echotc fsIn addition echotc understands the arguments baud, lines, cols, meta, and tabs And prints the baud rate, the number of lines and columns, and "yes" or "no" depending if the terminal has tabs or a meta key. This can be useful in determining how terse the output of commands will be depending on the baud rate, or setting limits to commands like history to the highest number so that the terminal does not scroll:
> set history=`echotc lines`
> @ history--Note: Termcap strings may contain wildcard characters, and echoing them will not work correctly. The suggested method of setting shell variables to terminal capability strings is using double quotes, as in the following example that places the date in the status line:
> set tosl="`echotc ts 0`"
> set frsl="`echotc fs`"
> echo -n "$tosl";date; echo -n "$frsl"Echotc accepts two flags. The flag -v enables verbose messages and the flag -s ignores any errors and returns the empty string if the capability is not found.
> alias cwdcmd 'echo -n "^[]2;${HOST}:$cwd ^G"'then the shell will change the title of the running xterm(1) to be the name of the host, a colon, and the full current working directory. A more fancy way to do that is:
> alias cwdcmd 'echo -n "^[]2;${HOST}:$cwd^G^[]1;${HOST}^G"'This will put the hostname and working directory on the title bar but only the hostname in the icon manager menu. Note that if a user defines cwdcmd to contain a cd, pushd, or popd, command, an infinite loop may result. In this case, it is the author's opinion that said user will get what he deserves.
When using the system's NLS, the setlocale C library function will be called to determine appropriate character classification and sorting - this function will typically examine the LANG and LC_CTYPE variables for this purpose (refer to the system documentation for further details). Otherwise, NLS will be simulated, by assuming that the ISO 8859-1 character set is used whenever either of the LANG and LC_CTYPE variables are set, regardless of their values. Sorting is not affected for the simulated NLS.
In addition, with both real and simulated NLS, all printable characters in the range \200-\377, i.e. those that have M-<char> bindings, are automatically rebound to self-insert-command (the corresponding binding for the escape+<char> sequence, if any, is left alone). This automatic rebinding is inhibited if the NOREBIND environment variable is set - this may be useful for the simulated NLS, or a primitive real NLS which assumes full ISO 8859-1 (otherwise all M-<char> bindings in the range \240-\377 will effectively be undone in these cases). Explicitly rebinding the relevant keys, using bindkey, is of course still possible.
Unknown characters (i.e. those that are neither printable nor control characters) will be printed using the \nnn format. If the tty is not in 8 bit mode, other 8 bit characters will be printed by converting them to ascii and using standout mode. Tcsh will never change the 7/8 bit mode of the tty, and will track user-initiated settings for this - i.e. it may be necessary for NLS users (or, for that matter, those that want to use a Meta key) to explicitly set the tty in 8 bit mode through the appropriate stty(1) command in e.g. the .login file.
The following sequences are supported only in systems that have the BSD resource limit functions.%U The time the process spent in user mode in cpu seconds. %S The time the process spent in kernel mode in cpu seconds. %E The elapsed time in seconds. %P The CPU percentage computed as (%U + %S) / %E.
The default time format is "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww" for systems that support resource usage reporting and "%Uu %Ss %E %P" for systems that do not.%W Number of times the process was swapped. %X The average amount in (shared) text space used in Kbytes. %D The average amount in (unshared) data/stack space used in Kbytes. %K The total space used (%X + %D) in Kbytes. %M The maximum memory the process had in use at any time in Kbytes. %F The number of major page faults (page needed to be brought from disk). %R The number of minor page faults. %I The number of input operations. %O The number of output operations. %r The number of socket messages received. %s The number of socket messages sent. %k The number of signals received. %w Number of voluntary context switches (waits). %c Number of involuntary context switches.
For Sequent's DYNIX/ptx %X, %D, %K, %r and %s are not supported. However, the following additional sequences are available.
The default time format for Sequent's DYNIX/ptx is "%Uu %Ss $E %P %I+%Oio %Fpf+%Ww". Also note that the CPU percentage can be higher than 100% on multi-processors.%Y The number of system calls performed. %Z The number of pages which are zero-filled on demand. %i The number of times a process' resident set size was increased by the kernel. %d The number of times a process' resident set size was decreased by the kernel. %l The number of read system calls performed. %m The number of write system calls performed. %p the number of reads from raw disk devices. %q the number of writes to raw disk devices.
TRANSPARENT COMPUTING FACILITY
On systems that support TCF (aix-ibm370, aix-ps2) the following builtins have been added:
Domain/OS Support
Mach
Masscomp/RTU
Convex/OS
but in tcsh:% set a=/usr/local/foo.bar.baz % echo $a:t:r:e foo.bar.baz:r:e
This bug fix changes slightly the input syntax of csh, causing expressions of the form to have invalid syntax:> set a=/usr/local/foo.bar.baz > echo $a:t:r:e bar
Which is the correct behavior, since after the second colon a variable modifier is expected and `$' is found. Expressions like this should be re-written as:> set a=/usr/local/foo.bar.baz > echo $a:t:$cwd Unknown variable modifier.
Tcsh can also use the l and u modifiers to change the case of a word. Also tcsh has an additional : character a which applies the current modifier multiple times in the same word, in the same way g applies the modifier once in each word:> echo ${a:t}:$cwd
The csh expert will notice in the above example another tcsh enhancement. In csh the s modifier does not work for variables. The a character works correctly with other modifiers, for example:> set foo=(a:b:c d:e:f) > echo $foo:s/:/ / a b:c d:e:f > echo $foo:gs/:/ / a b:c d e:f > echo $foo:as/:/ / a b c d:e:f > echo $foo:ags/:/ / a b c d e f
Note: The a character causes a modifier to be applied to a word repeatedly until the modifier fails. This can lead to an infinite loop in the current implementation when used with the s modifier. For example :as/f/ff/ will never terminate. This behavior might change in the future.> echo $host tesla.ee.cornell.edu > echo $host:r tesla.ee.cornell > echo $host:ar tesla
> complete cd 'n/*/d/'The above command tells tcsh to complete any following word with a directory.
The syntax for the complete and uncomplete builtins is: complete
uncomplete
Completion arguments are matched in turn from left to right and the first successful match is returned. There are three different completion arguments, modeled after the sed(1) substitute command and they are of the form: <command>/<match-pattern>/<complete-action>/[<suffix>|/] The five commands available are:
> complete cd 'p/1/d/'completes only the first argument of 'cd' with a directory. A special useful case of position-dependent completion can be used to disambiguate command completion:
> set autolist > co[TAB] complete compress > complete -co* 'p/0/(complete)/' > co[TAB] > complete _The above command tells the completion mechanism to match any word on position 0, that matches the pattern co*". If a match is found, the word is replaced with the literal pattern "complete". The leading '-' in the pattern signifies that this completion is to be used only with ambiguous commands.
> complete find 'n/-user/u/'Here the argument of the find command which follows the -user argument is completed from the list of users.
> complete cc 'c/-I/d/'completes the the word containing -I from the list of directories. While `c' discards the matched prefix, `C' keeps it and applies the completion using it.
All the above completion actions, except x, $var, (...), and `...` can have an additional shell pattern which must match the files to be completed, separated from the action with a ':'. The 'x' completion action instead expects the explanation string specified this way. For example, in the C compiler, it makes sense to complete only files that the compiler understands:C Complete completions S Complete signals a Complete aliases b Complete binding c Complete command d Complete directory e Complete environment variable f Complete file or path component j Complete jobs l Complete limits n Complete nothing p Complete files using the supplied pathname prefix s Complete shell variable t Complete non directory `text' filename v Complete any variable u Complete username x Explain what argument when listing is requested. $var Complete using words from variable (...) Complete using words from list `...` Complete evaluating word list from the output of command.
> complete cc 'n/*/f:*.[cao]/'
It is also useful to exclude files from the completion list. Normally tcsh will expand the following command:
> set fignore=(.o) > ls foo.c foo.o > vi f[TAB] > vi foo.c > rm f[TAB] > rm foo.cA better way to do this is to use the complete builtin to protect precious files:
> complete rm 'n/*/f:^*.{c,h,cc,C,tex,1,man,l,y}/' > ls foo.c foo.o > vi f[TAB] > vi foo.c > rm f[TAB] > rm foo.oNote that fignore is not used when a shell pattern is specified in a completion action.
Other commands don't expect files as arguments, so the completion builtin can be used to change the list of items to be completed:
Note that in the dbx example, the positional completion is specified before the next word completion. Since completions are evaluated from left to right, if the next word completion was specified first it would always match and the positional completion would never be executed. This is a common mistake when defining a completion.> complete man 'n/*/c/' # complete commands > complete which 'n/*/c/' > complete dbx 'p/2/(core)/' 'n/*/c/' > complete alias 'p/1/a/' # complete aliases > complete set 'p/1/s/' # complete variables > complete finger 'p/1/u/' # complete user-names
In some cases the list needs to be customized or dynamically generated.
> set hostnames=(prep.ai.mit.edu tesla.ee.cornell.edu) > complete rlogin 'p/1/$hostnames/'Consider a complex example using matching patterns to direct argument dependent completions:
> complete find 'n/-fstype/(nfs 4.2)/' 'n/-name/f/' \ 'n/-type/(c b d f p l s)/' 'n/-user/u/' 'n/-exec/c/' \ 'n/-ok/c/' 'n/-cpio/f/' 'n/-ncpio/f/' 'n/-newer/f/' \ 'c/-/(fstype name perm prune type user nouser \ group nogroup size inum atime mtime ctime exec \ ok print ls cpio ncpio newer xdev depth)/' \ 'n/*/d/'The words following the -fstype and -type arguments is to be completed from the lists specified. The word following the -name, -cpio, -ncpio, and -newer arguments are to be completed using files or directory components. The word following the -user argument will be completed from the list of user names of the system, and the word following the -exec and -ok arguments will be completed from the list of commands. The fourth line specifies how the current word will be completed if it starts with a -. Note that the pattern of this completion argument refers to the current word and not to the previous word, like before. Finally the last line in the find completion matches all the remaining cases and requires a directory component.
> cd /usr > set autolist > find [TAB] bin/ include/ lib/ local/ man/ src/ > find -[TAB] atime depth group mtime newer ok prune user cpio exec inum name nogroup perm size xdev ctime fstype ls ncpio nouser print type > find -u[TAB] > find -user [TAB] christos root > find -user c[TAB] > find -user christos
Another useful feature is to override the default suffix rules. For example:
> complete rcp 'c/*:/f/' 'p/1/$hosts/:' > complete finger 'c/*@/$hosts/' 'p/1/u/@'completes from $hosts appending a `:' and then begins expanding files, where finger expands user-names appending an `@' and then begins expanding hosts.
Another exotic example that makes use of dynamic command execution is:
> complete talk p/1/'`users | tr " " "\012" | uniq`'/ \ n/\*/\`who\ \|\ grep\ \$:1\ \|\ awk\ \'\{\ print\ \$2\ \}\'\`/Here we want to get a list of the active users, as an argument to talk, then we want to pick the user, and find his tty... Note that there is no quoting performed inside the completion patterns. If the character '/' is used in the matched pattern, then another punctuation character can be used as a separator. The only pattern recognized is $:<number> which is substituted by the n'th word of the current line.
Notes:
This shell will restore your tty to a sane mode if it appears to return from some command in raw, CBREAK, or noecho mode. This behavior can be changed using setty.
r read access w write access x execute access e existence o ownership z zero size f plain file d directory l symbolic link *
Tcsh defines also the following:
c character special file b block special file p named pipe (fifo) * u set-user-ID bit is set g set-group-ID bit is set k sticky bit is set s socket special file * t open file descriptor for terminal device [a number] X executable in the path or shell builtin
Notes: On systems without the file types indicated by * the file inquiry operands return false. In the version of csh appearing on the Silicon Graphics IRIX, -s is true when the file is not zero size. Tcsh is *not* compatible with that.
LANG -- used to give preferred character environment (see NLS)
LC_CTYPE -- used to change only ctype character handling (see NLS)
NOREBIND -- inhibits rebinding of printable characters to self-insert-command
PATH -- path to look for command execution
SHLVL -- current shell level nesting
TERM -- used to tell how to handle the terminal
LINES -- Number of lines in terminal (see WINDOW SIZE)
COLUMNS -- Number of columns in terminal (see WINDOW SIZE)
TERMCAP -- Terminal capability string (see WINDOW SIZE)
SYSTYPE -- The current system type (Domain OS only)
8b 7b If tcsh was compiled to be eight bit clean or not. The default is 8b. nls Set if tcsh uses the system's NLS, should be the default for systems that have NLS. lf Set if tcsh should execute .login before .cshrc on login shells. Default is not set. dl Set if tcsh should put . last on the path for security. Default is set. vi Set if tcsh's default editor is vi. Default is unset (emacs) dtr Set if tcsh should drop dtr on login shells when exiting. Default is unset. bye Set if tcsh should accept bye in addition to logout, and rename log to watchlog. Default is unset. al Set if tcsh should determine if autologout should be enabled. The default is set. kan Set if tcsh is compiled for Kanji. (ignore the iso character set.) Default is unset. sm Set if tcsh was compiled to use the system's malloc. hb Set if tcsh is emulating #!<program> <args> in shell script execution
Wrote the command completion. Mike Ellis, Fairchild, 1983
Added command name recognition/completion. Paul Placeway, Ohio State CIS dept., 1983
Added the command line editor. Rayan Zachariassen, University of Toronto, 1984
Added the builtin which feature to the editor, and the code for ls-F". Also numerous bug fixes, modifications, and performance enhancements. Chris Kingsley, Caltech
Wrote the fast storage allocator routines (nmalloc.c). Karl Kleinpaste, CCI 1983-4
Added special aliases, directory stack extraction stuff, login/logout watch, and scheduled events. Also came up with the idea of the new prompt format. Paul Placeway, Ohio State CIS dept., 1987
Re-wrote the editor, cleaned up other code, and added the prompt routines, added to the syntax for file name expressions, and sped up the shell some. Chris Grevstad, TRW, 1987
Ported the 4.3 csh sources to tcsh. Christos S. Zoulas, Cornell U. EE dept., 1987-92
ported tcsh to HPUX, and System V rel. 2 and 3 and wrote a SysV version of getwd.c. Added SHORT_STRINGS support. New version of sh.glob.c. James J Dempsey, BBN, 1988, and Paul Placeway, OSU, 1988
Re-ported tcsh to A/UX.
Coherent port Andy Phillips, Mullard Space Science Lab U.K., 1992
VMS-POSIX port. Beto Appleton, IBM Corp., 1992
Walking process group fixes, lots of misc csh bug fixes, POSIX file tests, POSIX SIGHUP. Scott Bolte, Cray Computer Corp., 1992
CSOS port. Kaveh R. Ghazi, Rutgers University, 1992
Fixes and Ports for Tek, m88k, Titan, Masscomp. Mark Linderman, Cornell University, 1992
OS/2 Port Mika Liljeberg, liljeber@kruuna.Helsinki.FI, 1992
Linux port. Scott Krotz, Motorola, 1991
Minix port. David Dawes, Sydney U. Australia, Physics dept., 1991
SVR4 job control fixes. (reverse pipeline startup code, and signal fixes). Jose Sousa, Interactive Systems Corp., 1991
Extended vi fixes. Added delete command in vi. Marc Horowitz, MIT, 1991
Ansification fixes, new exec hashing code, imake fixes, where builtin. Eric Schnoebelen, Convex, 1990
Convex support, lots of csh bug fixes, save and restore of directory stack. Jaap Vermeulen, Sequent, 1990-91
Vi mode fixes, expand-line, window change fixes, ported to symmetry machines. Ron Flax, Apple, 1990
Ported again to A/UX 2.0 Dan Oscarsson, LTH Sweden, 1990
NLS support and simulated for non NLS sites. Correction of file names also handles the case when the / is replaced by another character. The editor does not switch into cbreak mode unless needed. The shell will not use character attributes when output is not to a tty. Johan Widen, SICS Sweden, 1990
Shell level variable, mach support, correct-line, 8-bit printing. Matt Day, Sanyo Icon, 1990
Added POSIX termio support; Fixed limit stuff for SysV. Hans J. Albertsson (Sun Sweden)
Added the ampm variable handling, DING!, and the settc and telltc builtins. Michael Bloom
Fixed some of the interrupt handling. Michael Fine, Digital Equipment Corp
added the extended key support. Daniel Long, NNSC, 1988
Added the wordchars variable. George Hartzell, MCD Biology, University of Colorado-Boulder, 1988
Fixed the always resetting to DEL bug. Patrick Wolfe, Kuck and Associates, Inc., 1988
Cleaned up VI mode and wrote the new editor description (in section 1). Jak Kirman, 1988
Fixed the SunOS 4 giant stack allocation bug. Bruce Robertson, Tektronix, 1989
Fixed setting erase and kill (again). David C Lawrence, Rensselaer Polytechnic Institute, 1989
Added "autolist" variable and code to list possibilities on ambiguous completion. Martin Boyer, Institut de recherche d'Hydro-Quebec, 1991.
Modified "autolist" variable and code to give options on beeping behavior. Modified the history search to search for the whole string from the beginning of the line to the cursor. Alec Wolman, DEC, 1989
Added code to allow newlines in the prompt. Matt Landau, BBN, 1989
Fixed YP bugs on Suns, added .tcshrc stuff. Ray Moody, Purdue Physics, 1989
Added the code to do magic spacebar history expansion. Mordechai ????, Intel, 1989
Re-arranged the printprompt() routine to use a switch(*cp) (rather than a bunch of ifs), and added a few things to it. Josh Siegel, dspo.gov, 1989
Fixed "fg-editor" and added the status line shell variables "sl" and "el". Karl Berry, UMB, 1989
Fixed a bug involving environ (in sh.func.c) on NeXT computers. Michael Greim, Universitaet des Saarlandes, Saarbruecken, W-Germany,
Fixed the nested backquote bug (yes, you can do it; think about aliases) in 4.2 csh. This fix was posted to comp.bugs.4bsd. Kazuhiro Honda, Department of Computer Science, Keio University, 1989
Added the code for automatic spelling correction, the prompt3 stuff (the autocorrect prompt), and HOSTTYPE symbols for the Sony NEWS. Paul Placeway, BBN, 1990
Fixed character redrawing code insert bugs, and made redrawing code handle multiple character movement, insert, and delete (if it exists). Fixed setting of SHELL. Per Hedeland, Ellemtel, Sweden, 1990
Various bugfixes and improvements, e.g. in history expansion, autolist, added autoexpand, updated the manual.