Skip to content

Instantly share code, notes, and snippets.

@jotafeldmann
Last active August 26, 2024 18:27
Show Gist options
  • Save jotafeldmann/0b4b71b2ef60c6d199a42b85c887dc2f to your computer and use it in GitHub Desktop.
Save jotafeldmann/0b4b71b2ef60c6d199a42b85c887dc2f to your computer and use it in GitHub Desktop.
ubuntu_simple_bash_git_prompt.sh
# Source: https://code.mendhak.com/simple-bash-prompt-for-developers-ps1-git/
function parse_git_dirty {
[[ $(git status --porcelain 2> /dev/null) ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/ (\1$(parse_git_dirty))/"
}
export PS1="\n\t \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment