Terminal GuideTerminal Guide

Tcsh

TENEX C Shell

Enhanced C shell with command-line editing and programmable completion

Non-POSIXReleased: 1983Official Site

Overview

Tcsh (TENEX C Shell) is an enhanced version of the C shell (csh) with additional features like command-line editing, programmable completion, and spelling correction. It was the default root shell on FreeBSD for many years.

Quick Facts

Full NameTENEX C Shell
CategorySpecialized
POSIX CompliantNo
Config File.tcshrc / .cshrc
Default OnFreeBSD (root)
First Release1983

Who Should Use Tcsh?

  • C programmers - C-like syntax feels familiar
  • FreeBSD users - Historical default shell
  • Legacy csh users - Drop-in csh replacement
  • Interactive use - Good completion and editing

Installation

Install tcsh on various systems.

bash
# Install on macOS
brew install tcsh

# Install on Debian/Ubuntu
sudo apt install tcsh

# Install on Fedora
sudo dnf install tcsh

# FreeBSD (pre-installed)
# tcsh is available as /bin/tcsh

# Set as default shell
chsh -s $(which tcsh)

Basic Usage

Tcsh uses C-like syntax.

bash
#!/bin/tcsh

# Variables (set for local, setenv for environment)
set name = "World"
setenv PATH "$HOME/bin:$PATH"

# Arrays (1-indexed)
set fruits = (apple banana cherry)
echo $fruits[1]  # apple

# Conditionals (C-style)
if ($name == "World") then
    echo "Hello, World!"
endif

# Loops
foreach fruit ($fruits)
    echo $fruit
end

# C-style for loop
@ i = 1
while ($i <= 5)
    echo $i
    @ i++
end

Configuration

Tcsh configuration files.

bash
# ~/.tcshrc - Main configuration file
# ~/.login - Login shell only

# Custom prompt with colors
set prompt = "%B%n@%m%b:%~%# "

# Enable features
set autolist        # List completions automatically
set complete = enhance  # Enhanced completion
set correct = cmd   # Command spelling correction
set history = 1000  # History size

# Aliases
alias ll 'ls -la'
alias h 'history 25'

# Bindkey for editing
bindkey -e  # Emacs keybindings
# bindkey -v  # Vi keybindings

Key Features

C-like Syntax

Familiar to C programmers with similar expressions

Programmable Completion

Context-aware tab completion

Spelling Correction

Automatic correction for command typos

Job Control

Advanced job management features

FAQ

Should I use tcsh for scripting?

No. The csh/tcsh syntax has many pitfalls for scripting (see "Csh Programming Considered Harmful"). Use sh, bash, or another Bourne-style shell for scripts.

What is the difference between csh and tcsh?

Tcsh is csh with additional features like command-line editing, history, and programmable completion. Tcsh is backward compatible with csh scripts.

Summary

Key takeaways for Tcsh:

  • Enhanced C shell with interactive features
  • C-like syntax familiar to programmers
  • Good for interactive use, not recommended for scripting
  • Historical importance on BSD systems

Official Documentation

For authoritative information, refer to the official documentation:

Written by Dai AokiPublished: 2026-01-20

Related Articles