dotfiles/bash-files/bashrc

95 lines
2.9 KiB
Bash
Raw Normal View History

2012-08-15 00:33:15 -04:00
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# append to the history file, don't overwrite it
shopt -s histappend
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
BLACK="\[\033[0;38m\]"
RED="\[\033[0;31m\]"
RED_BOLD="\[\033[01;31m\]"
BLUE="\[\033[01;34m\]"
GREEN="\[\033[0;32m\]"
2014-03-19 10:23:04 -07:00
YELLOW="\[\033[0;33m\]"
parse_git_branch() {
git rev-parse --git-dir &> /dev/null
git_status="$(git status 2> /dev/null)"
branch_pattern="^# On branch ([^${IFS}]*)"
remote_pattern="# Your branch is (.*) of"
diverge_pattern="# Your branch and (.*) have diverged"
if [[ ! ${git_status} =~ "working directory clean" ]]; then
state="${RED}!"
fi
# add an else if or two here if you want to get more specific
if [[ ${git_status} =~ ${remote_pattern} ]]; then
if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then
remote="${YELLOW}"
else
remote="${YELLOW}"
fi
fi
if [[ ${git_status} =~ ${diverge_pattern} ]]; then
remote="${YELLOW}"
fi
if [[ ${git_status} =~ ${branch_pattern} ]]; then
branch=${BASH_REMATCH[1]}
echo " $RED(${branch})${remote}${state} "
fi
}
2012-08-15 00:33:15 -04:00
export CLICOLOR=1
export EDITOR=/usr/bin/mvim
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
fi
2012-08-15 01:10:45 -04:00
alias grep='grep --color'
alias fgrep='fgrep --color'
alias egrep='egrep --color'
2012-08-15 00:33:15 -04:00
alias vim='~/local/bin/vim'
2012-08-15 00:33:15 -04:00
function ll(){ ls -lhF --color=auto "$@"| egrep "^d" ; ls -lXB "$@" 2>&-| \
2012-08-15 00:33:15 -04:00
egrep -v "^d|total "; }
alias ls="ls -hF --color=auto"
alias la='ls -Al --color=auto' # show hidden files
alias lx='ls -lXB --color=auto' # sort by extension
alias lk='ls -lSr --color=auto' # sort by size, biggest last
alias lc='ls -ltcr --color=auto' # sort by and show change time, most recent last
alias lu='ls -ltur --color=auto' # sort by and show access time, most recent last
alias lt='ls -ltr --color=auto' # sort by date, most recent last
alias lm='ls -al --color=auto | more' # pipe through 'more'
alias lr='ls -lR --color=auto' # recursive ls
2012-08-15 00:33:15 -04:00
alias tree='tree -Csu' # nice alternative to 'recursive ls'
alias mkdir='mkdir -p'
# aliases
alias cd..="cd .."
alias lp="ls -p --color=auto"
2012-08-15 00:33:15 -04:00
alias h=history
# the "kp" alias ("que pasa"), in honor of tony p.
alias kp="ps auxwww"
# general path munging
PATH=${PATH}:~/bin
PATH=${PATH}:/usr/local/bin
2012-08-15 01:10:45 -04:00
if [ -f /opt/local/etc/bash_completion.d/git ]; then
source /opt/local/etc/bash_completion.d/git
2012-08-15 00:33:15 -04:00
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWUPSTREAM=auto
fi
# configure my multi-line prompt
2014-03-19 10:23:04 -07:00
export PS1="\n$BLACK[ \u@$RED\h $GREEN\w$RED$(parse_git_branch)$BLACK]\n> "