Created
April 27, 2015 14:45
-
-
Save joshdcomp/42645a8390cc22cdec04 to your computer and use it in GitHub Desktop.
Git completion and vim syntax sugar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -f ~/.bashrc ]; then | |
source ~/.bashrc | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## More Customization here: http://bashrcgenerator.com/ | |
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\]"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment