Created
December 9, 2015 20:24
-
-
Save jvz/adaedda9727f87205ef2 to your computer and use it in GitHub Desktop.
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 ~/.git-prompt.sh ]]; then | |
curl -o ~/.git-prompt.sh https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh | |
fi | |
. ~/.git-prompt.sh | |
function get_version_ctl_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" | |
[[ -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 | |
} | |
PS1_UN="\[\033[38;5;33m\]\u@\h\[\033[00m\]" | |
PS1_DIR="\[\033[38;5;26m\]\w\[\033[00m\]" | |
PS1_GIT_CUR="\[\033[0;35;49m\]\$(get_version_ctl_branch "$2")\[\033[00m\]" | |
PS1_LAMBDA="\[\033[38;5;173m\]λ\[\033[0;00m\]" | |
PS1="${PS1_UN}:${PS1_DIR} ${PS1_GIT_CUR}\n${PS1_LAMBDA} \[$(tput sgr0)\]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment