Next / Previous / Contents / TCC Help System / NM Tech homepage

2. Your .bashrc file: Shell configuration

In your .bashrc file you place any shell commands that you want executed every time you start up a new shell.

Here are some lines you might want to add to your .bashrc file, with commentary by K. Scott Rowe.

## If we are not a login shell, source /etc/profile anyway
if [ "$0" != "-bash" ] ; then
    . /etc/profile

The above lines cause the /etc/profile file to be read even if the current shell ($0) is not bash. That file sets up your default search path—the set of directories where bash looks to find executable files when you type a command.

## To add a directory to your path, do something like this:
export PATH=${PATH}:${HOME}/bin

There's a lot going on in the above line:

## set up a happy editor for programs that want them
export EDITOR='pico'
export VISUAL='pico'

This sets up two environmental variables, EDITOR and VISUAL, that some programs expect to find, so they know which editor you like. Substitute emacs or vi for pico in the above lines if you prefer one of those editors.

set history=40

Tells bash to remember the last 40 commands you have typed. “History substitution” allows you to recall such previously entered commands and execute them again.

## some useful aliases, so new users don't hurt themselves
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls -F'

The bash alias command sets up new commands as shorthand for longer commands. For example, the first command makes rm an alias for the rm command with the -i option so that the shell will ask the user before removing files.

The ls command's -F option decorates the filenames with special characters to remind what they are: a “/” after directory names, a “*” after executable files, and “@” after soft links.

## this is to fool the automounter
cd ${HOME}

This command does a cd to your home directory so that pwd prints out your /u/username pathname and not the longer “real” (and confusing) path name that may appear due to our physical disk structures.