tcsh ( “tee-see-shell”, “tee-shell”, or as “tee see ess aitch”,
tcsh
) is a
Unix shell
A Unix shell is a command-line interpreter or shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language, and is used by the operating system t ...
based on and
backward compatible with the
C shell (
csh
).
Shell
It is essentially the C shell with programmable
command-line completion,
command-line
A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive command (computing), commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invokin ...
editing, and a few other features. Unlike the other common shells,
functions cannot be defined in a tcsh script and the user must use aliases instead (as in csh). It is the native root shell for BSD-based systems such as
FreeBSD
FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD), which was based on Research Unix. The first version of FreeBSD was released in 1993. In 2005, FreeBSD was the most popular ...
.
tcsh added filename and command completion and command line editing concepts borrowed from the
TENEX operating system, which is the source of the “t”.
[
] Because it only added functionality and did not change what was there, tcsh remained
backward compatible with the original C shell. Though it started as a side branch from the original csh source tree that
Bill Joy
William Nelson Joy (born November 8, 1954) is an American computer engineer and venture capitalist. He co-founded Sun Microsystems in 1982 along with Scott McNealy, Vinod Khosla, and Andy Bechtolsheim, and served as Chief Scientist and CTO a ...
had created, tcsh is now the main branch for ongoing development.
tcsh is very stable but new releases continue to appear roughly once a year, consisting mostly of minor bug fixes.
On many systems, such as
macOS
macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac (computer), Mac computers. Within the market of ...
and
Red Hat Linux
Red Hat Linux was a widely used commercial open-source Linux distribution created by Red Hat until its discontinuation in 2004.
Early releases of Red Hat Linux were called Red Hat Commercial Linux. Red Hat published the first non-beta release ...
,
csh
is actually
tcsh
. Often one of the two files is either a
hard link
In computing, a hard link is a directory entry (in a directory-based file system) that associates a name with a file. Thus, each file must have at least one hard link. Creating additional hard links for a file makes the contents of that file ac ...
or a
symbolic link
In computing, a symbolic link (also symlink or soft link) is a file whose purpose is to point to a file or directory (called the "target") by specifying a path thereto.
Symbolic links are supported by POSIX and by most Unix-like operating syste ...
to the other, so that either name refers to the same improved version of the C shell.
On
Debian
Debian (), also known as Debian GNU/Linux, is a Linux distribution composed of free and open-source software, developed by the community-supported Debian Project, which was established by Ian Murdock on August 16, 1993. The first version of De ...
and some derivatives (including
Ubuntu), there are two different packages:
csh
and
tcsh
. The former is based on the original BSD version of csh and the latter is the improved tcsh.
History
The “t” in
tcsh
comes from the “T” in
TENEX, an
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
which inspired Ken Greer at
Carnegie Mellon University
Carnegie Mellon University (CMU) is a private research university in Pittsburgh, Pennsylvania. One of its predecessors was established in 1900 by Andrew Carnegie as the Carnegie Technical Schools; it became the Carnegie Institute of Technology ...
, the author of tcsh, with its command-completion feature. Greer began working on his code to implement Tenex-style file name completion in September 1975, finally merging it into the C shell in December 1981.
[ Mike Ellis at Fairchild A.I. Labs added command completion in September 1983.][ On October 3, 1983, Greer posted source to the net.sources newsgroup.][
]
Significant features
*Command history
**The built-in history
command displays the previously entered commands
**Use of / at the command line to allow the user to select a command from the history to edit/execute
**Invoking previous commands using command history
Command history is a feature in many operating system shells, computer algebra programs, and other software that allows the user to recall, edit and rerun previous commands.
Command line history was added to Unix in Bill Joy
William Nelson ...
***!!
executes the previous command
***!n
executes the nth command that was previously executed
***!-n
executes the command that was executed ''n'' commands ago
***!''string''
executes the most recently executed command that starts with ''string''
***!?''string''
executes the most recently executed command that contains ''string''
**Using history in new commands
***!*
- refers to all of the arguments from the previous command
***!$
- refers to the last argument from the previous command
***!^
- refers to the first argument from the previous command
***!:n
- refers to the nth argument from the previous command
***!:m-n
- refers to the mth through nth arguments from the previous command
***!:n-$
- refers to the nth through the last argument from the previous command
*Command line editing
*Auto-completion of file names and variables as well as programmable completion at the command line
*Alias argument selectors; the ability to define an alias to take arguments supplied to it and apply them to the commands that it refers to. Tcsh is the only shell that provides this feature.
**\!#
- argument selector for all arguments, including the alias/command itself; arguments need not be supplied.
**\!*
- argument selector for all arguments, excluding the alias/command; arguments need not be supplied.
**\!$
- argument selector for the last argument; argument need not be supplied, but if none is supplied, the alias name is considered to be the last argument.
**\!^
- argument selector for first argument; argument MUST be supplied.
**\!:n
- argument selector for the nth argument; argument MUST be supplied; n=0 refers to the alias/command name.
**\!:m-n
- argument selector for the arguments from the mth to the nth; arguments MUST be supplied.
**\!:n-$
- argument selector for the arguments from the nth to the last; at least argument n MUST be supplied.
**\!:n*
- argument selector for the arguments from the nth to the last; sufficient arguments need not be supplied.
#Alias the cd command so that when you change directories, the contents are immediately displayed.
alias cd 'cd \!* && ls'
*Wildcard matching
if ( "$input" =~ -9 ) then
echo "the input starts with an integer"
else
echo "the input does NOT start with an integer"
endif
*Job control
*The built-in where
command. Works like the which
command but shows all locations of the target command in the directories specified in $PATH
rather than only the one that will be used.
Deployment
Early versions of Mac OS X shipped with tcsh as the default shell, but the default for new accounts became bash as of 10.3 then zsh as of 10.15. (tcsh is still provided, and upgrading the OS does not change the shell of any existing accounts). tcsh is the default root shell of FreeBSD
FreeBSD is a free and open-source Unix-like operating system descended from the Berkeley Software Distribution (BSD), which was based on Research Unix. The first version of FreeBSD was released in 1993. In 2005, FreeBSD was the most popular ...
(the default user shell is POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inte ...
-based)POSIX 2008 Shell Command Language
"The System V shell was selected as the starting point for the Shell and Utilities volume of POSIX.1-2008. The BSD C shell was excluded from consideration" and its descendants like DragonFly BSD
DragonFly BSD is a free and open-source Unix-like operating system forked from FreeBSD 4.8. Matthew Dillon, an Amiga developer in the late 1980s and early 1990s and FreeBSD developer between 1994 and 2003, began working on DragonFly BSD in ...
and DesktopBSD
DesktopBSD is a Unix-derivative, desktop-oriented operating system based on FreeBSD. Its goal is to combine the stability of FreeBSD with the ease-of-use of K Desktop Environment 3, which is the default graphical user interface.
History an ...
.
See also
* Comparison of command shells
References
External links
*
tcsh releases
tcsh mailing list
Archive for the O'Reilly book "Using csh and tcsh"
{{Unix shells
Cross-platform free software
Free software programmed in C
Scripting languages
Software using the BSD license
Text-oriented programming languages
Unix shells