Last active
January 4, 2022 00:48
-
-
Save marclipovsky/4660499 to your computer and use it in GitHub Desktop.
git-bash-prompt
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's the current git branch | |
function parse_git_branch | |
{ | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo -e "▸"${ref#refs/heads/} | |
} | |
# Checks to see if there are uncommitted files | |
function git_status | |
{ | |
string=$(git status 2> /dev/null) || return | |
if [[ "$string" == *"Changes not staged for commit"* || "$string" == *"untracked files present"* ]] | |
then | |
echo -e "✶" | |
fi | |
} | |
# Checks to see if there are files ready to be committed | |
function git_changes | |
{ | |
string=$(git status 2> /dev/null) || return | |
if [[ "$string" == *"Changes to be committed"* ]] | |
then | |
echo -e "●" | |
fi | |
} | |
PS1=" \[\e[0;32m\]\W\[\e[1;32m\]\$(parse_git_branch)\[\e[0;31m\]\$(git_status)\[\e[0;33m\]\$(git_changes) \[\e[0;37m\]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment