Skip to content

Instantly share code, notes, and snippets.

@CostasAK
Last active February 15, 2021 18:20
Show Gist options
  • Select an option

  • Save CostasAK/74fa9c4ac48bb0ea9503dcb09f11a95d to your computer and use it in GitHub Desktop.

Select an option

Save CostasAK/74fa9c4ac48bb0ea9503dcb09f11a95d to your computer and use it in GitHub Desktop.
For windows git bash, colourful ps1 with git info + pipenv local install.
git_branch() {
local BRANCH="$(echo `__git_ps1`)"
if [ "$BRANCH" != "" ]; then
BRANCH="\e[1;33m $BRANCH"
fi
echo -e "\e[0m$BRANCH\e[0m"
}
git_stats() {
local STATUS=$(git status -s 2> /dev/null)
local ADDED=$(echo "$STATUS" | grep '??' | wc -l)
local DELETED=$(echo "$STATUS" | grep ' D' | wc -l)
local MODIFIED=$(echo "$STATUS" | grep ' M' | wc -l)
local STATS=''
if [ $ADDED != 0 ]; then
STATS="\e[92m +$ADDED"
fi
if [ $DELETED != 0 ]; then
STATS="$STATS\e[91m -$DELETED"
fi
if [ $MODIFIED != 0 ]; then
STATS="$STATS\e[93m \xce\xb4$MODIFIED"
fi
echo -e "\e[0m$STATS\e[0m"
}
__PS1_BEFORE='\n'
__PS1_USER='\[\e[1;7;32m\] \u@\h '
__PS1_LOCATION='\[\e[1;7;34m\] \w '
__PS1_GIT_BRANCH='`git_branch`'
__PS1_GIT_STATS='`git_stats`'
__PS1_AFTER='\[\e[0m\]\n\\$ '
export PS1="${__PS1_BEFORE}${__PS1_USER}${__PS1_LOCATION}${__PS1_GIT_BRANCH}${__PS1_GIT_STATS}${__PS1_AFTER}"
export PIPENV_VENV_IN_PROJECT=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment