Home | RecentChanges | Preferences

Here I request everyone to put in their favorite tricks and tips on using

tcsh effectively. When enough meat is generated here, than we may go ahead and refactor this page.

Urgent: We need some full form of TIP -- Tcsh In Practise, or Tcsh Is P?? etc.

Urgent: Webmaster .. which Wiki is this .. how to get monospaced font ?

TIP#1: Overcome lack of functions With a clever use of alias and scripts, lack of 'functions' can be easily overcome.

e.g. I want a 'cd' without argument to behave as cd - instead of cd ~. So i do following:

 'alias cd   'source ~$USER/.tcsh/func_cd'
where the script ~$USER/.tcsh/func_cd is
 if ( "X$1" == "X" ) then
  cd -
  cd $1

TIP#2: Enhance the basic install with a souped-up .tcshrc

It's easy to make a default tcsh install even better and (some say) more user friendly.

Visit http://tcshrc.sourceforge.net/ and download their package. You'll be quite surprised at the features it adds to your tcsh install.

TIP#3: Send error messages to stderr not stdout

launch a bash or Bourne shell one-liner:

 /bin/sh -c "${ME}: USAGE foo [bar|baz] quux >&2"

on some systems you can do:

echo my error message > /dev/stderr


echo error > /dev/fd/2

TIP#4: set DISPLAY if remote login

put in your .tcshrc:

if( $?REMOTEHOST && ! $?DISPLAY ) then

    setenv DISPLAY ${REMOTEHOST}:0
TIP#5: search a directory tree

I'm often asked how to find a pattern in certain types of files within a directory tree. For example, how does one find all occurrences of a variable in C source code without finding them in the SCCS history files? Here's an alias to do it:

 alias cgrep 'find . -regex ".*/SCCS" -prune -o -name "*.[ch]" -type f -exec grep \!* {} /dev/null \;'
Then, you can simply use it as:
Note that this requires a "find" command which supports the "regex" option, such as GNU find. By changing the strings following the "regex" and "name" options, you can modify this to search for various types of files while excluding other types of directories.
Tip#6: enable colorful NLS messages

  1. check your $version shell variable, it should contain ccat and nls. If not you need to recompile tcsh and enable COLORCAT in config_f.h
  2. install the message catalogs
  3. set the shell variable colorcat
  4. theoretically that's it

Tip#7: List possible completions

I often see Bash users complain that Tcsh does not give a list of completions with the tab key. This is not true. Not only can Tcsh list complentions, but it can do it in color. Just add this to your ~/.tcshrc

set autolist set color set colorcat

I also like to set this option...

set nobeep

Home | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited June 28, 2004 14:12 (diff)