Skip to content

Instantly share code, notes, and snippets.

@chsh
Created October 23, 2010 10:52
Show Gist options
  • Select an option

  • Save chsh/642071 to your computer and use it in GitHub Desktop.

Select an option

Save chsh/642071 to your computer and use it in GitHub Desktop.
Show RAILS version using zsh RPROMPT.
_set_env_git_current_branch() {
GIT_CURRENT_BRANCH=$( git branch &> /dev/null | grep '^\*' | cut -b 3- )
}
_set_env_rails_version() {
RAILS_VERSION=$( rails -v &> /dev/null | cut -b 7- )
}
_update_rprompt () {
if [ "`git ls-files 2>/dev/null`" ]; then
RPROMPT="[$RAILS_VERSION:%2.:$GIT_CURRENT_BRANCH]"
else
RPROMPT="[$RAILS_VERSION:%2.]"
fi
}
precmd()
{
_set_host_and_pwd_on_title
_set_env_git_current_branch
_set_env_rails_version
_update_rprompt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment