Skip to content

Instantly share code, notes, and snippets.

@joshdcomp
Created January 7, 2016 20:33
Show Gist options
  • Save joshdcomp/bb7b9fdfbaf4c471c345 to your computer and use it in GitHub Desktop.
Save joshdcomp/bb7b9fdfbaf4c471c345 to your computer and use it in GitHub Desktop.
alias ll='ls -la'
alias rm='rm -i'
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias sites='cd ~/Projects/sites'
if [ -f `brew --prefix`/etc/bash_completion ]; then
. `brew --prefix`/etc/bash_completion
fi
## Modd'd ps1 bash path
export PS1="\[\e[00;36m\]\H\[\e[0m\]\[\e[00;33m\]:\[\e[0m\]\[\e[00;32m\]\u\[\e[0m\]\[\e[00;33m\]:\[\e[0m\]\[\e[00;35m\]\w\[\e[0m\]\[\e[00;33m\]\\$\[\e[0m\]";
## Print nickname for git/hg/bzr/svn version control in CWD
## Optional $1 of format string for printf, default "(%s) "
function be_get_branch {
local dir="$PWD"
local vcs
local nick
while [[ "$dir" != "/" ]]; do
for vcs in git hg svn bzr; do
if [[ -d "$dir/.$vcs" ]] && hash "$vcs" &>/dev/null; then
case "$vcs" in
git) __git_ps1 "${1:-(%s) }"; return;;
hg) nick=$(hg branch 2>/dev/null);;
svn) nick=$(svn info 2>/dev/null\
| grep -e '^Repository Root:'\
| sed -e 's#.*/##');;
bzr)
local conf="${dir}/.bzr/branch/branch.conf" # normal branch
[[ -f "$conf" ]] && nick=$(grep -E '^nickname =' "$conf" | cut -d' ' -f 3)
conf="${dir}/.bzr/branch/location" # colo/lightweight branch
[[ -z "$nick" ]] && [[ -f "$conf" ]] && nick="$(basename "$(< $conf)")"
[[ -z "$nick" ]] && nick="$(basename "$(readlink -f "$dir")")";;
esac
[[ -n "$nick" ]] && printf "${1:-(%s) }" "$nick"
return 0
fi
done
dir="$(dirname "$dir")"
done
## dir=":D"
}
## Add branch to PS1 (based on $PS1 or $1), formatted as $2
export GIT_PS1_SHOWDIRTYSTATE=yes
##export PS1="${PS1}\[\e[00;31m\]\$(be_get_branch"$2")\[\e[00;33m\]\$\[\e[0m\]";
export PS1="\[\e[00;36m\]\H\[\e[0m\]\[\e[00;33m\]:\[\e[0m\]\[\e[00;32m\]\u\[\e[0m\]\[\e[00;33m\]:\[\e[0m\]\[\e[00;35m\]\w\[\e[31m\]\$(be_get_branch"$2")\[\e[00;33m\]\\$\[\e[0m\]";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment