Environment Variables (03-08)
Environment Variables (03-08)
variables
This makes bash follow the Snark rule ("What I tell you three
times is true") and only log you out if you hit ^D three times
in a row. If that's too few for you, feel free to set it to 101 and
bash will obligingly keep count for you.
Having a directory just off of your home that lies in your path
can be extremely useful (for keeping scripts, symlinks, and
other random pieces of code.) A traditional place to keep this
directory is in bin underneath your home directory. If you use
the ~ expansion facility in bash, like this:
export PATH=$PATH:~/bin
then the path will always be set properly, even if your home
directory ever gets moved (or if you decide you want to use
this same line on multiple machines with potentially different
home directories — as in movein.sh). See [Hack #72].
Did you know that just as commands are searched for in the
PATH variable (and manpages are searched for in the
MANPATH variable), directories are likewise searched for in
the CDPATH variable every time you issue a cd? By default,
it is only set to ".", but can be set to anything you like:
export CDPATH=.:~
This will make cd search not only the current directory, but
also your home directory for the directory you try to change
to. For example:
rob@caligula:~$ ls
bin/ devel/ incoming/ mail/ test/ stuff.txt
rob@caligula:~$ cd /usr/local/bin
rob@caligula:/usr/local/bin$ cd mail
bash: cd: mail: No such file or directory
rob@caligula:/usr/local/bin$ export CDPATH=.:~
rob@caligula:/usr/local/bin$ cd mail
/home/rob/mail
rob@caligula:~/mail$
To clear out your history quickly, try this from the command
line:
export HISTSIZE=0
This completely clears out the current bash history and will
write an empty .bash_history on logout. When you log back
in, your history will start over from scratch but will otherwise
work just as before. From now on, try to be more careful!
For the full definition of what constitutes a login shell (and for
a whole bunch of information about the environment you
work in every day), consult bash(1).