[Fix #361] Load chruby when found

This commit is contained in:
Sorin Ionescu 2014-02-01 23:37:29 -05:00
parent af003d83c5
commit dbeb6d4e1a
4 changed files with 35 additions and 4 deletions

View File

@ -8,7 +8,7 @@ Local Gem Installation
----------------------
When a Ruby version manager is not detected, local gems are installed in
*~/Library/Ruby/Gems/1.8* on Mac OS X.
*~/.gems*; otherwise, they are installed according to the manager.
RVM
---
@ -23,12 +23,27 @@ may conflict with shell scripts.
rbenv
-----
An alternative RVM is to use [rbenv][3], which allows for switching between multiple,
isolated Ruby installations in the home directory.
An alternative RVM is to use [rbenv][3], which allows for switching between
multiple, isolated Ruby installations in the home directory.
While it is not as feature rich as RVM, it is not loaded into the shell and is
not known to cause conflicts with shell scripts.
chruby
------
Yet another alternative is [chruby][6], which is simpler than both RVM and
rbenv.
### Settings
#### Auto-Switch
To enable auto switching the Ruby version on directory change based on the
.ruby-version file, add the following line to *zpreztorc*:
zstyle ':prezto:module:ruby:chruby' auto-switch 'yes'
Bundler
-------
@ -87,4 +102,4 @@ Authors
[3]: https://github.com/sstephenson/rbenv
[4]: http://gembundler.com
[5]: https://github.com/sorin-ionescu/prezto/issues
[6]: https://github.com/postmodern/chruby

View File

@ -18,6 +18,8 @@ if (( $+commands[rvm-prompt] )); then
version="$(rvm-prompt)"
elif (( $+commands[rbenv] )); then
version="$(rbenv version-name)"
elif (( $+commands[ruby] )); then
version="${${$(ruby --version)[(w)1,(w)2]}/ /-}"
fi
# Format version.

View File

@ -23,6 +23,13 @@ elif [[ -s "$HOME/.rbenv/bin/rbenv" ]]; then
elif (( $+commands[rbenv] )); then
eval "$(rbenv init - --no-rehash zsh)"
# Load package manager installed chruby into the shell session.
elif (( $+commands[chruby-exec] )); then
source "${commands[chruby-exec]:h:h}/share/chruby/chruby.sh"
if zstyle -t ':prezto:module:ruby:chruby' auto-switch; then
source "${commands[chruby-exec]:h:h}/share/chruby/auto.sh"
fi
# Prepend local gems bin directories to PATH.
else
path=($HOME/.gem/ruby/*/bin(N) $path)

View File

@ -87,6 +87,13 @@ zstyle ':prezto:module:editor' key-bindings 'emacs'
# Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'sorin'
#
# Ruby
#
# Auto switch the Ruby version on directory change.
# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes'
#
# Screen
#