|
Runs once, when you log in.
Like
AUTOEXEC.BAT
on DOS.
Can call a shell script in here.
# add $HOME/bin export PATH=$PATH:$HOME/bin # add . export PATH=$PATH:. # add both export PATH=$PATH:$HOME/bin:.
Type "which ls" to see the location of the system ls program.
If you write your own "ls" script,
and insert it in a directory
in the path which comes before that system directory,
then
you have over-ridden the system ls.
All calls to "ls" at the command-line will be calls to your program, not system ls.
This may be ok for you,
but other programs that call ls
will now be calling your version instead.
They may fail in unexpected ways.
Recommended:
Also, if you are in someone else's directory, and read is off and "." is in the PATH, you will find strange effects.
Beware recursion: Do not call a shell script in here.
In .bashrc:
In .cshrc:alias name="string" alias h='history' alias cdshare="cd $HOME/share"
alias name string
For instance (on C shell):
If you regularly need to login to some other server, put the following in .cshrc:alias t 'ssh -l userid remoteserver'and then, to connect to it, just type:tOr if you regularly need to jump to your web directory, put the following in .cshrc:alias cdp 'cd $HOME/public_html'and then, any time you want to jump to that directory, just type:cdp
This straight text substitution at the command-line
is more efficient than starting up a Shell script that needs
parameters set up for it (environment variables,
command-line arguments) and then needs to be interpreted.
It is like the difference between a macro text substitution
(e.g. a #define
in C/C++)
and a run-time procedure call.
In fact, in the case of "cdp" above, a Shell program won't work since a Shell program can't change the directory of the parent process that called it.
See:# PS1='[\H] [\u] [\w] > ' PS1='\W> '
On Internet since 1987.