Last active
January 21, 2016 22:57
-
-
Save eternalruler/d5067f2e17a33c31e31e to your computer and use it in GitHub Desktop.
Custom Prompt String One for Git Repo Information
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 git_num_untracked_files { | |
expr `git status --porcelain 2>/dev/null| grep "^??" | wc -l` | |
} | |
function git_num_staged_new_files { | |
expr `git status --porcelain 2>/dev/null| grep "^A" | wc -l` | |
} | |
function git_num_staged_modified_files { | |
expr `git status --porcelain 2>/dev/null| grep "^M" | wc -l` | |
} | |
function git_num_unstaged_files { | |
expr `git status --porcelain 2>/dev/null| grep "^ M" | wc -l` | |
} | |
function parse_git_dirty { | |
dirty=`[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit, working directory clean" ]] && echo "*"` | |
# echo -en $dirty | |
if [ -z "$dirty" ]; then | |
echo "" | |
else | |
echo -en " "\ | |
"\e[1;37m"$(git_num_untracked_files)"\e[0m"\ | |
":"\ | |
"\e[1;31m"$(git_num_unstaged_files)"\e[0m"\ | |
":"\ | |
"\e[1;32m"$(git_num_staged_modified_files)"\e[0m"\ | |
":"\ | |
"\e[1;36m"$(git_num_staged_new_files)"\e[0m"\ | |
" " | |
fi | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ [\1]$(parse_git_dirty)/" | |
} | |
export PS1='\[\e[1;31m\]\u@\h\[\e[0m\] \[\e[1;33m\]\w\[\e[0m\]\[$(parse_git_branch)\]$ ' | |
# List Branch Owners by Date | |
alias gitwho="git remote prune origin && echo -e 'Committed Date\t\t\t Last Committer\t\t Branch\n------------------------------------------------------------------------------' && git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n | grep -v 'tags' | grep -v 'stash' | grep -v 'heads'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment