99 lines
2.9 KiB
Bash
99 lines
2.9 KiB
Bash
# 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\]"
|
|
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} =~ "nothing to commit" ]]; then
|
|
state=" ${RED}!"
|
|
else
|
|
state=""
|
|
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}$RED) "
|
|
fi
|
|
}
|
|
|
|
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
|
|
|
|
alias grep='grep --color'
|
|
alias fgrep='fgrep --color'
|
|
alias egrep='egrep --color'
|
|
|
|
alias vim='~/local/bin/vim'
|
|
|
|
function ll(){ ls -lhF --color=auto "$@"| egrep "^d" ; ls -lXB "$@" 2>&-| \
|
|
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
|
|
alias tree='tree -Csu' # nice alternative to 'recursive ls'
|
|
|
|
alias mkdir='mkdir -p'
|
|
# aliases
|
|
alias cd..="cd .."
|
|
alias lp="ls -p --color=auto"
|
|
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
|
|
|
|
if [ -f /opt/local/etc/bash_completion.d/git ]; then
|
|
source /opt/local/etc/bash_completion.d/git
|
|
export GIT_PS1_SHOWDIRTYSTATE=1
|
|
export GIT_PS1_SHOWUPSTREAM=auto
|
|
fi
|
|
|
|
# configure my multi-line prompt
|
|
prompt_func() {
|
|
PS1="\n$BLACK[ \u@$RED\h $GREEN\w$RED$(parse_git_branch)$BLACK]\n> "
|
|
}
|
|
PROMPT_COMMAND=prompt_func
|