Created
October 23, 2010 10:52
-
-
Save chsh/642071 to your computer and use it in GitHub Desktop.
Show RAILS version using zsh RPROMPT.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| _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