2.11BSD/man/cat1/tcsh.0
TCSH(1) UNIX Programmer's Manual TCSH(1)
NAME
tcsh - C shell with file name completion and command line
editing
SYNOPSIS
tcsh [ -bcdefilmnqstvVxX ] [ _a_r_g_u_m_e_n_t ... ]
DESCRIPTION
_T_c_s_h is an enhanced version of the Berkeley UNIX C shell
_c_s_h(1). It behaves exactly like the C shell, except for the
added utilities of:
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 comple-
tion.
5) File/directory/user list in the middle of a typed com-
mand.
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 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 direc-
tories.
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
Printed 11/24/99 27 November 1996 1
TCSH(1) UNIX Programmer's Manual TCSH(1)
are to be executed at given times.
17) A new builtin that does a subset of _l_s(1).
18) An addition to the file expression syntax for a char-
acter not in a set of characters and the ability to
negate a regular expression.
19) New automatically initialized environment variables
_H_O_S_T and _H_O_S_T_T_Y_P_E.
20) Commands for debugging terminal capabilities.
21) Searching for the visual history mechanism.
22) A new builtin for the _w_h_i_c_h(1) command.
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
For a description of standard C-shell features, see the _c_s_h
manual page.
1. COMMAND LINE EDITING
Commands that the user types in may be edited using the same
control characters that Gnu Emacs or vi uses. Arrow and
function key sequences are also allowed. _T_c_s_h allows this
by setting the terminal to `CBREAK' mode and reading the
input one character at a time.
There is a new shell command, _b_i_n_d_k_e_y, that allows the user
to redefine what any key does, or find out what any or all
of the keys do.
Syntax: bindkey [ -a ] [ -s ] [ -v ] [ -e ] [ -d ] [ -l ] [
-r ] [ -- ] [ in-string [ out-string | command ]]
Printed 11/24/99 27 November 1996 2
TCSH(1) UNIX Programmer's Manual TCSH(1)
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 _t_c_s_h
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
-v bind for default VI-mode
-e bind for default emacs-mode
-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:
\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
In all other cases \ escapes the following character. Needed
for escaping the special meaning of \ and ^. Delete is
written as "^?" (caret-question mark).
_T_c_s_h always binds the arrow keys as defined by the termcap
entry to:
up arrow up-history
down arrow down-history
right arrow forward-char
left arrow backward-char
Also the vt100 sequences for arrow keys are always bound.
The following is a list of the default emacs and vi bind-
ings. Characters with the 8th bit set are written as M-
<character>. Note however, that unlike with the old _b_i_n_d
command (see below), the syntax M-<character> has no special
Printed 11/24/99 27 November 1996 3
TCSH(1) UNIX Programmer's Manual TCSH(1)
meaning to the _b_i_n_d_k_e_y 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 _s_e_l_f-_i_n_s_e_r_t-_c_o_m_m_a_n_d function,
which just inserts the given character literally into the
input line. The remaining characters are bound to the
_u_n_d_e_f_i_n_e_d-_k_e_y function, which only causes a beep (unless
_n_o_b_e_e_p 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-char
EMACS 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
Printed 11/24/99 27 November 1996 4
TCSH(1) UNIX Programmer's Manual TCSH(1)
"^[^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
Printed 11/24/99 27 November 1996 5
TCSH(1) UNIX Programmer's Manual TCSH(1)
VI Insert Mode functions
"^C" -> tty-sigintr
"^D" -> list-or-eof
"^H" -> backward-delete-char
"^I" -> complete-word
"^J" -> newline
"^K" -> kill-line
"^L" -> clear-screen
"^M" -> newline
"^N" -> is undefined
"^O" -> tty-flush-output
"^P" -> is undefined
"^Q" -> tty-start-output
"^R" -> redisplay
"^S" -> tty-stop-output
"^T" -> is undefined
"^U" -> backward-kill-line
"^V" -> quoted-insert
"^W" -> backward-delete-word
"^X" -> is undefined
"^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-delete-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
Printed 11/24/99 27 November 1996 6
TCSH(1) UNIX Programmer's Manual TCSH(1)
"^V" -> is undefined
"^W" -> backward-delete-word
"^X" -> expand-line
"^[" -> sequence-lead-in
"^\" -> tty-sigquit
" " -> forward-char
"!" -> expand-history
"$" -> end-of-line
"*" -> expand-glob
"0" -> vi-zero
"1" to "9" -> digit-argument
"?" -> which-command
"@" -> is undefined
"A" -> vi-add-at-eol
"B" -> backward-word
"C" -> vi-chg-to-eol
"D" -> kill-line
"I" -> vi-insert-at-bol
"J" -> history-search-forward
"K" -> history-search-backward
"O" -> sequence-lead-in
"R" -> vi-replace-mode
"S" -> vi-substitute-line
"T" -> toggle-literal-history
"V" -> expand-variables
"W" -> forward-word
"X" -> backward-delete-char
"[" -> sequence-lead-in
"\^" -> beginning-of-line
"a" -> vi-add
"b" -> backward-word
"c" -> is undefined
"d" -> delete-word
"h" -> backward-char
"i" -> vi-insert
"j" -> down-history
"k" -> up-history
"l" -> forward-char
"r" -> vi-replace-char
"s" -> vi-substitute-char
"t" -> toggle-literal-history
"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
Printed 11/24/99 27 November 1996 7
TCSH(1) UNIX Programmer's Manual TCSH(1)
"^[?" -> run-help
There is also an older version of bindkey called _b_i_n_d, 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 compa-
tibility reasons.
If given two arguments _b_i_n_d binds the function (first argu-
ment) 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 func-
tion "sequence-lead-in" and the string specified to the _b_i_n_d
command must not include this prefix.
If given one argument _b_i_n_d takes the argument as the name
for a key and tells what that key does. As a special case,
the user can say
bind emacs
or
bind vi
to bind all the keys for Emacs or vi mode respectively.
If given no arguments _b_i_n_d 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).
2. VISUAL HISTORY
The keys ^P and ^N are used to step up and down the history
list. If the user has typed in the following:
> ls
foo bar
> echo mumble
mumble
>
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).
An easy way to re-do a command is to type ^_P followed by
_R_e_t_u_r_n. Also, pieces of previous commands can be assembled
to make a new command. The commands that work on regions
are especially useful for this.
Printed 11/24/99 27 November 1996 8
TCSH(1) UNIX Programmer's Manual TCSH(1)
^_P and ^_N actually only copy commands from out of the his-
tory 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 _t_c_s_h '_s 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 _c_s_h history, and always appends a space. Magic-space
thus can be bound to <space>, to automatically expand _c_s_h
history. Expand-history is normally bound to _M-<_s_p_a_c_e> and
magic-space is not bound.
3. TTY MODE SANITY
As part of the editor, _t_c_s_h does a check and reset of the
terminal mode bits. If the speed has been changed, then
_t_c_s_h will change to using that speed. _T_c_s_h will also obey
changes in the padding needed by the tty. Some changes to
the command keys will be obeyed, however if a command key is
unset, _t_c_s_h will reset it to what it was. Also, the shell
will automatically turn off RAW and CBREAK modes, and will
turn on the tty driver's output processing.
4. WORD COMPLETION
In typing commands, it is no longer necessary to type a com-
plete name, only a unique abbreviation is necessary. When
you type a TAB to _t_c_s_h it will complete the name for you,
echoing the full name on the terminal (and entering it into
the edit buffer). If the prefix you typed matches no name,
the terminal bell is rung, unless the variable _n_o_b_e_e_p is
set. The name may be partially completed if the prefix
matches several longer names. If this is the case, the name
is extended up to the point of ambiguity, and the bell is
rung. This works for file names, command names, shell vari-
ables and the ~ user name convention. The variable _f_i_g_n_o_r_e
may be set to a list of suffixes to be disregarded during
completion.
_E_x_a_m_p_l_e
Assume the current directory contained the files:
DSC.TXT bin cmd lib memos
DSC.NEW chaos cmtest mail netnews
bench class dev mbox new
The command:
> gnumacs ch[TAB]
would cause _t_c_s_h to complete the command with the file name
chaos. If instead, the user had typed:
Printed 11/24/99 27 November 1996 9
TCSH(1) UNIX Programmer's Manual TCSH(1)
> gnumacs D[TAB]
_t_c_s_h would have extended the name to DSC and rung the termi-
nal bell, indicating partial completion. However, if _f_i_g_n_o_r_e
had previously been set to a list containing .NEW as one
element, e.g. ( .o .NEW ), _t_c_s_h would have completed the `D'
to DSC.TXT.
File name completion works equally well when other direc-
tories are addressed. Additionally, _t_c_s_h understands the C
shell tilde (~) convention for home directories. 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/local
> echo $lo[TAB]
will expand to "$local/". Note that a slash is appended
because the expanded variable points to a directory. Also:
> set local=/usr/local
> echo $local/[^D]
bin/ etc/ lib/ man/ src/
will correctly list the contents of /usr/local. Shell and
environment variables can also be expanded via the expand-
variables function:
> echo $local/[^X$]
> echo /usr/local/
Printed 11/24/99 27 November 1996 10
TCSH(1) UNIX Programmer's Manual TCSH(1)
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 _r_e_c_e_x_a_c_t variable makes an exact command be
expanded rather than just ringing the bell. For example,
assume the current directory has two subdirectories called
foo and food, then with _r_e_c_e_x_a_c_t 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 _a_u_t_o_l_i_s_t 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. The "noise
level" can be controlled by the value that _m_a_t_c_h_b_e_e_p is set
to: With matchbeep=nomatch, completion will only beep if
there are no matching names; with matchbeep=ambiguous, com-
pletion will _a_l_s_o beep if there are many possible matches;
with matchbeep=notunique, completion will _a_l_s_o 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 ambiquous.
If the _a_u_t_o_e_x_p_a_n_d variable is set, the expand-history func-
tion will be invoked automatically before the completion
attempt, expanding normal _c_s_h history substitutions.
For covert operation, the variable _n_o_b_e_e_p can be set; it
will prevent the completion mechanism, as well as _t_c_s_h in
general, from actually beeping. Finally, if the _a_u_t_o_c_o_r_r_e_c_t
variable is set, the spelling correction is attempted for
any path components up to the completion point.
5. LISTING OF POSSIBLE NAMES
At any point in typing a command, you may request "what
names are available". Thus, when you have typed, perhaps:
> cd ~speech/data/fritz/
Printed 11/24/99 27 November 1996 11
TCSH(1) UNIX Programmer's Manual TCSH(1)
you may wish to know what files or subdirectories exist (in
~speech/data/fritz), without, of course, aborting the com-
mand 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 com-
mand is re-echoed for you to complete.
Additionally, one may want to know which files match a pre-
fix. If the user had typed:
> cd ~speech/data/fr[^D]
all files and subdirectories 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 beeps.
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
Command Name Recognition
Command name recognition and completion works in the same
manner as file name recognition and completion above. The
current value of the environment variable _P_A_T_H is used in
searching for the command. For example
> newa[TAB]
Printed 11/24/99 27 November 1996 12
TCSH(1) UNIX Programmer's Manual TCSH(1)
might expand to
> newaliases
Also,
> new[^D]
would list all commands (along PATH) that begin with "new".
Note that Control-D has three different effects on _t_c_s_h. On
an empty line (one that contains nothing, not even spaces),
^_D sends an EOF to _t_c_s_h 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 cur-
sor is in the middle of a line (or on an empty line), a
Meta-Control-D should be typed (Escape followed by Control-
D).
6. SPELLING CORRECTION
If while typing a command, the user mistypes or misspells a
file name, user name, or command name, _t_c_s_h can correct the
spelling. When correcting a file name, each part of the
path is individually checked and corrected. Spelling
correction can be invoked in several different ways:
The _s_p_e_l_l-_w_o_r_d function, normally bound to M-s (and M-S),
will attempt to correct the word immediately before the cur-
sor. For example, suppose that the user has typed:
> cd /uxr/spol/news[ESC s]
_T_c_s_h will check the path for spelling, correct the mistakes,
and redraw the line as
> cd /usr/spool/news
leaving 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 _s_p_e_l_l-_l_i_n_e
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 _c_o_r_r_e_c_t variable is set
to an appropriate value: correct=cmd will cause the spelling
of the command name only to be checked, while correct=all
Printed 11/24/99 27 November 1996 13
TCSH(1) UNIX Programmer's Manual TCSH(1)
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 _p_r_o_m_p_t_3 variable, followed by the corrected
line, e.g.
> lz /usr/bin
CORRECT>ls /usr/bin (y/n)?
Answering 'y' or <space> at the prompt will cause the
corrected line to be used, anything else will leave the ori-
ginal line unchanged.
Automatic correction is not guaranteed to work the way the
user intended. Command line parsing is done in a rudimen-
tary fashion. It is mostly provided as an experimental
feature. Suggestions and improvements are welcome.
7. DOCUMENTATION LOOKUP
The editor function _r_u_n-_h_e_l_p (M-h) prints a help file on the
current command (using the same definition of current as the
completion routines use). This help file is found by
searching the path list HPATH for files of the form
foo.help, foo.1, foo.8, or foo.6 in that order (assuming
that the current command is foo). The file is just printed,
not paged in any way. This is because _r_u_n-_h_e_l_p is meant to
be used to look up short help files, not manual pages
(although it can do manual pages also).
8. ENHANCED HISTORY MECHANISM
_T_c_s_h will save the history list between login sessions. It
does this by writing the current list to the file "~/.his-
tory" on logout, and reading it in on login. For example,
placing the line
> set history=25 savehist=20
tells _t_c_s_h 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 _s_a_v_e_h_i_s_t larger than _h_i_s_-
_t_o_r_y. In addition to the above _t_c_s_h, keeps unparsed
(literal) versions of the history if the variable _h_i_s_t_l_i_t is
set. Also the toggle-history function toggles between the
parsed and literal version of the recalled history in the
editor buffer. For example:
> set histlit
> echo !:s/foo/bar; ls
Modifier failed.
> ^P
> echo !:s/foo/bar; ls
Printed 11/24/99 27 November 1996 14
TCSH(1) UNIX Programmer's Manual TCSH(1)
> unset histlit
> echo !:s/foo/bar; ls
Modifier failed.
> ^P
> echo unset histlit[M-r]
> echo !:s/foo/bar; ls
_T_c_s_h also supports the history escape !#. This undocumented
_c_s_h escape holds the words of the current line. This is use-
ful in renaming commands:
> mv foo bar!#:1
mv foo barfoo
Care should be taken when using this history expansion in
_c_s_h since there is no check for recursion. In _t_c_s_h up to 10
levels of recursion are allowed.
Another difference between _t_c_s_h and _c_s_h history expansion,
is the treatment of history arguments. In _c_s_h !_3_d 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 _t_c_s_h only numeric
arguments are treated as event numbers; therefore !_3_d is
interpreted as: repeat the last command that started with
the string "3d". To mimick the _c_s_h behavior !_3_\_d can be
used.
9. AUTOMATIC LOGOUT
The automatic logout time is controlled by the variable
_a_u_t_o_l_o_g_o_u_t, the value of which is the number of minutes of
inactivity will be allowed before automatically logging the
user out. When that many minutes have been reached, the
shell prints "autologout" and dies (without executing
~/.logout). The default for _t_c_s_h is to set _a_u_t_o_l_o_g_o_u_t for
60 minutes on login shells, and when the user is root. To
disable autologout (for instance in a window system), unset
the shell variable _a_u_t_o_l_o_g_o_u_t.
10. EXECUTION OF A COMMAND PRIOR TO EACH PROMPT
_T_c_s_h supports a special alias, _p_r_e_c_m_d, which if set holds a
command that will be executed before printing each prompt.
For example, if the user has done
> alias precmd date
then the program _d_a_t_e 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.
Printed 11/24/99 27 November 1996 15
TCSH(1) UNIX Programmer's Manual TCSH(1)
11. PERIODIC COMMAND EXECUTION
_T_c_s_h is now capable of providing periodic command execution
through the use of the shell variable _t_p_e_r_i_o_d and the alias
_p_e_r_i_o_d_i_c. When these items are set, the alias _p_e_r_i_o_d_i_c will
be executed every _t_p_e_r_i_o_d minutes. This provides a con-
venient means for checking on common but infrequent changes,
such as new messages. Example:
> set tperiod = 30
> alias periodic checknews
This will cause the _c_h_e_c_k_n_e_w_s(1) program to be run every 30
minutes. Having the alias _p_e_r_i_o_d_i_c set but with an unset
_t_p_e_r_i_o_d (or a value of 0 for _t_p_e_r_i_o_d) will cause _p_e_r_i_o_d_i_c to
degenerate to another form of _p_r_e_c_m_d.
12. NEW PROMPT FORMAT
The format for the _p_r_o_m_p_t shell variable has been changed to
include many new things, such as the current time of day,
current working directory, etc.. The new format uses
"%<char>" to signal an expansion, much like _p_r_i_n_t_f(_3_S). The
available sequences are:
%d or %/ 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 _a_m_p_m 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 %.
Printed 11/24/99 27 November 1996 16
TCSH(1) UNIX Programmer's Manual TCSH(1)
%n The user name, contents of $user.
%w The date in <Mon> dd format.
%W The date in mm/dd/yy format.
%D The date in yy-mm-dd 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.
The sequences for standout are often used to indicate that
this is an enabled (running as root) shell. An example:
> set prompt="%m [%h] %U[%@]%u [%/] you rang? "
tut [37] [_2:_5_4_p_m] [/usr/accts/sys] you rang? _
In addition, there is a new variable, _p_r_o_m_p_t_2, which is used
to prompt for the body of while and for loops (wherever nor-
mal _c_s_h prompts with a question mark). The default for
_p_r_o_m_p_t_2 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 _p_r_o_m_p_t_3 variable is used when
displaying the corrected command line when automatic spel-
ling correction is in effect; it defaults to "CORRECT>%R
(y|n)? ".
13. TIME-STAMPED HISTORY LIST
The history list in _t_c_s_h now has a time-of-day stamp
attached to each history list event. This time stamp is
printed whenever the history command is executed. This
allows the user to keep track of when the various events
occurred. The time stamps are not maintained on the saved
history list (also available in _c_s_h); thus, on logging back
in, all the saved history events will be recorded with the
login time as their time stamp. The time stamp printouts
can be omitted from the history list by adding the -t switch
to the _h_i_s_t_o_r_y command.
14. DIRECTORY ACCESS
_T_c_s_h supports three new flags to control directory style
Printed 11/24/99 27 November 1996 17
TCSH(1) UNIX Programmer's Manual TCSH(1)
printing for cd, pushd, popd, and dirs:
-_n Print entries in new lines so that the screen width is
not exceeded
-_l Don't print ~ but print the whole path
-_v Print the stack entries one in each line, preceeded by
the stack number.
Note that popd +n can be used to pop out stack entries of
directories that do not exist any more.
_T_c_s_h will now allow the user to access all elements in the
directory stack directly. The syntax "=<digit>" is recog-
nized by _t_c_s_h 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,
> 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.
>
_T_c_s_h will complain if you ask for a directory stack item
which does not exist.
In the normal _c_s_h, 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 _d_e_x_t_r_a_c_t 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
Printed 11/24/99 27 November 1996 18
TCSH(1) UNIX Programmer's Manual TCSH(1)
/usr/net/bin ~ /usr/spool/uucp /sys/src
> unset dextract
> pushd +2
/usr/spool/uucp /sys/src /usr/net/bin ~
The way symbolic links that point to directories are crossed
is determined by two variables: _c_h_a_s_e__s_y_m_l_i_n_k_s and
_i_g_n_o_r_e__s_y_m_l_i_n_k_s. If _c_h_a_s_e__s_y_m_l_i_n_k_s is set, then every time
the directory changes, $_c_w_d 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
_i_g_n_o_r_e__s_y_m_l_i_n_k_s is set, then directory change tries to find
where you came from before you crossed the link to change
the directory relatively. 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.
For example:
> cd /tmp
> mkdir from from/src to
> ln -s ../from/src to/dst
> echo $cwd
/tmp
> unset ignore_symlinks; unset chase_symlinks
> cd to/dst; echo $cwd
/tmp/to/dst
> cd ..
/tmp/from
> unset ignore_symlinks; set chase_symlinks
> cd /tmp/to/dst; echo $cwd
/tmp/from/src
> cd ..; echo $cwd
/tmp/from
> set ignore_symlinks; unset chase_symlinks
> cd /tmp/to/dst; echo $cwd
/tmp/to/dst
> cd ..; echo $pwd
/tmp/to
In case you are wondering what happens when you set both,
_i_g_n_o_r_e__s_y_m_l_i_n_k_s will override _c_h_a_s_e__s_y_m_l_i_n_k_s.
15. WATCHING FOR LOGINS AND LOGOUTS
_T_c_s_h has a mechanism so that the user can watch for login
and logout activity of any user or terminal in the system.
This is accomplished using the new special shell variable
_w_a_t_c_h, which contains login/terminal name pairs to be
Printed 11/24/99 27 November 1996 19
TCSH(1) UNIX Programmer's Manual TCSH(1)
checked for activity. For example:
> set watch=(sys ttyjd root console)
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=(brad any any ttyh0)
which will check for user "brad" 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=(any any)
allows the user to check on any and all login/logout
activity in the the system.
By default, the interval between checks of users on the sys-
tem is 10 minutes; this can be changed by making the first
element of _w_a_t_c_h a number of minutes which should be used
instead, as in
> set watch=(40 any any)
which will check for any users logging in or out every 40
minutes.
There is also a new command, _l_o_g, which is used to cause
_t_c_s_h to inform the user of all users/terminals affected by
_w_a_t_c_h 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. _L_o_g will reset all indication of previous announce-
ment and give the user the login list all over again, as
well as printing the current value of _w_a_t_c_h.
The first time that _w_a_t_c_h is set at _t_c_s_h 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 _w_h_o. The following sequences are available for
the format specification:
%n The name of the user that logged in/out.
%a The observed action, i.e. "logged on",
Printed 11/24/99 27 November 1996 20
TCSH(1) UNIX Programmer's Manual TCSH(1)
"logged off", or "replaced <olduser> on".
%l The line (tty) the user is logged on.
%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)
%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.
%t or %@ The time, in 12-hour, am/pm format (logout
time is approximated if unavailable).
%T The time, in 24-hour format. (but see
the "ampm" shell variable below).
%w The date in <Mon> dd format.
%W The date in mm/dd/yy format.
%D The date in yy-mm-dd format.
The %M and %m sequences are only available on systems that
store the remote hostname in /var/run/utmp. If _w_h_o 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.
16. TIMED EVENT LIST
_T_c_s_h now supports a scheduled-event list through the use of
the command _s_c_h_e_d. This command gives the user a mechanism
by which to arrange for other commands to be executed at
given times. An event is added to the scheduled-event list
by saying
> sched [+]hh:mm <command>
as in
> sched 11:00 echo It\'s eleven o\'clock.
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 +2:15 /usr/sbin/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.
>
Note that _t_c_s_h will complain if you try to make faulty time
Printed 11/24/99 27 November 1996 21
TCSH(1) UNIX Programmer's Manual TCSH(1)
specifications.
Printing the current time-event list is accomplished by giv-
ing the _s_c_h_e_d command with no arguments:
> sched
1 Wed Apr 4 15:42 /usr/sbin/uucico -r1 -sother
2 Wed Apr 4 17:00 set prompt=[%h] It's after 5; go home: >
>
There is also a mechanism by which the user can remove an
item from the list:
> sched --3
Usage for delete: sched -<item#>.
> sched -3
Not that many scheduled events.
> sched -2
> sched
1 Wed Apr 4 15:42 /usr/sbin/uucico -r1 -sother
>
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 _t_c_s_h will definitely get around to all commands
which are overdue at its next prompt. Scheduled-event list
items which come due while _t_c_s_h 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.
This mechanism is similar to, but not the same as, the _a_t(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 _t_c_s_h, 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.
17. BUILTIN FOR ls -F
There is a new builtin command called _l_s-_F which does the
same thing as the command "ls -aF" if the shell variable
_s_h_o_w_d_o_t_s has been set, and acts like "ls -F" otherwise. Ls-F
works like ls, only it is generally faster. If other
switches are passed to _l_s-_F, then the normal ls is executed.
Aliasing ls to ls-F provides a fast alternative way of list-
ing files. Note that on non BSD machines, where ls -C is
not the default, _l_s-_F, behaves like ls -CF.
Printed 11/24/99 27 November 1996 22
TCSH(1) UNIX Programmer's Manual TCSH(1)
_l_s-_F appends the following characters depending on the file
type:
= 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]
On systems that support symbolic links the variable _l_i_s_t_-
_l_i_n_k_s controls the way symbolic links are identified. If
_l_i_s_t_l_i_n_k_s is not set then the character '@' is appended to
the file. If _l_i_s_t_l_i_n_k_s is set then the following characters
are appended to the filename depending on the type of file
the symbolic links points to:
@ 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
While setting _l_i_s_t_l_i_n_k_s can be helpful while navigating
around the filesystem, it slows down _l_s-_F and it causes
mounting of filesystems if the symbolic links point to an
NFS automounted partition.
18. GLOBBING SYNTAX ADDITIONS
The syntax for any character in a range (for example ".[a-
z]*") has been extended so as to conform with standard Unix
regular expression syntax (see _e_d(1)). Specifically, after
an open bracket ("["), if the first character is a caret
("^") then the character matched will be any not in the
range specified. For example:
> cd ~
> echo .[a-z]*
.cshrc .emacs .login .logout .menuwmrc
> echo .[^.]*
.Xdefaults .Xinit .cshrc .emacs .login .logout .menuwmrc
>
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 '.'.
Printed 11/24/99 27 November 1996 23
TCSH(1) UNIX Programmer's Manual TCSH(1)
Also the ability to negate a regular expression has been
added:
> echo *
foo foobar bar barfoo
> echo ^foo*
bar barfoo
Note that this does not work correctly if the expression
does not have any wildcard characters (?*[]) or if the
expression has braces {}.
19. NEW ENVIRONMENT AND SHELL VARIABLES
On startup, _t_c_s_h now automatically initializes the environ-
ment variable _H_O_S_T to the name of the machine that it is
running on. It does this by doing a _g_e_t_h_o_s_t_n_a_m_e(2) system
call, and setting _H_O_S_T to the result.
_T_c_s_h also initializes the environment variable _H_O_S_T_T_Y_P_E 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 ._l_o_g_i_n:
set path = (~/bin.$HOSTTYPE /usr/ucb /bin /usr/bin
/usr/games .)
and the user has directories named "bin._m_a_c_h_i_n_e" (where
_m_a_c_h_i_n_e is a name from the above list), then the user can
have the same programs compiled for different machines in
the appropriate "bin._m_a_c_h_i_n_e" directories and _t_c_s_h will run
the binary for the correct machine.
The current possible values are:
_a_i_x_3_7_0 an IBM 370, running aix
_a_l_l_i_a_n_t an Alliant FX series
_a_p_o_l_l_o an Apollo running DomainOS
_a_t_t_3_b_1_5 an AT&T 3b15
_a_t_t_3_b_2_0 an AT&T 3b20
_a_t_t_3_b_2 an AT&T 3b2
_a_t_t_3_b_5 an AT&T 3b5
_b_a_l_a_n_c_e a Sequent Balance (32000 based)
_b_u_t_t_e_r_f_l_y a BBN Computer Butterfly 1000
_c_o_n_v_e_x a Convex
_d_e_c_s_t_a_t_i_o_n a DecStation XXXX
_g_o_u_l_d-_n_p_1 a Gould NP1
_h_p_3_0_0 an HP 9000, series 300, running mtXinu
_h_p_8_0_0 an HP 9000, series 800, running mtXinu
_h_p_9_0_0_0_s_3_0_0 an HP 9000, series 300, running hpux
_h_p_9_0_0_0_s_7_0_0 an HP 9000, series 700, running hpux
_h_p_9_0_0_0_s_8_0_0 an HP 9000, series 800, running hpux
Printed 11/24/99 27 November 1996 24
TCSH(1) UNIX Programmer's Manual TCSH(1)
_h_p an HP, running hpux
_i_3_8_6-_m_a_c_h an Intel 386, running mach
_i_r_i_s_4_d a Silicon Graphics Iris 4D
_m_8_8_k an mc88000 CPU machine
_m_a_c_2 an Apple Computer Macintosh II, running AUX
_m_a_s_s_c_o_m_p a Concurrent (Masscomp), running RTU
_m_i_p_s another mips CPU
_m_u_l_t_i_m_a_x an Encore Computer Corp. Multimax (32000 based)
_n_e_x_t a NeXT computer
_n_e_w_s a Sony NEWS 800 or 1700 workstation
_n_e_w_s__m_i_p_s a NeWS machine with mips CPU
_n_s_3_2_0_0_0 an NS32000 CPU machine
_p_f_a_5_0 a PFU/Fujitsu A-xx computer
_p_s_2 an IBM PS/2, running aix
_p_t_x a Sequent Symmetry running DYNIX/ptx (386/486 based)
_p_y_r_a_m_i_d a Pyramid Technology computer (of any flavor)
_r_s_6_0_0_0 an IBM RS6000, running aix
_r_t an IBM PC/RT, running BSD (AOS 4.3) or mach
_r_t_p_c an IBM PC/RT, running aix
_s_u_n_2 a Sun Microsystems series 2 workstation (68010 based)
_s_u_n_3_8_6_i a Sun Microsystems 386i workstation (386 based)
_s_u_n_3 a Sun Microsystems series 3 workstation (68020 based)
_s_u_n_4 a Sun Microsystems series 4 workstation (SPARC based)
_s_u_n a Sun workstation of none of the above types
_s_y_m_m_e_t_r_y a Sequent Symmetry running DYNIX 3 (386/486 based)
_t_i_t_a_n an Stardent Titan
_v_a_x a Digital Equipment Corp. Vax (of any flavor)
(The names of the machines are usually trade marks of the
corresponding companies.)
_T_c_s_h also initializes the shell variables _u_i_d and _g_i_d 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 _t_c_s_h will also set _o_i_d indicating the current real
organization id.
20. COMMANDS FOR DEBUGGING
Only two such commands are available at this point, both
concerned with testing termcap entries.
_t_e_l_l_t_c tells you, politely, what _t_c_s_h thinks of your termi-
nal, and _s_e_t_t_c `cap' `value' tells _t_c_s_h to believe that the
termcap capability `cap' ( as defined in _t_e_r_m_c_a_p(5) ) has
the value `value'. No checking for sanity is performed, so
beware of improper use.
21. SEARCHING FOR THE VISUAL HISTORY
Two new editor functions have been added: history-search-
backward, bound to M-p (and M-P), and history-search-
forward, bound to M-n (and M-N). Each of these search back-
ward (or forward) through the history list for previous
(next) occurrence of the first word in the input buffer as a
Printed 11/24/99 27 November 1996 25
TCSH(1) UNIX Programmer's Manual TCSH(1)
command. That is, if the user types:
> echo foo
foo
> ls
filea fileb
> echo bar
bar
>
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 glob-
bing pattern. Successive history searches use the same pat-
tern.
22. BUILTIN WHICH(1) COMMAND
There is now a builtin version of the _w_h_i_c_h(1) command. The
builtin version is just like the original, except that it
correctly reports aliases peculiar to this _t_c_s_h, and builtin
commands. The only other difference is that the builtin
runs somewhere between 10 and 100 times faster. There is
also a key-function interface to this command: the _w_h_i_c_h-
_c_o_m_m_a_n_d function (normally bound to M-?), can be used any-
where on the command line, and will in effect do a 'which'
on the command name.
23. RESTARTING A STOPPED EDITOR
There is another new editor function: run-fg-editor, which
is bound to _M-^_Z. When typed, it saves away the current
input buffer, and looks for a stopped job with a name equal
to the file name part (last element) of either the EDITOR or
VISUAL environment variables (if not defined, the default
names are "ed" and "vi" respectively). If such a job is
found, then it is restarted as if "fg %_n_a_m_e" had been typed.
This is used to toggle back and forth between an editor and
the shell easily. Some people bind this function to ^_Z so
they can do this even more easily.
24. STATUS LINE SUPPORT
_T_c_s_h has a new builtin called _e_c_h_o_t_c that allows the user to
access the terminal capabilities from the command line,
similar to the system V _t_p_u_t(1).
> echotc home
Places the cursor at the home position and
Printed 11/24/99 27 November 1996 26
TCSH(1) UNIX Programmer's Manual TCSH(1)
> echotc cm 3 10
places the cursor at column 3 row 10. This command replaces
the _e_l and _s_l variables that used contain the escape
sequences to begin and end status line changes. The command:
> echo $sl this is a test $el
is replaced by:
> echotc ts 0; echo "this is a test"; echotc fs
In addition _e_c_h_o_t_c understands the arguments _b_a_u_d, _l_i_n_e_s,
_c_o_l_s, _m_e_t_a, and _t_a_b_s And prints the baud rate, the number of
lines and columns, and "yes" or "no" depending if the termi-
nal has tabs or a meta key. This can be useful in determin-
ing 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"
_E_c_h_o_t_c accepts two flags. The flag -_v enables verbose mes-
sages and the flag -_s ignores any errors and returns the
empty string if the capability is not found.
25. EXECUTION OF A COMMAND AFTER CHANGING THE CURRENT WORKING
DIRECTORY
_T_c_s_h now supports a special alias, _c_w_d_c_m_d, which if set
holds a command that will be executed after changing the
value of $cwd. For example, if the user is running on an X
window system xterm, and has done
> alias cwdcmd 'echo -n ^[]2 $hostname $cwd ^G'
then the shell will change the title of the running xterm to
be the name of the host, a colon, and the full current work-
ing directory. Note that if a user defines _c_w_d_c_m_d to con-
tain a _c_d, _p_u_s_h_d, or _p_o_p_d, command, an infinite loop may
result. In this case, it is the author's opinion that said
Printed 11/24/99 27 November 1996 27
TCSH(1) UNIX Programmer's Manual TCSH(1)
user will get what he deserves.
26. NATIVE LANGUAGE SYSTEM
_T_c_s_h is eight bit clean (if so compiled, see the description
of the _v_e_r_s_i_o_n shell variable below), and will thus support
character sets needing this capability. The _t_c_s_h support
for NLS differs depending on whether it was compiled to use
the system's NLS (again, see the _v_e_r_s_i_o_n variable) or not.
In either case, the default for character classification
(i.e. which characters are printable etc) and sorting is 7-
bit ascii, and any setting or unsetting of the LANG or
LC_CTYPE environment variables will cause a check for possi-
ble changes in these respects.
When using the system's NLS, the _s_e_t_l_o_c_a_l_e C library func-
tion will be called to determine appropriate character clas-
sification and sorting - this function will typically exam-
ine the LANG and LC_CTYPE variables for this purpose (refer
to the system documentation for further details). Other-
wise, 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 _s_e_l_f-_i_n_s_e_r_t-
_c_o_m_m_a_n_d (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 _b_i_n_d_k_e_y, is of course still possible.
Unknown characters (i.e. those that are neither printable
nor control characters) will be printed using the \nnn for-
mat. If the tty is not in 8 bit mode, other 8 bit charac-
ters will be printed by converting them to ascii and using
standout mode. _T_c_s_h 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 _s_t_t_y(1) command in
e.g. the .login file.
27. AUTOMATIC PROCESS TIME REPORTING
Automatic process time reporting is a feature that exists in
_c_s_h, but it is usually not documented. In addition _t_c_s_h pro-
vides a slightly enriched syntax. Process time reports are
controlled via the _t_i_m_e shell variable. The first word of
Printed 11/24/99 27 November 1996 28
TCSH(1) UNIX Programmer's Manual TCSH(1)
the _t_i_m_e variable indicates the minimum number of CPU
seconds the process has to consume before a time report is
produced. The optional second word controls the format of
the report. The following sequences are available for the
format specification:
%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 following sequences are supported only in systems that
have the BSD resource limit functions.
%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.
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.
For Sequent's DYNIX/ptx %X, %D, %K, %r and %s are not sup-
ported. However, the following additional sequences are
available.
%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.
Printed 11/24/99 27 November 1996 29
TCSH(1) UNIX Programmer's Manual TCSH(1)
%p the number of reads from raw disk devices.
%q the number of writes to raw disk devices.
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.
28. OS/DEPENDENT BUILTIN SUPPORT
_T_R_A_N_S_P_A_R_E_N_T _C_O_M_P_U_T_I_N_G _F_A_C_I_L_I_T_Y
On systems that support TCF (aix-ibm370, aix-ps2) the fol-
lowing builtins have been added:
getspath Print the current system execution path.
setspath LOCAL|<site>|<cpu> ...
Set the current execution path.
getxvers Print the current experimental version prefix.
setxvers [<string>]
If the optional string is ommited, any experimen-
tal version prefix is removed. Otherwise the
experimental version prefix is set to string.
migrate [-<site>] <pid>|%<jobid> ...
migrate -<site>
The first form migrates the process or job to the
site specified or the default site determined by
the system path. The second form, is equivalent
to 'migrate -<site> $$', i.e. migrates the current
process to the site specified. Note: migrating
_t_c_s_h itself can cause unexpected behavior, since
the shell does not like to lose its tty.
In addition, jobs will print the site the job is executing.
_D_o_m_a_i_n/_O_S _S_u_p_p_o_r_t
inlib <shared-library> ...
Inlib adds shared libraries to the current enviroment.
There is no way to remove them...
rootnode //<nodename>
Change the name of the current rootnode. From now on, /
will resolve to //<_r_o_o_t_n_o_d_e>
ver [<systype>] [<command>]
Printed 11/24/99 27 November 1996 30
TCSH(1) UNIX Programmer's Manual TCSH(1)
Without arguments, print $_S_Y_S_T_Y_P_E; with the <_s_y_s_t_y_p_e>
provided, set _S_Y_S_T_Y_P_E to the one provided. Valid sys-
types are bsd4.3 and sys5.3. If a <_c_o_m_m_a_n_d> is argument
is given, then <_c_o_m_m_a_n_d> is executed under the <_s_y_s_-
_t_y_p_e> specified.
_M_a_c_h
setpath <path-spec> ...
XXX: What does it do?
_M_a_s_s_c_o_m_p/_R_T_U
universe <universe-spec> ...
Sets the current universe to the specified parameter.
_C_o_n_v_e_x/_O_S
warp [<universe-spec>] ...
Without arguments prints the current value of the
universe. With a universe argument it sets the current
universe to the value of the argument.
29. WINDOW SIZE TRACKING
On systems that support SIGWINCH or SIGWINDOW, _t_c_s_h adapts
to window resizing automatically and adjusts the environment
variables LINES and COLUMNS if set. Also if the environment
variable TERMCAP contains li#, and co# fields, these will be
adjusted also to reflect the new window size.
30. INPUT FILES
On startup _t_c_s_h will try to source /_e_t_c/_c_s_h._c_s_h_r_c and then
/_e_t_c/_c_s_h._l_o_g_i_n if the shell is a login shell. Then it will
try to source $_H_O_M_E/._t_c_s_h_r_c and then $_H_O_M_E/._c_s_h_r_c if
$_H_O_M_E/._t_c_s_h_r_c is not found. Then it will source $_H_O_M_E/._l_o_g_i_n
if the shell is a login shell. On exit _t_c_s_h will source
first /_e_t_c/_c_s_h._l_o_g_o_u_t and then $_H_O_M_E/._l_o_g_o_u_t if the shell
was a login shell.
Note: On _c_o_n_v_e_x_o_s the names of the system default files are
/_e_t_c/_c_s_h_r_c , /_e_t_c/_l_o_g_i_n and /_e_t_c/_l_o_g_o_u_t respectively and on
_i_r_i_x or _A/_U_X only the file /_e_t_c/_c_s_h_r_c is executed if the
shell is a login shell.
31. COMMAND LINE OPTIONS
This section describes options that are either undocumented
in _c_s_h (*) or present only in _t_c_s_h. (+)
Printed 11/24/99 27 November 1996 31
TCSH(1) UNIX Programmer's Manual TCSH(1)
-_d Load ~/.cshdirs (If _t_c_s_h was compiled with CSHDIRS
enabled)(+)
-_l Make _t_c_s_h behave like a login shell. (+)
-_m Allow reading of a .cshrc that does not belong to the
effective user. Newer versions of _s_u(_1) can pass that to
the shell. (some versions of csh have it) (+*)
-_q Make the shell accept SIGQUIT, and behave when it is
used under a debugger. Job control is disabled. (*)
FYI
This shell uses cbreak mode but takes typed-ahead characters
anyway. You can still use _s_t_t_y(1) to set some of the modes
of your terminal (but not bindings).
This shell will restore your tty to a sane mode if it
appears to return from some command in raw, cbreak, or noe-
cho mode.
ENVIRONMENT
HPATH -- path to look for command documentation
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)
NEW SHELL VARIABLES
addsuffix add a / for directories, and a space for normal
files when complete matches a name exactly. If
unset don't add anything extra.
ampm show all times in 12 hour, AM/PM format.
autocorrect
Correct mis-spelled path components automatically
before attempting completion.
autoexpand
invoke the expand-history function automatically
on completion.
Printed 11/24/99 27 November 1996 32
TCSH(1) UNIX Programmer's Manual TCSH(1)
autolist list possibilities on an ambiguous completion.
autologout
number of minutes of inactivity before automatic
logout.
chase_symlinks
always resolve symbolic links to real names on cd,
etc.
correct automatically try to correct the spelling of com-
mands. Must be set to either correct=cmd, only
command name will be corrected, or correct=all,
the whole line will be corrected.
dextract extract a directory on pushd rather than rotating.
edit use the input editor, set by default.
fignore list of file name suffixes (e.g. .o, ~) to ignore
during complete.
gid the current real group id.
histlit If set, history lines in the editor will be shown
with its literal value (that is the line as it was
input) instead of the shells lexical version. The
current history line can be toggled between
literal and lexical with the toggle-literal-
history function. History lines saved at shell
exit are also saved as this variable indicates.
ignore_symlinks
don't resolve symbolic links to real names on cd,
etc.
listjobs list all jobs when suspending. set listjobs=long,
produces long format.
listlinks Resolve symbolic links when listing files so that
the correct filetype is shown.
listmax maximum number of items to list without asking
first.
matchbeep control beeping on completion. With
matchbeep=nomatch, completion only beeps when
there is no match, with matchbeep=ambiguous, beeps
also when there are multiple matches, with
matchbeep=notunique, beeps when there is one exact
and other longer matches, with matchbeep=never, it
never beeps.
Printed 11/24/99 27 November 1996 33
TCSH(1) UNIX Programmer's Manual TCSH(1)
nobeep Disables beeping completely.
oid The organization id number (Domain OS only).
printexitvalue
if an interactive program exits non-zero, print
the exit value.
prompt the string to prompt with.
prompt2 the string to prompt for while and for loops with.
prompt3 the string to prompt with when automatic spelling
correction has corrected a command line.
pushdtohome
make pushd with no args do a "pushd ~" (like cd
does).
pushdsilent
do not print the dir stack on every pushd and
popd.
recexact recognize exact matches even if they are ambigu-
ous.
recognize_only_executables
list choices of commands only displays files in
the path that are executable (slow).
rmstar Prompt the user before execution of `rm *'.
savehist number of history items to save between login ses-
sions.
shlvl Integer value indicating the number of nested
shells.
showdots show hidden files in list and complete operations.
tcsh Contains the current version of the shell as
R.VV.PP. The _R indicates the major release number,
the _V_V the current version and the _P_P the
patchlevel.
term the terminal type; see above.
tperiod periodic command wait period (in minutes).
tty The name of the tty, or empty if not attached to
one.
Printed 11/24/99 27 November 1996 34
TCSH(1) UNIX Programmer's Manual TCSH(1)
uid the current real user ID.
version the version ID stamp for this _t_c_s_h. It contains,
the origin of this version of _t_c_s_h, the date this
version was released and a string containing a
comma separated list of the compile time options
enabled:
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.
dir Set if tcsh should save and restore the directory
stack.
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.
In addition to the above strings, administrators can enter
local strings to indicate differences in the local version.
visiblebell
use the visible bell (screen flash) rather than
audible bell.
watch list of events to watch.
who format string for the printouts generated when
_w_a_t_c_h is set.
wordchars list of nonalphanumeric characters considered part
of a word for the purpose of the forward-word,
backward-word etc functions -- defaults to "*?_-
.[]~=".
NEW SPECIAL ALIASES
_c_w_d_c_m_d the command is run after every change of working
directory.
Printed 11/24/99 27 November 1996 35
TCSH(1) UNIX Programmer's Manual TCSH(1)
_p_e_r_i_o_d_i_c the command to be run every _t_p_e_r_i_o_d minutes.
_p_r_e_c_m_d the command to be run prior to printing each
prompt.
SEE ALSO
csh(1), chsh(1), termcap(5)
BUGS
The screen update for lines longer than the screen width is
very poor if the terminal cannot move the cursor up (i.e.
terminal type "dumb").
I am certain that there are bugs. Bugs (preferably with
fixes) should be sent to Christos Zoulas
(christos@ee.cornell.edu).
VERSION
This man page documents tcsh 6.00.00 (Cornell) 07/04/91.
AUTHORS
Ken Greer, HP Labs, 1981
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 _w_h_i_c_h feature to the editor, and the code
for _l_s-_F . Also numerous bug fixes, modifications, and per-
formance 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 expres-
sions, 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-90
Printed 11/24/99 27 November 1996 36
TCSH(1) UNIX Programmer's Manual TCSH(1)
ported tcsh to HPUX, and System V rel. 2 and 3 and wrote a
SysV version of getwd.c. Added SHORT_STRINGS support.
James J Dempsey, BBN, 1988, and Paul Placeway, OSU, 1988
Re-ported tcsh to A/UX.
BUGFIXES AND ENHANCEMENTS
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 attri-
butes when output is not to a tty.
Johan Widen, SICS Sweden, 1990
Shell level variable, mach support, correct-line, 8-bit
printing.
Matthew T. 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 reseting to DEL bug.
Patrick Wolfe, Kuck and Associates, Inc., 1988
Cleaned up VI mode and wrote the new editor description (in
Printed 11/24/99 27 November 1996 37
TCSH(1) UNIX Programmer's Manual TCSH(1)
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 cur-
sor.
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 comput-
ers.
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 Univer-
sity, 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
Printed 11/24/99 27 November 1996 38
TCSH(1) UNIX Programmer's Manual TCSH(1)
Fixed character redrawing code insert bugs, and made redraw-
ing 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 expan-
sion, autolist, added autoexpand, updated the manual.
THANKS TO
A special thanks to: Bryan Dunlap, Clayton Elwell, Karl
Kleinpaste, Bob Manson, Steve Romig, Diana Smetters, Bob
Sutterfield, Mark Verber, Elizabeth Zwicky, and all the
other people at Ohio State for suggestions and encourage-
ment.
Also, thanks to all the people on the net for putting up
with, reporting bugs in, and suggesting new additions to the
old tcsh editor.
Printed 11/24/99 27 November 1996 39