Skip to content

Instantly share code, notes, and snippets.

@scepion1d
Last active July 28, 2017 08:29
Show Gist options
  • Save scepion1d/5e56f9925704371f28890dd88b1d43dd to your computer and use it in GitHub Desktop.
Save scepion1d/5e56f9925704371f28890dd88b1d43dd to your computer and use it in GitHub Desktop.
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\] $ "
@scepion1d
Copy link
Author

screenshot-2017-07-28 1 pm 28 38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment