chore(zsh): install rbenv, pyenv and nodenv with zinit instead of brew

Main benefit is that these tools will now auto-install correctly on
Linux systems too.
This commit is contained in:
2020-09-25 21:13:34 +01:00
parent a5bafef348
commit 90554015b7
8 changed files with 208 additions and 183 deletions

View File

@@ -44,13 +44,10 @@ brew 'node'
brew 'pandoc'
brew 'peco'
brew 'pgformatter'
brew 'pyenv'
brew 'rbenv'
brew 'rclone'
brew 'readline'
brew 'redis'
brew 'ripgrep'
brew 'ruby-build'
brew 'rustup-init'
brew 'shellcheck'
brew 'source-highlight'
@@ -71,15 +68,6 @@ brew 'zsh'
tap 'heroku/brew'
brew 'heroku'
# node.js version manager
tap 'nodenv/nodenv'
brew 'nodenv'
brew 'node-build'
brew 'nodenv-aliases'
brew 'nodenv-each'
brew 'nodenv-nvmrc'
brew 'nodenv-package-rehash'
# sshfs requires osxfuse
cask 'osxfuse'
brew 'sshfs'

View File

@@ -2,7 +2,7 @@
# direnv setup
#
zinit from"gh-r" as"program" mv"direnv* -> direnv" \
zinit ice wait lucid from'gh-r' as'program' mv'direnv* -> direnv' \
atclone'./direnv hook zsh > zhook.zsh' atpull'%atclone' \
pick"direnv" src="zhook.zsh" for \
direnv/direnv
pick'direnv' src='zhook.zsh'
zinit light direnv/direnv

View File

@@ -1,7 +1,11 @@
#
# Go (golang) setup.
# Go (golang) environment setup.
#
# ==============================================================================
# global golang packages
# ==============================================================================
install_go_global_packages() {
local packages=(
github.com/akavel/up
@@ -23,4 +27,9 @@ install_go_global_packages() {
echo "installing/updating \"$package\""
go get -u "$package"
done
if command-exists goenv && [ "$(goenv version-name)" != "system" ]; then
echo "running: goenv rehash..."
goenv rehash
fi
}

View File

@@ -1,14 +1,67 @@
#
# Node.js
# Node.js environment setup.
#
# Aliases
# ==============================================================================
# nodenv
# ==============================================================================
# install nodenv
zinit ice wait lucid as'program' pick'bin/nodenv' from'gh' \
atclone'src/configure && make -C src' atpull'%atclone' nocompile'!'
zinit light nodenv/nodenv
# install node-build
zinit ice wait lucid as'program' pick'bin/node-build' from'gh'
zinit light nodenv/node-build
# install nodenv-aliases plugin
zinit ice wait lucid as'program' pick'bin/nodenv-aliases' from'gh'
zinit light nodenv/nodenv-aliases
# install nodenv-each plugin
zinit ice wait lucid as'program' pick'bin/nodenv-each' from'gh'
zinit light nodenv/nodenv-each
# install nodenv-nvmrc plugin
zinit ice wait lucid as'program' pick'bin/nodenv-nvmrc' from'gh'
zinit light ouchxp/nodenv-nvmrc
# install nodenv-package-rehash plugin
zinit ice wait lucid as'program' pick'bin/nodenv-package-*' from'gh'
zinit light nodenv/nodenv-package-rehash
# lazy-load nodenv
nodenv() {
load-nodenv
nodenv "$@"
}
_nodenv() {
load-nodenv
_nodenv "$@"
}
compctl -K _nodenv nodenv
load-nodenv() {
unset -f load-nodenv _nodenv nodenv
eval "$(command nodenv init -)"
}
# ==============================================================================
# aliases
# ==============================================================================
alias no="node"
alias np="npm"
alias ni="npm install"
alias ngi="npm install -g"
alias cof="coffee"
alias tl="tldr"
# ==============================================================================
# global node packages
# ==============================================================================
install_node_global_packages() {
local packages=(
@@ -43,54 +96,3 @@ install_node_global_packages() {
npm install -g "${packages[@]}"
}
# Support for nodenv (https://github.com/nodenv/nodenv)
if command-exists nodenv; then
# lazy-load nodenv
nodenv() {
load-nodenv
nodenv "$@"
}
_nodenv() {
load-nodenv
_nodenv "$@"
}
compctl -K _nodenv nodenv
load-nodenv() {
unset -f load-nodenv _nodenv nodenv
eval "$(command nodenv init -)"
}
fi
# Support for nvm (https://github.com/nvm-sh/nvm)
if [ -f "$HOME/.nvm/nvm.sh" ]; then
export NVM_DIR="$HOME/.nvm"
# If default alias is set, add that Node version's bin direcotry to PATH to
# ensure CLI tools from npm packages work before nvm is lazy-loaded.
if [ -s "$NVM_DIR/alias/default" ]; then
path_prepend "$NVM_DIR/versions/node/$(cat "$NVM_DIR/alias/default")/bin"
fi
# lazy-load nvm
nvm() {
load-nvm
nvm "$@"
}
_nvm() {
load-nvm
_nvm "$@"
}
compctl -K _nvm nvm
load-nvm() {
unset -f load-nvm nvm _nvm
source "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion"
}
fi

View File

@@ -1,7 +1,46 @@
#
# Python environment setup
# Python environment setup.
#
# ==============================================================================
# pyenv
# ==============================================================================
# install pyenv
zinit ice wait lucid as'program' pick'bin/pyenv' from'gh' \
atclone'src/configure && make -C src' atpull'%atclone' nocompile'!'
zinit light pyenv/pyenv
# lazy-load pyenv
pyenv() {
load-pyenv
pyenv "$@"
}
_pyenv() {
load-pyenv
_pyenv "$@"
}
compctl -K _pyenv pyenv
load-pyenv() {
unset -f load-pyenv _pyenv pyenv
eval "$(command pyenv init -)"
}
# ==============================================================================
# aliases
# ==============================================================================
alias ap="env OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES ansible-playbook"
alias av="env OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES ansible-vault"
alias mo="env OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES molecule"
# ==============================================================================
# global python package
# ==============================================================================
install_python_global_packages() {
local packages=(
'ansible'
@@ -16,28 +55,3 @@ install_python_global_packages() {
"$pipcmd" install --upgrade setuptools
"$pipcmd" install --upgrade "${packages[@]}"
}
# Aliases
alias ap="env OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES ansible-playbook"
alias av="env OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES ansible-vault"
alias mo="env OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES molecule"
if command-exists pyenv; then
# lazy-load pyenv
pyenv() {
load-pyenv
pyenv "$@"
}
_pyenv() {
load-pyenv
_pyenv "$@"
}
compctl -K _pyenv pyenv
load-pyenv() {
unset -f load-pyenv _pyenv pyenv
eval "$(command pyenv init -)"
}
fi

View File

@@ -1,55 +0,0 @@
#
# rbenv (Ruby version manager) setup.
#
# ==============================================================================
# Lazy-load rbenv
# ==============================================================================
rbenv() {
load-rbenv
rbenv "$@"
}
_rbenv() {
load-rbenv
_rbenv "$@"
}
compctl -K _rbenv rbenv
load-rbenv() {
unset -f load-rbenv _rbenv rbenv
eval "$(command rbenv init -)"
}
# ==============================================================================
# Plugins
# ==============================================================================
zinit ice as'program' pick'bin/rbenv-each' from'gh'
zinit light rbenv/rbenv-each
# ==============================================================================
# Misc.
# ==============================================================================
solargraph-install() {
rbenv each -v gem install solargraph
}
solargraph-download-cores() {
rbenv each -v solargraph download-core
}
solargraph-list-versions() {
rbenv each -v gem list -q solargraph
}
rubygems-upgrade() {
rbenv each -v gem update --system
}
upgrade-bundler() {
rbenv each -v gem install --no-document 'bundler:~> 1.0' 'bundler:~> 2.0'
}

View File

@@ -2,6 +2,78 @@
# Ruby environment setup.
#
# ==============================================================================
# rbenv
# ==============================================================================
# Install rbenv
zinit ice wait lucid as'program' pick'bin/rbenv' from'gh' \
atclone'src/configure && make -C src' atpull'%atclone' nocompile'!'
zinit light rbenv/rbenv
# install ruby-build
zinit ice wait lucid as'program' pick'bin/ruby-build' from'gh'
zinit light rbenv/ruby-build
# install rbenv-each plugin
zinit ice wait lucid as'program' pick'bin/rbenv-each' from'gh'
zinit light rbenv/rbenv-each
# lazy-load rbenv
rbenv() {
load-rbenv
rbenv "$@"
}
_rbenv() {
load-rbenv
_rbenv "$@"
}
compctl -K _rbenv rbenv
load-rbenv() {
unset -f load-rbenv _rbenv rbenv
eval "$(command rbenv init -)"
}
# ==============================================================================
# aliases
# ==============================================================================
# bundler
alias bch="bundle check"
alias bcn="bundle clean"
alias bco="bundle console"
alias be="bundle exec"
alias bi="bundle_install"
alias bl="bundle list"
alias bo="bundle open"
alias bp="bundle package"
alias bu="bundle update"
# bundle exec wrappers
alias ru="bundle exec ruby"
alias ra="bundle exec rake"
alias rai="bundle exec rails"
alias rs="bundle exec rspec -f doc"
alias cu="bundle exec cucumber"
alias scu="RAILS_ENV=cucumber bundle exec spring cucumber"
# gems
alias po="powify"
alias lu="lunchy"
alias he="heroku"
alias f="foreman"
alias fs="foreman start"
alias fr="foreman run"
alias pe="procodile exec"
alias sm="schmersion"
# ==============================================================================
# global ruby packages
# ==============================================================================
install_ruby_global_packages() {
local packages=(
'bundler:~> 1.0'
@@ -25,35 +97,30 @@ install_ruby_global_packages() {
gem install --no-document "${packages[@]}"
}
# Aliases
alias po="powify"
alias lu="lunchy"
alias he="heroku"
alias f="foreman"
alias fs="foreman start"
alias fr="foreman run"
alias pe="procodile exec"
alias sm="schmersion"
# ==============================================================================
# bundler
# ==============================================================================
# Aliases for specific ruby commands
alias ru="bundle exec ruby"
alias ra="bundle exec rake"
alias rai="bundle exec rails"
alias rs="bundle exec rspec -f doc"
alias cu="bundle exec cucumber"
alias scu="RAILS_ENV=cucumber bundle exec spring cucumber"
upgrade-bundler() {
rbenv each -v gem install --no-document 'bundler:~> 1.0' 'bundler:~> 2.0'
}
# Bundler aliases
alias bch="bundle check"
alias bcn="bundle clean"
alias bco="bundle console"
alias be="bundle exec"
alias bi="bundle_install"
alias bl="bundle list"
alias bo="bundle open"
alias bp="bundle package"
alias bu="bundle update"
# ==============================================================================
# solargraph
# ==============================================================================
if command-exists rbenv; then
source "$DOTZSH/rbenv.zsh"
fi
solargraph-install() {
rbenv each -v gem install solargraph
}
solargraph-download-cores() {
rbenv each -v solargraph download-core
}
solargraph-list-versions() {
rbenv each -v gem list -q solargraph
}
rubygems-upgrade() {
rbenv each -v gem update --system
}

6
zshenv
View File

@@ -153,15 +153,15 @@ path_prepend "/opt/emacs/bin"
# Use custom tmux install if available
path_prepend "/opt/tmux/bin"
# Ruby setup
# Ruby setup for rbenv (./zsh/ruby.zsh)
path_prepend "$HOME/.rbenv/shims"
path_prepend "$HOME/.rbenv/bin"
# Python setup
# Python setup for pyenv (./zsh/python.zsh)
path_prepend "$HOME/.pyenv/shims"
path_prepend "$HOME/.pyenv/bin"
# Node setup
# Node setup for nodenv (./zsh/nodejs.zsh)
path_prepend "$HOME/.nodenv/shims"
path_prepend "$HOME/.nodenv/bin"