Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Show uncommitted files
- function parse_git_dirty {
- [[ $(/usr/bin/git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"
- }
- # Returns "|s:N" where N is the number of stashed states (if any).
- function parse_git_stash {
- local stash=`expr $(/usr/bin/git stash list 2>/dev/null| wc -l)`
- if [ "$stash" != "0" ]
- then
- echo "|s:$stash"
- fi
- }
- # Get the current git branch name (if available)
- git_prompt() {
- local ref=$(/usr/bin/git symbolic-ref HEAD 2>/dev/null | cut -d'/' -f3)
- if [ "$ref" != "" ]
- then
- echo "($ref$(parse_git_dirty)$(parse_git_stash)) "
- fi
- }
- # Show host, cwd and git status
- PS1="$PS1PREFIX\h:\w\$(git_prompt)$ "
Advertisement
Add Comment
Please, Sign In to add comment