Linux Unleashed, Third Edition:tcsh3
-->
Previous
Table of Contents
Next
Customizing tcsh
Weve shown many ways of customizing tcsh in this chapter. If you simply enter the commands that we have discussed at the command line, the changes you make will be lost every time you log out of the system. This section describes how to store these changes in a file that are executed each time you start tcsh.
Tip: If you make even a small mistake editing the tcshfiles, you can cause problems when logging in. For this reason, make safety backup copies before you edit and verify each of your edits carefully before you save the new file.
Two initialization files are important to tcsh. The first is called the login file. The commands in this file are executed when you first log in to Linux. The contents of the default login file are as follows:
if ($?prompt) then
#this means that the shell is interactive
umask 022
set cdpath = ( /usr/spool )
set notify
set history = 100
set histfile = .history
# The savehist variable is set to tell tcsh to
# save the history list to the history file on
# logout. The value of 25 means that tcsh will
# save the last 25 commands to the history file.
set savehist = 25
setenv OPENWINHOME /usr/openwin
setenv MANPATH /usr/local/man:/usr/man/preformat:/usr/man:/usr/X11/man:
/usr/openwin/man
setenv MINICOM -c on
setenv HOSTNAME cat /etc/HOSTNAME
set path = ( $path /usr/X11/bin /usr/andrew/bin
$OPENWINHOME/bin /usr/games . )
endif
# I had problems with the Backspace key installed by tset, but you might
want
# to try it anyway, instead of the setenv term
.. below it.
# eval tset -sQ $term
# setenv term console
if ! $?TERM setenv TERM console
set prompt = %m:%~%#
alias ls ls -F
if ( { tty --silent } ) then >& /dev/null
echo ;fortune;echo
endif
This file, csh.login, can be found in the /etc directory. If you want to change any of the settings found in csh.login, copy it to your home directory and make the changes you want there.
The other file that tcsh makes use of is cshrc. The commands in this file are executed each time a copy of the tcsh program is run. Examples of the types of commands that usually appear in this file are aliases and variable declarations. This file, csh.cshrc, is also contained in the /etc directory. If you want to make changes to this file, copy it to your home directory and make your changes there.
When you first log in to Linux, tcsh executes the /etc/csh.cshrc file, followed by the /etc/csh.login file. It then checks your home directory to see if you have a personal copy of the csh.cshrc file. This file can be named either .tcshrc or .cshrc. If you have one of these files in your home directory, tcsh executes it next.
tcsh then checks to see if you have your own copy of the csh.login file in your home directory. This file must be named .login. If you do have a .login file in your home directory, it is executed next.
Whenever you start another copy of tcsh after you log in to the system, it executes the commands that are in the /etc/csh.cshrc file and then checks your home directory to see if there is a .tcshrc or a .cshrc file there.
tcsh Command Summary
Here are some of the most useful tcsh commands:
alias: Used to set and display aliases, command nicknames that can be set by the user.
bg: Background command. Forces a suspended process to continue running in the background.
bindkey: Enables users to change the editing actions that are associated with a key sequence.
cd: Changes the current working directory to the directory specified.
exit: Terminates the shell.
fg: Foreground command. Forces a suspended process to continue running in the foreground.
history: Enables users to display and modify the contents of the history list and the history file.
kill: Terminates another process.
logout: Terminates a login shell.
set: Used to set the value of tcsh variables.
source: Reads and executes the contents of a file. This command is discussed in more detail in Chapter 14.
unalias: Used to remove aliases that have been defined using the alias command.
tcsh Variables
Here are some of the most useful tcsh variables:
autocorrect: If this is set, tcsh automatically tries to correct command-line spelling errors.
histfile: The name of the file that is used to store the command history.
history: The size of the history list.
home: The users home directory.
path: The search path that tcsh uses when looking for executable programs.
prompt: The first-level prompt that displays on the command line.
prompt2: The second-level prompt that displays when a for, foreach, or while loop is expecting input.
prompt3: The third-level prompt that displays when tcsh is attempting to correct a spelling error in a command.
savehist: This variable must be set to the number of history commands that you want to save, if you want tcsh to save the history list when you log out.
watch: Contains a list of user terminal pairs to watch for logins and logouts.
Summary
The last three chapters have presented the fundamental commands and concepts of the three most popular UNIX shells. tcsh is the most feature-rich shell of those presented but that doesnt necessarily mean that its the best shell for you to use. In the end, this decision will probably be based on your personal preference as opposed to what features are offered.
The next chapter looks at the programming languages that are provided by each of the shells we have discussed. You may want to learn about other subjects before of moving on to the C shell. To learn about:
Using editors to create and edit files, read Chapter 16, Text Editors: vi and emacs.
Sending output to your printers under Linux, see Chapter 20, Printing.
Previous
Table of Contents
Next
Wyszukiwarka
Podobne podstrony:
257 260257 260257 260260 wichtigere deutsche Abkürzungen DE PL Deutsch als Fremdsprache260 261257 25926 (257)257 313 (2)260(1)254 257I CSK 257 12 1254 257więcej podobnych podstron