Skip to content

Commit

Permalink
[Fix sorin-ionescu#361] Load chruby when found
Browse files Browse the repository at this point in the history
  • Loading branch information
sorin-ionescu authored and Pablo Olmos de Aguilera Corradini committed Mar 7, 2014
1 parent eba9c18 commit 7ff6af8
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
23 changes: 19 additions & 4 deletions modules/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
Expand All @@ -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
-------

Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions modules/ruby/functions/ruby-info
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 7 additions & 0 deletions modules/ruby/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions runcoms/zpreztorc
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down

0 comments on commit 7ff6af8

Please sign in to comment.