Created
January 16, 2011 08:28
-
-
Save jcn/781651 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /' | |
} | |
function breadcrumb() | |
{ | |
echo $1 | sed "s|^$HOME|~|" | awk -v n=$2 '{ | |
# Split the path into components | |
count = split($0, components, "/") | |
# If there are less than n components, just print the whole path | |
if (count <= n) { | |
print $0 | |
} else { | |
# print the last n components | |
for (i = count - n + 1; i < count; i++) { | |
printf "%s/", components[i] | |
} | |
printf "%s", components[count] | |
} | |
}' | |
} | |
PS1='[\h:$(breadcrumb "$PWD" 3)] $(parse_git_branch)\u\$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment