Last active
February 22, 2021 23:28
-
-
Save rkitover/3efb2312fa97987705cd466ebb78432d to your computer and use it in GitHub Desktop.
simple version of bash git prompt for ksh (also works in bash) (raw escape, click raw and fetch the gist URL with curl or wget)
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
shopt -s checkwinsize 2>/dev/null | |
_cmd_status() { | |
if [ $? -eq 0 ]; then | |
printf '\001[0;32m\002✔' | |
else | |
printf '\001[0;31m\002✘' | |
fi | |
} | |
_git_branch() { | |
_br="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)" | |
if [ -n "$_br" ]; then | |
printf '\001[0;36m\002[\001[35m\002'"${_br}"'\001[36m\002]\001[0m\002' | |
fi | |
} | |
PS1='`_cmd_status` \001[33m\002\w `_git_branch`\n\001[0;34m\002'"${USER}"'\001[0;37m\002@\001[1;34m\002\h \001[1;31m\002➤\001[0m\002 ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With older version of this script I sometimes got
-bash: [: 1: unary operator expected
after variousgit
commands:Perhaps there's namespace clash with bash completion project: