blob: ad9a5c20d519f7f3cce47fdb1e7d4d0f0547c84f (
plain) (
tree)
|
|
# Don't do anything if not running interactively.
[ -z "$PS1" ] && return
# Use vi as my text editor.
export EDITOR=vi
# 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
# Use completion, if available.
[[ -e /etc/bash_completion ]] && . /etc/bash_completion
# SSH agent setup, if available.
[[ -e ~/.ssh/agent ]] && . ~/.ssh/agent
# Turn off annoying and useless flow control keys.
stty -ixon
# Never beep at me.
setterm -bfreq 0
# Sensible prompts, we'll work out colors shortly.
PS1='\u@\h:\w\$'
PS2='...'
# Start stacking up options for ls and grep.
LS_OPTS=
GREP_OPTS=
# If we're using an xterm, force 256 colors.
case "$TERM" in
xterm*)
TERM=xterm-256color
;;
esac
# If we have a color terminal, do colory things.
case "$TERM" in
*color)
# Change prompt color depending on whether I'm root or not.
if [[ $EUID -eq 0 ]]; then
PS1='\[\e[1;31m\]'${PS1}'\[\e[0m\]'
else
PS1='\[\e[1;32m\]'${PS1}'\[\e[0m\]'
fi
# Get colouring for ls and grep if available.
hash dircolors &>/dev/null && eval "$(dircolors -b)"
if ls --help | grep -- --color &>/dev/null; then
LS_OPTS="${LS_OPTS} --color=auto"
fi
if grep --help | grep -- --color &>/dev/null; then
GREP_OPTS="${GREP_OPTS} --color=auto"
fi
;;
esac
# Set up more options for grep; exclude version control files.
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
# Alias ls and grep with the options we've collected.
alias ls="ls ${LS_OPTS}"
alias grep="grep ${GREP_OPTS}"
# Protect innocent MySQL databases from my stupidity.
alias mysql='mysql --safe-updates'
# I always do this, and I hate slow train.
alias sl='ls'
# Set window titles in various terminals.
case "$TERM" in
screen*)
PS1='\[\ek\h\e\\\]'${PS1}
;;
xterm*)
PS1='\[\e]0;\h\a\]'${PS1}
;;
esac
# Add space suffix to the prompt now that we're done hacking it up.
PS1="${PS1} "
|