[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 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 RVM
--- ---
@ -23,12 +23,27 @@ may conflict with shell scripts.
rbenv rbenv
----- -----
An alternative RVM is to use [rbenv][3], which allows for switching between multiple, An alternative RVM is to use [rbenv][3], which allows for switching between
isolated Ruby installations in the home directory. 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 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. 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 Bundler
------- -------
@ -87,4 +102,4 @@ Authors
[3]: https://github.com/sstephenson/rbenv [3]: https://github.com/sstephenson/rbenv
[4]: http://gembundler.com [4]: http://gembundler.com
[5]: https://github.com/sorin-ionescu/prezto/issues [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)" version="$(rvm-prompt)"
elif (( $+commands[rbenv] )); then elif (( $+commands[rbenv] )); then
version="$(rbenv version-name)" version="$(rbenv version-name)"
elif (( $+commands[ruby] )); then
version="${${$(ruby --version)[(w)1,(w)2]}/ /-}"
fi fi
# Format version. # Format version.

View file

@ -23,6 +23,13 @@ elif [[ -s "$HOME/.rbenv/bin/rbenv" ]]; then
elif (( $+commands[rbenv] )); then elif (( $+commands[rbenv] )); then
eval "$(rbenv init - --no-rehash zsh)" 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. # Prepend local gems bin directories to PATH.
else else
path=($HOME/.gem/ruby/*/bin(N) $path) 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. # Auto set to 'off' on dumb terminals.
zstyle ':prezto:module:prompt' theme 'sorin' zstyle ':prezto:module:prompt' theme 'sorin'
#
# Ruby
#
# Auto switch the Ruby version on directory change.
# zstyle ':prezto:module:ruby:chruby' auto-switch 'yes'
# #
# Screen # Screen
# #