Skip to content

Instantly share code, notes, and snippets.

@jaimeiniesta
Created November 27, 2013 14:18
Show Gist options
  • Save jaimeiniesta/7676379 to your computer and use it in GitHub Desktop.
Save jaimeiniesta/7676379 to your computer and use it in GitHub Desktop.
custom shell prompt showing ruby version and git branch
# BEGIN custom prompt
show_git_branch() {
_branch="$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
test -n "$_branch" && echo -e " $_branch"
}
# prompt with ruby version
show_ruby_version()
{
echo "$(ruby -e 'print RUBY_VERSION')"
}
show_dev_info() {
echo "($(show_ruby_version)$(show_git_branch))"
}
# colors
Black='\e[0;30m'
Red='\e[0;31m'
LightRed='\e[1;31m'
Green='\e[0;32m'
LightGreen='\e[1;32m'
Yellow='\e[0;33m'
Blue='\e[0;34m'
Purple='\e[0;35m'
Cyan='\e[0;36m'
White='\e[0;37m'
PS1="\n\[$Yellow\]\u@\h \[$Cyan\]\w \[$Green\]\$(show_dev_info)\n\[$White\]➔\[$White\] "
# END custom prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment