feat(revamp): add zsh and neovim configs, add an install script and a dependencies list
This commit is contained in:
@@ -0,0 +1,113 @@
|
||||
# Ruby
|
||||
|
||||
Configures [Ruby][1] 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_][2], 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_)][3],
|
||||
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_][4], 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`_:
|
||||
|
||||
```sh
|
||||
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][5].
|
||||
|
||||
## Aliases
|
||||
|
||||
Aliases are enabled by default. To disable them, add the following to
|
||||
_`${ZDOTDIR:-$HOME}/.zpreztorc`_.
|
||||
|
||||
```sh
|
||||
zstyle ':prezto:module:ruby:alias' skip 'yes'
|
||||
```
|
||||
|
||||
### 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.
|
||||
|
||||
```sh
|
||||
# %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][6]._
|
||||
|
||||
- [Sorin Ionescu](https://github.com/sorin-ionescu)
|
||||
|
||||
[1]: https://www.ruby-lang.org
|
||||
[2]: https://github.com/rbenv/rbenv
|
||||
[3]: https://rvm.io
|
||||
[4]: https://github.com/postmodern/chruby
|
||||
[5]: https://gembundler.com
|
||||
[6]: https://github.com/sorin-ionescu/prezto/issues
|
||||
@@ -0,0 +1,22 @@
|
||||
#
|
||||
# Displays the path to the Ruby application root directory.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function ruby-app-root {
|
||||
|
||||
local root_dir="$PWD"
|
||||
|
||||
while [[ "$root_dir" != '/' ]]; do
|
||||
if [[ -f "$root_dir/Gemfile" ]]; then
|
||||
print "$root_dir"
|
||||
break
|
||||
fi
|
||||
root_dir="$root_dir:h"
|
||||
done
|
||||
|
||||
return 1
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,38 @@
|
||||
#
|
||||
# Exposes information about the Ruby environment via the $ruby_info associative
|
||||
# array.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
#
|
||||
|
||||
# function ruby-info {
|
||||
|
||||
local version
|
||||
local version_format
|
||||
local version_formatted
|
||||
|
||||
# Clean up previous $ruby_info.
|
||||
unset ruby_info
|
||||
typeset -gA ruby_info
|
||||
|
||||
# Grab formatting for anything we might have to do
|
||||
zstyle -s ':prezto:module:ruby:info:version' format 'version_format'
|
||||
|
||||
if [[ -n "$version_format" ]]; then
|
||||
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.
|
||||
if [[ -n "$version" && "$version" != "system" ]]; then
|
||||
zformat -f version_formatted "$version_format" "v:$version"
|
||||
ruby_info[version]="$version_formatted"
|
||||
fi
|
||||
fi
|
||||
|
||||
# }
|
||||
@@ -0,0 +1,83 @@
|
||||
#
|
||||
# Configures Ruby local installation, loads version managers, and defines
|
||||
# aliases.
|
||||
#
|
||||
# Authors:
|
||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||
# Indrajit Raychaudhuri <irc@indrajit.com>
|
||||
#
|
||||
|
||||
# Possible lookup locations for manually installed rbenv and rvm.
|
||||
local_rbenv_paths=({$RBENV_ROOT,{$XDG_CONFIG_HOME/,$HOME/.}rbenv}/bin/rbenv(N))
|
||||
local_rvm_paths=({$RVM_DIR,{$XDG_CONFIG_HOME/,$HOME/.}rvm}/scripts/rvm(N))
|
||||
|
||||
# Load manually installed or package manager installed rbenv into the shell
|
||||
# session.
|
||||
if (( $#local_rbenv_paths || $+commands[rbenv] )); then
|
||||
|
||||
# Ensure manually installed rbenv is added to path when present.
|
||||
[[ -s $local_rbenv_paths[1] ]] && path=($local_rbenv_paths[1]:h $path)
|
||||
|
||||
eval "$(rbenv init - zsh)"
|
||||
|
||||
# Load manually installed rvm into the shell session.
|
||||
elif (( $#local_rvm_paths )); then
|
||||
# Unset AUTO_NAME_DIRS since auto adding variable-stored paths to ~ list
|
||||
# conflicts with rvm.
|
||||
unsetopt AUTO_NAME_DIRS
|
||||
|
||||
source "$local_rvm_paths[1]"
|
||||
|
||||
# Load package manager installed chruby into the shell session.
|
||||
elif (( $+commands[chruby-exec] )); then
|
||||
if (( ! $+functions[chruby] )); then
|
||||
source "${commands[chruby-exec]:h:h}/share/chruby/chruby.sh"
|
||||
fi
|
||||
|
||||
if zstyle -t ':prezto:module:ruby:chruby' auto-switch; then
|
||||
if (( ! $+functions[chruby_auto] )); then
|
||||
source "${commands[chruby-exec]:h:h}/share/chruby/auto.sh"
|
||||
fi
|
||||
|
||||
# If a default ruby is set, switch to it.
|
||||
chruby_auto
|
||||
fi
|
||||
|
||||
# Prepend local gems bin directories to PATH.
|
||||
else
|
||||
path=($HOME/.gem/ruby/*/bin(N) $path)
|
||||
fi
|
||||
|
||||
unset local_rbenv
|
||||
|
||||
# Return if requirements are not found.
|
||||
if (( ! $+commands[ruby] && ! $#functions[(i)r(benv|vm)] )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Aliases
|
||||
#
|
||||
|
||||
if ! zstyle -t ':prezto:module:ruby:alias' skip; then
|
||||
# General
|
||||
alias rb='ruby'
|
||||
|
||||
# Bundler
|
||||
if (( $+commands[bundle] )); then
|
||||
alias rbb='bundle'
|
||||
alias rbbc='bundle clean'
|
||||
alias rbbe='bundle exec'
|
||||
alias rbbi='bundle install --path vendor/bundle'
|
||||
alias rbbl='bundle list'
|
||||
alias rbbo='bundle open'
|
||||
alias rbbp='bundle package'
|
||||
alias rbbu='bundle update'
|
||||
alias rbbI='rbbi \
|
||||
&& bundle package \
|
||||
&& print .bundle >>! .gitignore \
|
||||
&& print vendor/assets >>! .gitignore \
|
||||
&& print vendor/bundle >>! .gitignore \
|
||||
&& print vendor/cache >>! .gitignore'
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user