Created
January 30, 2018 15:10
-
-
Save scepion1d/57465c3cb223ac26639dc41862b092e0 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
| get_current_git_branch() { | |
| local branch=`git rev-parse --abbrev-ref HEAD 2> /dev/null` | |
| if [ "$branch" != "" ]; then | |
| echo " ⌥ $branch " | |
| fi | |
| } | |
| get_git_stat() { | |
| local branch=`git rev-parse --abbrev-ref HEAD 2> /dev/null` | |
| local changes=`git diff --shortstat 2> /dev/null` | |
| read changed insertion deletion <<<${changes//[^0-9]/ } | |
| if [ "$changed" = "" ]; then changed=0; fi | |
| if [ "$insertion" = "" ]; then insertion=0; fi | |
| if [ "$deletion" = "" ]; then deletion=0; fi | |
| read not_pushed<<<`git rev-list --count origin/$branch..$branch 2> /dev/null` | |
| if [ "$not_pushed" = "" ]; then not_pushed=0; fi | |
| read untracked<<<`git status --porcelain 2>/dev/null| grep "^??" | wc -l` | |
| if [ "$untracked" = "" ]; then untracked=0; fi | |
| local stats=" ⇡$not_pushed ∼$changed +$insertion -$deletion ∓$untracked" | |
| if [ "$branch" != "" ]; then | |
| echo " $stats " | |
| fi | |
| } | |
| # Get last folders | |
| short_pwd() { | |
| local pwd="${PWD/$HOME//~}" | |
| local current=$(basename "$pwd") | |
| local parrent=$(basename "$(dirname "$pwd")") | |
| if [[ "~" = "$current" && '/' = "$parrent" ]]; then | |
| echo "~" | |
| elif [ "/" = "$current" ]; then | |
| echo "/" | |
| elif [ "/" = "$parrent" ]; then | |
| echo "/$current" | |
| else | |
| echo "$parrent/$current" | |
| fi | |
| } | |
| export CLICOLOR=1 | |
| export LSCOLORS=ExFxCxDxBxegedabagacad | |
| export PS1="\[\e[0;107m\] \u \[\e[m\]\[\e[0;104m\] \$(short_pwd) \[\e[m\]\[\e[0;43m\]\$(get_current_git_branch)\[\e[m\]\[\e[0;102m\]\$(get_git_stat)\[\e[m\] $ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment