set
The set command is used to assign values to shell variables. The
syntax for the command is:
set <VAR> <string>
Issuing the set command without any arguments displays the
values of all shell variables. The set command is used
primarily in the initialization files, but can be used at any
time if necessary.
The following should be put in your .cshrc file (if it isn't already there):
set ignoreeof=yes noclobber=yesThe ignoreeof variable, when set to 'yes', keeps the <ctrl-d> sequence (end-of-file character) from accidently killing a C-Shell. The noclobber variable, when set to 'yes', keeps output redirection from overwriting existing files.
setenv <VAR> <string>
Issuing the setenv command without any arguments displays the
values of all environment variables. The setenv command is similar
to the set command in that its primary use is in initialization files.
An important use of the setenv command outside of initialization
files is to redefine the DISPLAY variable when logging in to a remote
terminal. If you log in to a remote machine, then run an X-windows-based
program from that remote machine, the X server needs to know where to
display the window for program output. The DISPLAY variable is used
for this purpose. Enter the following from the remote machine to
set the DISPLAY environment variable:
setenv DISPLAY <hostname>:0
After setting the DISPLAY variable, add the name of the remote
machine to the list of those machines allowed to make connections with the
X server with the command xhost. If remotely connected to
gandalf the following would add gandalf to the list:
xhost + gandalf
You can now run your X application on the remote host.
alias
The alias command allows commands or commands with parameters
to be aliased with a shorter, sometimes single-character version
of the command. To use alias to redefine the ls -FC
command to the single character l, enter the following:
alias l ''ls -FC''
Giving the alias command without any parameters lists the
aliases that are currently defined.
Place any aliases that you plan to use often in your .cshrc file
so you don't have to reenter them every time you login. Another
reason for placing the alias declaration in the .cshrc is that
aliases are window-specific. If you declare an alias within one
window, then it is only recognized within that window. Placing
an alias declaration in the .cshrc assures that the alias will
be available regardless of the window that you are in.
A list of aliases that you should consider placing in your .cshrc follows:
alias cp cp -i alias mv mv -i alias rm rm -iThe -i argument specifies interactive prompting if existing data might be overwritten, a precaution that might save you a considerable amount of work in the future.
history
Commands that have already been issued are 'remembered' and can easily
be repeated with a couple of keystrokes if the history command
is used. In your .cshrc file, include the statement:
set history=20
The set command assigns the number of commands that history
will be able to access. Include the statement 'alias h history' in
your .cshrc file so that you only need to enter 'h' to get the command
history list. Note that the history list is window-specific in that
commands entered in one window don't show up on the history list of
another.
To use the history list after following the above steps, enter 'h'
after you have issued a few commands. You will see a numbered
list showing the last twenty commands that you have entered. To
reexecute a command, enter a bang character (an exclamation point)
followed by the number of the command. Another way of reexecuting
a command is to type a bang character followed by enough of a previous
command to uniquely distinguish that command from others in the
history list. If a previous command had been:
grep strcmp 3dlife.c
then entering !g would reexecute that command if no other
command in the history list began with 'g'. If more than one command
in the history list is described by the character or string after the
bang character, then the most recent command in the list fitting that
description is reexecuted.
If you just want to reexecute the last command typed, type two bang characters followed by a carriage return. In addition, by putting text after the bang characters you can modify the previous command. As an example, if you forgot to type the destination while copying a file you would get an error message telling you the proper syntax of the copy command:
cp /backup/*.tex <CR> (Missing destination for copy)The text following the bang characters is concatenated with the previous command string and then the command is executed.To reexecute this command specifying the destination:
!!latex (latex is destination directory)