Skip to content

Instantly share code, notes, and snippets.

@aravindkumarsvg
Last active July 19, 2017 02:26
Show Gist options
  • Save aravindkumarsvg/b57795e5019063d93562d1f3aaa25c60 to your computer and use it in GitHub Desktop.
Save aravindkumarsvg/b57795e5019063d93562d1f3aaa25c60 to your computer and use it in GitHub Desktop.
Git prompt for Bash shell
# Reference https://gist.github.com/justintv/168835
# Used in Elementery OS terminal
# Add to ~/.bashrc file
# Sets the Git branch name in the PS1 prompt
function git_prompt_setter() {
local RED="\\\[\\\033[1;31m\\\]"
local NORMAL="\\\[\\\033[00m\\\]"
# Modifies the existing prompt and adds the git branch name
PS1=$(echo $PS1 | sed 's/\(\\\?[$#]\)\s*$/'"$RED"'\$\(__git_ps1\)'"$NORMAL"'\1 / ' )
}
git_prompt_setter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment