With the bash shell in place, a .bashrc configuration script allows a user to use the more advanced features of the shell. Since I just switched from tcsh to bash, the main issue that I had was learning the syntax for bash, and figuring out how to translate my old ~/.tcshrc file into a ~/.bashrc file. As a result, I have included a copy of my new ~/.bashrc file here (most of it, at least). To create a new one from scratch, change into your home directory and open a text editor such as emacs:
$ cd ~
$ emacs .bashrc &
Copy/Paste
information from the
following into
your emacs
file:
$ emacs .bashrc &
#
.bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Set PATH
export PATH=$PATH:$HOME:/bin:/etc:/sbin:/etc/X11:/usr/bin:/usr/etc:/usr/include:
/usr/libexec:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/local/etc:
/usr/local/include:/usr/local/libexec:/usr/local/sbin:/usr/local/share:
/usr/share/emacs/site-lisp:/usr/local/rsi/idl/bin:/usr/bin/ivtools:
# Export Environment Variables
export HOST=`/bin/hostname`
export HOSTNAME=$HOST
export SHOST=`/bin/hostname -s`
export SHOSTNAME=$SHOST
export TERM=linux
export EDITOR=emacs
export MAIL=/var/spool/mail/$USER
export PRINTER=scroll
export CDROM=/mnt/cdrom
# LaTeX and IDL Configuration
export TEXINPUTS=/usr/share/texmf:~/lib/tex:~/lib/bibtex:
export IDL_STARTUP=~/lib/idl/startup.pro
export IDL_PATH=~/lib/idl:/usr/local/rsi/idl/lib:/usr/local/rsi/idl/lib/macros:
/usr/local/rsi/idl/lib/utilities:
export IDL_DIR=/usr/local/rsi/idl
export LM_LICENSE_FILE=/usr/local/rsi/license/license.dat
export LD_LIBRARY_PATH=/usr/local/lib
# Set Permissions
umask 022
# Set Bash Prompt
export PS1="\[\033[7;39m\]\h:\[\033[0m\] \w> "
# Evaluate Color Information
eval `dircolors -b /etc/DIR_COLORS`
# User specific aliases and functions
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls --color=auto'
alias ll='ls -l --color=auto'
alias l.='ls -d .* --color=auto'
alias la='ls -a --color=auto'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
alias psl='ps aux | less'
alias psm='ps aux | more'
alias psa='ps -a'
alias psgrep='ps aux | grep'
alias dir='ls -l | more'
alias cd..='cd ..'
alias cdl='cd; clear'
alias cls='clear'
alias path='echo $PATH'
alias cleanup='rm -f core *~ *.*~ .*~ *.dlog #*# *.blg'
alias veryclean='cleanup; rm -f *.o *.log *.dlog *.aux *.bbl *.lof'
alias em='emacs -bg navy -fg white -cr white'
alias help='man -k'
alias lpr='lpr -s -h'
alias xdvi='xdvi -s 8 -hush -paper us -bg navy -fg white'
alias xload='xload -bg navy -fg white'
alias ssh='ssh -l[username]'
Note
that the "export
PATH" and the "export
IDL_PATH" options should
span a single line (meaning that you will have to do some
editing), and you will need to replace the "[username]"
option with your own. Some of
the
other information
may not be applicable to you, such as the LaTeX and/or IDL stuff, so
pick and choose
as you like. Keyboard
mapping, which is supported in the ~/.tcshrc
file under tcsh,
is not possible using the ~/.bashrc
file. Instead, we will edit /etc/inputrc
momentarily. When finished editing ~/.bashrc,
hit ^x-s
to save
(press Ctrl-x
followed by Ctrl-s)
and ^x-c
to
exit.# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# Set PATH
export PATH=$PATH:$HOME:/bin:/etc:/sbin:/etc/X11:/usr/bin:/usr/etc:/usr/include:
/usr/libexec:/usr/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/local/etc:
/usr/local/include:/usr/local/libexec:/usr/local/sbin:/usr/local/share:
/usr/share/emacs/site-lisp:/usr/local/rsi/idl/bin:/usr/bin/ivtools:
# Export Environment Variables
export HOST=`/bin/hostname`
export HOSTNAME=$HOST
export SHOST=`/bin/hostname -s`
export SHOSTNAME=$SHOST
export TERM=linux
export EDITOR=emacs
export MAIL=/var/spool/mail/$USER
export PRINTER=scroll
export CDROM=/mnt/cdrom
# LaTeX and IDL Configuration
export TEXINPUTS=/usr/share/texmf:~/lib/tex:~/lib/bibtex:
export IDL_STARTUP=~/lib/idl/startup.pro
export IDL_PATH=~/lib/idl:/usr/local/rsi/idl/lib:/usr/local/rsi/idl/lib/macros:
/usr/local/rsi/idl/lib/utilities:
export IDL_DIR=/usr/local/rsi/idl
export LM_LICENSE_FILE=/usr/local/rsi/license/license.dat
export LD_LIBRARY_PATH=/usr/local/lib
# Set Permissions
umask 022
# Set Bash Prompt
export PS1="\[\033[7;39m\]\h:\[\033[0m\] \w> "
# Evaluate Color Information
eval `dircolors -b /etc/DIR_COLORS`
# User specific aliases and functions
alias cp='cp -i'
alias mv='mv -i'
alias ls='ls --color=auto'
alias ll='ls -l --color=auto'
alias l.='ls -d .* --color=auto'
alias la='ls -a --color=auto'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
alias psl='ps aux | less'
alias psm='ps aux | more'
alias psa='ps -a'
alias psgrep='ps aux | grep'
alias dir='ls -l | more'
alias cd..='cd ..'
alias cdl='cd; clear'
alias cls='clear'
alias path='echo $PATH'
alias cleanup='rm -f core *~ *.*~ .*~ *.dlog #*# *.blg'
alias veryclean='cleanup; rm -f *.o *.log *.dlog *.aux *.bbl *.lof'
alias em='emacs -bg navy -fg white -cr white'
alias help='man -k'
alias lpr='lpr -s -h'
alias xdvi='xdvi -s 8 -hush -paper us -bg navy -fg white'
alias xload='xload -bg navy -fg white'
alias ssh='ssh -l[username]'
Once the changes are made to your ~/.bashrc file, you must source it, which will read and execute all of the commands just created into your bash shell environment. Type:
$
source
~/.bashrc
Notice
that your prompt just changed due
to the "set prompt"
command. From now on, whenever you launch a new terminal,
your ~/.bashrc
file will
automatically be source'd. For
more information on configuring bash
to your
liking, see www.gnu.org/software/bash/manual/bash.html
and www.ibm.com/developerworks/library/l-bash.html.Edit the /etc/inputrc file
To perform keyboard mapping, edit the /etc/inputrc file using sudo:
~> sudo nano /etc/inputrc
Scroll
down to the bottom of the file, and add the following: #
User Defined Settings
set bell-style audible
set show-all-if-ambiguous on
"\e[2~": overwrite-mode
If
you do not like the audible bell, leave out the first line.
The "set
show-all-if-ambiguous on" line enables you to cycle
through possible auto completions by hitting the Tab key once,
rather than requiring pressing it twice. The last line fixes
the Insert
key. Hit ^x-s
to save, and ^x-c
to exit. Close out the terminal window, and launch a new one. Your new
key bindings have now been put into effect.
set bell-style audible
set show-all-if-ambiguous on
"\e[2~": overwrite-mode


