% echo $prompt % % set prompt="%n@%m%~>" scot@iriquois~>echo $prompt %n@%m%~> scot@iriquois~>This gives me my username(%n), the @ symbol(@), the machine I am working on(%m), and my current location in the directory structure(the ~ signifies my home directory).
Another type of special shell variable are the environment variables. Enviroment keep track of information that other programs will need. For example, the DISPLAY enviroment variable is used by X windows applications to determine the display location. With X windows you have the option of starting an application on a host and having it display on another machine. Once a variable has been set you can invoke it by preceding its name with a $ sign(for example, $DISPLAY). To get a list of all the current enviroment variables used by your shell use the env command. If you want to change the enviroment variable use the setenv command.
% echo $DISPLAY creek:0.0 % setenv DISPLAY crow:0 % echo DISPLAY crow:0 %Now our X applications will display on crow.
Table9.1: Some T-shell Enviroment Variables -------------------------------------------------------------- $HOME Absolute path to your home directory location $PATH Where the shell looks for binary files. $USER Your login name $MAIL Where you mail box is located $DISPLAY Where to display X windows applications $HOST Current host your are working on --------------------------------------------------------------One special enviroment variable is the PATH variable. The PATH is where the shell looks for executable commands. To determine where a command is located in your path use the which command.
% which tcsh /bin/tcsh %
% rehash %
% alias nv rlogin navaho % nv login:We have shorted the command rlogin navho to nv. Aliases can save you a tremendous amount of typing.
% history
1 11:31 ls
2 11:32 grep.pl array.pl
3 12:44 rlogin creek -l tai
4 9:40 ls
5 9:40 emacs
%
The number of commands that is displayed is set in your
shell startup file. For example, if you put set history=25
savehist=20 in your $HOME/.tcshrc file you can view the last 25 commands and when you
exit the shell the last 20 will be saved. To execute one of the commands from the history
list use the exclamation point followed by the number of the command.
% !4 ls spline.m taylor.m %Another way to traverse through commands is by using the
Table9.4: T-shell Command Line Editing
--------------------------------------------------------------
MOVING ON THE COMMAND LINE:
--------------------------
<CTRL-f> moves the cursor forward one character
<CTRL-b> moves the cursor back one character
<CTRL-a> moves the cursor to the beginning of the line
<CTRL-e> moves to the end of the line
DELETING CHARACTERS
-------------------
BACKSPACE delete the previous character
<CTRL-d> delete the current character
<CTRL-k> delete from the current position to the end of line
<CTRL-u> delete the whole line
MISC COMMANDS
-------------
<CTRL-p> list the previous command
<CTRL-n> list the next command
<CTRL-d> completes the program name (for example, em<CTRL-D> ,
will list all the files in your path that start with em)
<CTRL-i> completes the filename (for example, ls tay<CTRL-i> ,
will try to complete all files that start with tay)
<TAB> same as <CTRL-i>
<META-s> correct the spelling of the previous word.
NOTE: The META key is usually set to be the ESC key.
(for example, cd /usr/spol/news<META-s> , will correct the
spelling of the directory to /usr/spool/news
--------------------------------------------------------------
Try out some of these key sequences.
# Source common aliases & stuff: set history=25 savehist=20 alias h history alias nep rlogin neptune.tcad.ee.ufl.edu set prompt="%n@%m%~>" set path=($path ~/bin)You can see I have added my home binary directory to the the system-wide $path variable. Now I can execute commands from my home bin directory
When you make changes to your $HOME/.tcshrc file you use the source command to have the tcsh reread the file. The format is source $HOME/.tcshrc. When you start the tcsh it will try to source /etc/csh.cshrc and then /etc/csh.login if the shell is a login shell. Then it will try to source $HOME/.tcshrc and then $HOME/.cshrc if $HOME/.tcshrc is not found. Then it will source $HOME/.login if the shell is a login shell. On exit tcsh will source first /etc/csh.logout and then $HOME/.logout if the shell was a login shell.