Skip to content

Instantly share code, notes, and snippets.

@ys-qb
Last active October 22, 2017 01:47
Show Gist options
  • Save ys-qb/3ca62ff35fbbe260f9150752f9e75376 to your computer and use it in GitHub Desktop.
Save ys-qb/3ca62ff35fbbe260f9150752f9e75376 to your computer and use it in GitHub Desktop.
git prompt : branch only
# see https://coderwall.com/p/fasnya/add-git-branch-name-to-bash-prompt
# Terminal colours (after installing GNU coreutils)
NM="\[\033[0;38m\]" # means no background and white lines
GR="\[\033[0;90m\]" # dark grey
HI="\[\033[0;37m\]" # change this for letter colors
HII="\[\033[0;31m\]" # change this for letter colors
SI="\[\033[0;33m\]" # this is for the current directory
IN="\[\033[0m\]"
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1 /'
}
#export PS1="$NM[ $HI\u $HII\h $SI\w$NM ] $IN"
export PS1="$HII\h $SI\w$GR\$(parse_git_branch)$NM] $IN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment