tcsh - Command Line Stuff

tcsh incorporates many mechanisms to make your commandline session easier.
Commandline Editing
This allows you to edit a command as you type it. For example, say you've typed
tcsh> ls /usr/locak/bin
You really meant to type local instead of locak, and you want to fix your typo without retyping the last part of the command. Commandline editing allows you to use the left and right arrow keys to move back to the part of the commandline you want to fix, and edit it. By default, tcsh uses the emacs-style keybindings. Some useful basic keybindings: tcsh can also be configured for vi-style keybindings if you prefer. To do this, type
tcsh> bindkey -v
Command History
tcsh keeps a list of the last x commands you've entered. You can use the up and down arrows to scroll through the previous commands. So, for example, if you've entered the following commands:
tcsh> ls -l ~/tmp
tcsh> rm ~/tmp/clipboard
Now, if you want to look at the ~/tmp directory again to see what files remain, you needn't type the first command again. Instead, hit the up-arrow twice to get back to the original command, and hit enter to execute it again. (The keybindings for the history mechanism are also configurable; see description of the "bindkey" command on the tcsh manpage.)
Filename Completion
Say you have the following directory list:
tcsh> ls -1
superman
suroth
If you want to remove the file without typing the whole filename, you can use file completion. Simply type rm sup and then hit the tab key. tcsh looks for a filename starting with sup and completes the filename for you. You commandline now looks like this:
tcsh> rm superman
Now you can hit return to execute the command. If, however, you'd just typed rm s before hitting tab, it would have been expanded into rm su followed by a beep. tcsh is telling you that more than one filename starts with su, and it has no unique completion to give you. At this point you can type more letters to make it unique and then hit tab again.
Command Completion
Command completion works just like filename completion. For example, you can type gh followed by tab, and it'll be expanded to ghostscript.
Glob Expansion
A glob is a UNIX wildcard pattern. The basic wildcard characters are * and ?. Say you have the following files:
tcsh> ls -l
-rw-------  1 roth     student      2537 Jan 23 17:12 etherpower-info
-rw-------  1 roth     student      2609 Jan 29 03:42 get-fdisk
-rw-------  1 roth     student      2081 Jan 19 21:30 get-libgr
-rw-------  1 roth     student      1976 Jan 29 03:46 get-modules
-rw-------  1 roth     student      2934 Jan 29 03:43 get-mtools
-rw-------  1 roth     student         0 Feb  5 19:08 get-netscape
-rw-------  1 roth     student     30848 Jan 31 01:05 www
You want to remove all the files which start with get except for get-modules. The easiest way to do it would be to get tcsh to expand the filenames for you, and then use commandline editting to remove the one you don't want to delete. So, you type the following:
tcsh> rm get*
Now you type CTRL-X, followed by the * key. This causes tcsh to expand the glob for you. Your command line now looks like this:
tcsh> rm get-fdisk get-libgr get-modules get-mtools get-netscape
Your cursor is positioned at the end of the line. Now you can use commandline editting to go back into the line and delete get-modules. Your line will look like this:
tcsh> rm get-fdisk get-libgr get-mtools get-netscape
Hitting enter will execute the command, and you've just saved a lot of typing!

Mark D. Roth (roth@uiuc.edu)