This is a long and twisted tale about the bits in setting up bash to my liking.
I use bash as my primary shell for managing multiple accounts as an ad-hoc system administrator and for my computational research projects which involve some really big computers.
Below is included my complete .bashrc wherein each of the customizations is implemented.
First let me describe the environment that all of these things are tuned for. I currently use Ubuntu at the office and I use Debian at home. From here I use either the console or an xfce4-term for all of my day to day command line shenanigans.
Once on the command line, the tools that are in my face everyday are GNU Screen, the Bash prompt, and SSH. These utilities are absolutely essential to getting anything accomplished for me. Since this page is about bash I will describe how I have customized everything so that I experience a minimum of interference with getting things accomplished.
…In Progress…
# ~/.bashrc: executed by bash(1) for non-login shells. # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples # If not running interactively, don't do anything [ -z "$PS1" ] && return # Hack to get around kshell limitations if [ -n "$KHOST" ]; then kinit fmrose && ktelnet -l fmrose $KHOST -e "" exit 0 fi #add keys to ssh-agent if [ -n "$SSH_AUTH_SOCK" ]; then if ssh-add -l |grep -q "The agent has no ident"; then ssh-add fi fi umask 022 # Source global definitions [ -f /etc/profile ] && source /etc/profile [ -f /etc/bashrc ] && source /etc/bashrc [ -f /etc/bash.bashrc ] && source /etc/bash.bashrc # Source my functions if [ -d ~/.bash_functions ]; then for file in .bash_functions/*; do [ -f $file ] && source $file done fi # enable programmable completion features (you don't need to enable # this, if it's already enabled in /etc/bash.bashrc and /etc/profile # sources /etc/bash.bashrc). [ -f /etc/bash_completion ] && source /etc/bash_completion # don't put duplicate lines in the history. See bash(1) for more options export HISTCONTROL=ignoredups # ... and ignore same sucessive entries. export HISTCONTROL=ignoreboth # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize shopt -s cdspell shopt -s dotglob shopt -s histappend #convenient abbreviations export __B='froze@butsuri.homelinux.net' export __M='froze@miles.chips.ncsu.edu' export __O='froze@olympus.chips.ncsu.edu' export __T='froze@titan.chips.ncsu.edu' export __U='fmrose@unity.ncsu.edu' export __C='froze@chips.ncsu.edu' export __Q='froze@qianshoufo.chips.ncsu.edu' export __OH='rosef@home.ccs.ornl.gov' export __XTERM_OPT='-bg Black -fg Grey90 -geometry 210x70' export PYTHONSTARTUP="${HOME}/.pythonrc.py" export EDITOR='vim' #Host specific setup case ${HOSTNAME} in miles) MyPrompt=\$__M; export FHIPP_PATH="${HOME}/src" ;; jaguar*) MyPrompt=setme\${USER}@\${HOSTNAME} if [ ${HOSTNAME} = "jaguar9" ]; then cd module load vim/7.0 subversion fftw/2.1.5 >& /dev/null q () { echo "*************************************** SHOWUSAGE ***************************************" showusage echo "*************************************** SHOWSTART ***************************************" STAT=`qstat | grep $USER` && echo "$STAT" for JOB in `echo "$STAT" | cut -d" " -f1`; do showstart $JOB done echo "***************************************** SHOWQ *****************************************" showq -u $USER echo "***************************************** SHOWBF ****************************************" showbf } else ssh jaguar9 && exit fi ;; olympus) MyPrompt=\$__O; alias units="/usr/bin/units -o %.8e --verbose" rrm () { wipe -frcs $@ & } [ -x ~/bin/ivars.sh ] && source ~/bin/ivars.sh ;; butsuri) MyPrompt=\$__B; alias units="/usr/bin/units -o %.8e --verbose" rrm () { wipe -frcs $@ & } [ -x ~/bin/ivars.sh ] && source ~/bin/ivars.sh ;; unity) MyPrompt=setme\${USER}@\${HOSTNAME} alias d=exit ;; *) MyPrompt=setme\${USER}@\${HOSTNAME} esac # Keep $DISPLAY up to date export SCR_DISP=${HOME}/.screen_display if [ -z $DISPLAY ]; then rm -f ${SCR_DISP} touch ${SCR_DISP} elif [ -z $STY ]; then rm -f ${SCR_DISP} printf 'export DISPLAY=%s\n' $DISPLAY > ${SCR_DISP} printf 'export SESSION_MANAGER=%s\n' $SESSION_MANAGER >> ${SCR_DISP} printf 'export GNOME_KEYRING_SOCKET=%s\n' $GNOME_KEYRING_SOCKET >> ${SCR_DISP} fi #My pager preference if [ -x /usr/bin/lesspipe ]; then eval "$(/usr/bin/lesspipe)" elif [ ! -x /usr/bin/less ] ; then alias less more fi # set variable identifying the chroot you work in (used in the prompt below) if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then debian_chroot=$(cat /etc/debian_chroot) fi # If this is an xterm set the title to user@host:dir case $TERM in xterm*) if [ -n "$STY" ]; then #PROMPT_COMMAND='history -a; source ${SCR_DISP}; echo -ne "\033k\033\ \010\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' PROMPT_COMMAND='source ${SCR_DISP}; echo -ne "\033k\033\ \010\033]0;${MyPrompt}: ${PWD}\007"' else #PROMPT_COMMAND='history -a; source ${SCR_DISP}; echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"' PROMPT_COMMAND='source ${SCR_DISP}; echo -ne "\033]0;${MyPrompt}: ${PWD/$HOME/~}\007"' fi PS1='\[\033[01;32m\]${MyPrompt}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' case $HOSTNAME in olympus|butsuri) eval `dircolors -b` LS_OPT='--color=auto' ;; *) LS_OPT='' ;; esac ;; linux*) PS1='\[\033[01;32m\]${MyPrompt}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' eval `dircolors -b` LS_OPT='--color=auto' ;; "") export TERM=dumb export PS1='\u@\h:\W\$ ' LS_OPT='' ;; #if TERM not set then it must be a "dumb" terminal. *) ;; esac #Some ls aliases LS=`which ls` alias ll="$LS $LS_OPT -l" alias lh="$LS $LS_OPT -lh" alias la="$LS $LS_OPT -al" alias l="clear && $LS $LS_OPT -CF" alias ls="$LS $LS_OPT" unset LS unset LS_OPT #Some other aliass alias cgrep="grep --color=auto" alias ngrep="grep -n " alias s="source ~/.bashrc; xrdb -merge ~/.Xresources 2>&1 /dev/null;" alias scp="/usr/bin/scp -pr -c blowfish " # Some environment variables that I find usefull. [ -d ~/local/bin ] && export PATH=~/local/bin:${PATH} [ -d ~/bin ] && export PATH=~/bin:${PATH} export PATH=$PATH:./ if [ -f /usr/bin/x-terminal-emulator ]; then export TERMINAL=/usr/bin/x-terminal-emulator else export TERMINAL=xterm fi # Shortcut for attaching or creating a screen session a () { if [ -z "$1" ]; then SessionName=main else SessionName=$1 fi case ${HOSTNAME} in butsuri|olympus ) if [ -n "$STY" ]; then $TERMINAL -e screen -UA -S $SessionName -xRR -e ^\`\` & else screen -UA -S $SessionName -xRR -e ^\`\` fi ;; *) if [ -n "$STY" ]; then $TERMINAL -e screen -UA -S $SessionName -xRR -e ^\`\` & else screen -UA -S $SessionName -xRR -e ^~~ fi ;; esac } # do not actually delete files, just mv them to a .cruft directory. #This needs to be made smarter rm () { chk_flags=`echo $1 | cut -b 1` chk_dir=`basename $PWD` if [ $chk_flags = "-" -o $chk_dir = ".cruft" ]; then /bin/rm $@ else mkdir -p ./.cruft Tstmp=`date +"%Y_%b_%d_%H_%M_%S"` for file in $@; do mv -f $file ./.cruft/${file}__${Tstmp}__ done fi }