Skip to content

Instantly share code, notes, and snippets.

@shubhamkumar13
Created November 1, 2020 14:57
Show Gist options
  • Save shubhamkumar13/5e8d8080bde56bf6ba19302397e7c6ca to your computer and use it in GitHub Desktop.
Save shubhamkumar13/5e8d8080bde56bf6ba19302397e7c6ca to your computer and use it in GitHub Desktop.
single line command that shows git branch
export PS1="\[\033[95m\]\u@\h \[\033[32m\]\W\[\033[33m\] [\$(git symbolic-ref --short HEAD 2>/dev/null)]\[\033[00m\]\$ "
@shubhamkumar13
Copy link
Author

I like this one now

#color your git branch
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]$(parse_git_branch)\n\$ '

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment