aboutsummaryrefslogblamecommitdiff
path: root/bash/bashrc
blob: 5e7d37d0a5d0d45b42ff750e684e3f3efb7326bb (plain) (tree)
1
2
3
4
5
6
7
8
9


                                                 




                                                      
                      
 
                                            
                        
 

                                                     

                                       
                            

                                                 
                                 
 
                                                   
                            
 
                                             
                             
 
                                       
                            

                                   
                            
 
                               
                             
 
                                            
                               
 
                
                 
         
 




                                                        
  







                                                                    
  








                                                        
 
                                                     
                                  
 
                               
                                    
                          



                                                                      


                                

                            




                                                  


                   
                                         
                                       
 


                             

                                      
                                 

                           


                              
                                                                          
          

    
# Don't do anything if not running interactively.
[ -z "$PS1" ] && return

# Keep plenty of history.
unset HISTFILESIZE
HISTSIZE=1000000

# Ignore duplicate commands and whitespace in history.
HISTCONTROL=ignoreboth

# Keep the times of the commands in history.
HISTTIMEFORMAT='%F %T  '

# Don't check for mail all the time, it's irritating.
unset MAILCHECK

# Autocorrect fudged paths in cd calls.
shopt -s cdspell &>/dev/null

# Update columns and rows if window size changes.
shopt -s checkwinsize &>/dev/null

# Put multi-line commands onto one line of history.
shopt -s cmdhist &>/dev/null

# Autocorrect fudged paths during completion.
shopt -s dirspell &>/dev/null

# Include dotfiles in pattern matching.
shopt -s dotglob &>/dev/null

# Enable advanced pattern matching.
shopt -s extglob &>/dev/null

# Enable double-starring paths.
shopt -s globstar &>/dev/null

# Append rather than overwrite Bash history.
shopt -s histappend &>/dev/null

# Simple prompt.
PS1='\u@\h:\w\$ '
PS2='...'

# Set up options for ls; use color.
LS_OPTS=
if ls --help | grep -- --color &>/dev/null; then
    hash dircolors &>/dev/null && eval "$(dircolors -b)"
    LS_OPTS="$LS_OPTS --color"
fi
alias ls="ls $LS_OPTS"

# Set up options for grep; exclude version control files, use color.
GREP_OPTS=
if grep --help | grep -- --exclude &>/dev/null; then
    for PATTERN in .git .gitignore .gitmodules; do
        GREP_OPTS="$GREP_OPTS --exclude=$PATTERN"
    done
fi
if grep --help | grep -- --exclude-dir &>/dev/null; then
    for PATTERN in .cvs .git .hg .svn; do
        GREP_OPTS="$GREP_OPTS --exclude-dir=$PATTERN"
    done
fi
if grep --help | grep -- --color &>/dev/null; then
    GREP_OPTS="$GREP_OPTS --color"
fi
alias grep="grep $GREP_OPTS"

# Protect innocent MySQL databases from my stupidity.
alias mysql="mysql --safe-updates"

# Use completion, if available.
if [ -e /etc/bash_completion ]; then
    . /etc/bash_completion

    # Use shots for hostname completion, if available.
    hash shots &>/dev/null && complete -F _known_hosts -W "$(shots)" \
        dig fping ftp host mtr nc netcat ping ping6 telnet traceroute
fi

# SSH agent setup, if available.
if [ -e ~/.ssh/agent ]; then
    . ~/.ssh/agent
fi

# Turn off annoying and useless flow control keys.
stty -ixon

# Never beep at me.
setterm -bfreq 0

# Use vi as my text editor, if available.
hash vi &>/dev/null && export EDITOR=vi

# Terminal-specific settings.
case "$TERM" in

    # Set xterm title, use 256 colors.
    xterm*)
        PS1="\[\e]0;\h\a\]"${PS1}
        TERM=xterm-256color
        ;;

    # Set screen window title.
    screen*)
        PROMPT_COMMAND="printf '\033k$(hostname)\033\\';"${PROMPT_COMMAND}
        ;;
esac