Defining command completions for tcsh
The default interactive shell is tcsh. Recently I discovered that this shell
also has the ability to complete your command-line by using the built-in
complete
command. After some experimentation, I’ve added the following lines
to my /etc/csh.cshrc
file:
complete cd 'p/1/d/' complete man 'p/1/c/' complete git 'p/1/(add am checkout commit diff format-patch gc init log mv rm revert status)/' complete openssl 'p/1/(enc rand base64)/' 'p/2/(-base64 -aes-256-cbc -idea-cbc -bf-cbc)/' complete portsnap 'p/1/(fetch)/' 'p/2/(update)/' complete portmaster 'p/1/(-a)/' 'p/2/(-B)/' 'p/3/(-d)/' complete shutdown 'p/1/(-p)/' 'p/2/(now)/' complete df 'p/1/(-h)/' complete du 'p/1/(-csm)/'
This means e.g. that if I type cd
followed by the TAB
key, the shell
will list all available subdirectories. For another example, if I type
portsnap
and press the tab
key twice, it expands to portsnap fetch
update
. Especially with programs like openssl
and git
which have a
ton of available commands, this comes in very handy.
For comments, please send me an e-mail.
Related articles
- Use
pygmentize
as a colorizedcat
- Opening vim in a new terminal
- Setting the terminal title with urxvt and tcsh