1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-11-14 03:01:12 +00:00
prezto/modules/ruby
Indrajit Raychaudhuri 37443368c1 ruby: Cleanup and optimize 'ruby' module
Changes:
- Honor `$RBENV_ROOT` or `RVM_DIR` if set but, no need to set it
  explicitly if not set. Instead, let the respective initialization
  scripts take care of that.
- Reverse `rbenv` vs `rvm` selection order, preferring `rbenv` instead.
- Check for availability of `rbenv` or `rvm` function instead of command
  to validate requirements. In a properly configured and initialized
  shell, `rbenv` or `rvm` will be available as function.
- Adhere to more idiomatic Zsh operation and minimize redundant syntaxes.

For additional rationale, see: https://github.com/rbenv/rbenv/wiki/Why-rbenv%3F
2021-06-01 14:31:26 -05:00
..
functions ruby-info: only run commands if the prompt needs the info 2017-12-04 15:08:23 -08:00
init.zsh ruby: Cleanup and optimize 'ruby' module 2021-06-01 14:31:26 -05:00
README.md ruby: Cleanup and optimize 'ruby' module 2021-06-01 14:31:26 -05:00

Ruby

Configures Ruby local gem installation, loads version managers, and defines aliases.

Local Gem Installation

When a Ruby version manager is not detected, local gems are installed in ~/.gem; otherwise, they are installed according to the manager.

rbenv

An alternative RVM is to use rbenv, 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.

This will be loaded automatically if rbenv is installed to $RBENV_ROOT, ~/.rbenv, or if the rbenv command is on the path.

rvm

An alternative to the above is to use The Ruby Version Manager (rvm), which allows for managing multiple, isolated Ruby installations and gem sets in the home directory.

Since RVM is loaded into the shell and is known to override shell commands, it may conflict with shell scripts.

Load this module as late as possible when using RVM since RVM will complain if it is not first in $PATH.

chruby

Yet another alternative is chruby, 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 ${ZDOTDIR:-$HOME}/.zpreztorc:

zstyle ':prezto:module:ruby:chruby' auto-switch 'yes'

Bundler

Manage gems that are not meant to be used as commands, such as application dependencies, with Bundler.

Aliases

General

  • rb is short for ruby.

Bundler

  • rbb manages ruby dependencies (bundle).
  • rbbc cleans up unused gems in your bundler directory.
  • rbbe executes a script in the context of the current bundle.
  • rbbi installs the gems specified in the Gemfile in vendor/bundle.
  • rbbI installs the following:
    • gems specified in the Gemfile in vendor/bundle.
    • packages the gems into vendor/cache.
    • appends bundler directories to .gitignore.
  • rbbl lists all gems in the current bundle.
  • rbbo opens an installed gem in the editor.
  • rbbp packages gem files into vendor/cache.
  • rbbu updates gems to their latest version.

Functions

  • ruby-app-root displays the path to the Ruby application root directory.
  • ruby-info exposes information about the Ruby environment via the $ruby_info associative array.

Theming

To display the name of the current Ruby version in a prompt, define the following style in the prompt_name_setup function.

# %v - ruby version.
zstyle ':prezto:module:ruby:info:version' format 'version:%v'

Then add $ruby_info[version] to $PROMPT or $RPROMPT and call ruby-info in the prompt_name_preexec hook function.

Authors

The authors of this module should be contacted via the issue tracker.