Skip to content

Instantly share code, notes, and snippets.

@adworse
Last active September 26, 2018 10:25
Show Gist options
  • Save adworse/531715b6beafec2cd520f987aff3a3d0 to your computer and use it in GitHub Desktop.
Save adworse/531715b6beafec2cd520f987aff3a3d0 to your computer and use it in GitHub Desktop.

Show git branch and ruby version in bash prompt

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}

get_ruby_version() {
  ruby -v | grep -o '\d\.\d\.\d'
}

export PS1="\[\033[32m\]\W \[\033[33m\]\$(parse_git_branch)\[\e[2m\]\$(get_ruby_version)\[\e[0m\]$ "

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