Skip to content

Instantly share code, notes, and snippets.

@marclipovsky
Last active January 4, 2022 00:48
Show Gist options
  • Save marclipovsky/4660499 to your computer and use it in GitHub Desktop.
Save marclipovsky/4660499 to your computer and use it in GitHub Desktop.
git-bash-prompt
# 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