Skip to content

Instantly share code, notes, and snippets.

@spencerhakim
Created December 17, 2015 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spencerhakim/489964462d64e0476790 to your computer and use it in GitHub Desktop.
Save spencerhakim/489964462d64e0476790 to your computer and use it in GitHub Desktop.
function __better_git_ps1 {
local GIT_PS1=`__git_ps1 "%s"`
set -f
local GIT_PS1_ARR=($GIT_PS1)
set +f
if [ "$GIT_PS1" ]; then
if [ ${#GIT_PS1_ARR[0]} -ge 20 ]; then
GIT_PS1=`printf "%.20s... %s" \
"${GIT_PS1_ARR[0]}" \
"${GIT_PS1_ARR[1]}"`
fi
printf "{%s} " "$GIT_PS1"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment