refactor: use rtx to manage Go, Python, NodeJS, and more

This means g, pyenv, and volta are gone. And a lot of other tools
previously installed with zinit are also installed with rtx now instead.

This includes starship, direnv, shfmt, jq, and more.
This commit is contained in:
2023-03-09 23:06:47 +00:00
parent 885fd26901
commit 664f06bbdb
15 changed files with 75 additions and 170 deletions

3
config/rtx/config.toml Normal file
View File

@@ -0,0 +1,3 @@
[settings]
experimental = true
shims_dir = "~/.rtx/shims"

View File

@@ -15,6 +15,7 @@ SYMLINKS=(
bitbar bitbar
coffeelint.json coffeelint.json
config/kitty/kitty.conf config/kitty/kitty.conf
config/rtx/config.toml
config/solargraph/config.yml config/solargraph/config.yml
config/starship.toml config/starship.toml
erlang erlang
@@ -28,7 +29,6 @@ SYMLINKS=(
irbrc irbrc
peco peco
powconfig powconfig
prettierrc.js
pryrc pryrc
reek.yml reek.yml
rspec rspec
@@ -36,6 +36,7 @@ SYMLINKS=(
rustfmt.toml rustfmt.toml
tmux tmux
tmux.conf tmux.conf
tool-versions
zshenv zshenv
zshrc zshrc
) )

View File

@@ -1,50 +0,0 @@
const homedir = require('os').homedir();
const fs = require("fs");
function voltaPrettierSearchDirs(voltaDir) {
const packagesDir = `${voltaDir}/tools/image/packages`;
let paths = []
let parents = [];
fs.readdirSync(packagesDir).forEach((item) => {
if (/^prettier-plugin-[^/]+$/.test(item)) {
paths.push(`${packagesDir}/${item}/lib`);
}
if (item == '@prettier') {
paths = paths.concat(
findDirs(`${packagesDir}/@prettier`, /^plugin-[^/]+$/, "lib")
);
} else if (/^@[^/]+$/.test(item)) {
parents.push(`${packagesDir}/${item}`);
}
return [];
})
parents.forEach((parent) => {
paths = paths.concat(findDirs(parent, /^prettier-plugin-[^/]+$/, "lib"));
})
return paths;
}
function findDirs(parent, pattern, suffix) {
return fs.readdirSync(parent).flatMap((item) => {
const fp = `${parent}/${item}`;
if (pattern.test(item) && fs.statSync(fp).isDirectory()) {
if (suffix) {
return `${fp}/${suffix}`;
}
return fp;
}
return [];
});
}
module.exports = {
pluginSearchDirs: voltaPrettierSearchDirs(`${homedir}/.volta`),
};

11
tool-versions Normal file
View File

@@ -0,0 +1,11 @@
bat latest
direnv latest
dust latest
exa latest
golang latest
jq latest
nodejs lts
python latest
shellcheck latest
shfmt latest
starship latest

View File

@@ -1,9 +0,0 @@
#
# direnv setup
#
zinit light-mode wait lucid from'gh-r' as'program' pick'direnv' \
mv'direnv* -> direnv' \
atclone'./direnv hook zsh > .zinitrc.zsh' atpull'%atclone' \
src='.zinitrc.zsh' \
for @direnv/direnv

View File

@@ -2,10 +2,10 @@
# fzf # fzf
# #
export FZF_DEFAULT_OPTS="--bind=ctrl-k:kill-line --border=none --tabstop=4"
export FZF_TMUX_HEIGHT=100%
export FZF_TMUX=0
export FZF_CTRL_T_OPTS="--preview='less {}'" export FZF_CTRL_T_OPTS="--preview='less {}'"
export FZF_DEFAULT_OPTS="--bind=ctrl-k:kill-line --border=none --tabstop=4"
export FZF_TMUX=0
export FZF_TMUX_HEIGHT=100%
# Install fzf binary from latest GitHub Release. # Install fzf binary from latest GitHub Release.
zinit light-mode wait lucid from'gh-r' as'program' pick'fzf' \ zinit light-mode wait lucid from'gh-r' as'program' pick'fzf' \

View File

@@ -2,24 +2,9 @@
# Go (golang) environment setup. # Go (golang) environment setup.
# #
# # ==============================================================================
# g - Simple go version manager, gluten-free
#
# Create symlink for "g" called "gv", as I have "g" aliased to "git".
zinit light-mode wait lucid as'program' pick'bin/g' from'gh' \
atclone'cd bin && ln -s g gv' atpull'%atclone' \
for @stefanmaric/g
#
# gup - Update binaries installed with "go install"
#
zinit light-mode wait lucid as'program' from'gh-r' pick'gup' \
for @nao1215/gup
#
# global golang packages # global golang packages
# # ==============================================================================
list_go_global_packages() { list_go_global_packages() {
for bin in $(ls -1 ~/.go/bin); do for bin in $(ls -1 ~/.go/bin); do

View File

@@ -1,8 +0,0 @@
#
# jq
#
if ! command-exists jq; then
zinit light-mode wait lucid from'gh-r' as'program' mv'jq* -> jq' \
for @stedolan/jq
fi

View File

@@ -2,31 +2,11 @@
# Node.js environment setup. # Node.js environment setup.
# #
# ==============================================================================
# Volta
# ==============================================================================
zinit light-mode wait lucid as'program' from'gh-r' \
atclone'./volta completions zsh > _volta' atpull'%atclone' \
for @volta-cli/volta
# ==============================================================================
# aliases
# ==============================================================================
alias no="node"
alias np="npm"
# ============================================================================== # ==============================================================================
# global node packages # global node packages
# ============================================================================== # ==============================================================================
install_node_global_packages() { install_node_global_packages() {
local volta_packages=(
npm
npx
yarn
)
local npm_packages=( local npm_packages=(
@commitlint/cli @commitlint/cli
@commitlint/config-conventional @commitlint/config-conventional
@@ -57,7 +37,8 @@ install_node_global_packages() {
vscode-css-languageserver-bin vscode-css-languageserver-bin
vscode-json-languageserver vscode-json-languageserver
yaml-language-server yaml-language-server
yarn
) )
volta install "${volta_packages[@]}" "${npm_packages[@]}" npm install -g "${npm_packages[@]}"
} }

View File

@@ -2,20 +2,6 @@
# Python environment setup. # Python environment setup.
# #
# ==============================================================================
# pyenv
# ==============================================================================
# install pyenv
zinit light-mode wait lucid as'program' pick'bin/pyenv' from'gh' \
atclone'src/configure && make -C src; libexec/pyenv init - > .zinitrc.zsh' \
atpull'%atclone' src'.zinitrc.zsh' nocompile'!' \
for @pyenv/pyenv
zinit light-mode wait lucid as'program' pick'plugins/python-build/bin/python-build' \
from'gh' id-as'pyenv/python-build' \
for @pyenv/pyenv
# ============================================================================== # ==============================================================================
# aliases # aliases
# ============================================================================== # ==============================================================================

View File

@@ -1,7 +0,0 @@
#
# Rclone
#
zinit light-mode wait lucid as'program' from'gh-r' mv'**/rclone -> rclone' \
atclone'./rclone genautocomplete zsh - > _rclone' atpull'%atclone' \
for @rclone/rclone

View File

@@ -8,8 +8,8 @@
# Install rbenv # Install rbenv
zinit light-mode wait lucid as'program' pick'bin/rbenv' from'gh' \ zinit light-mode wait lucid as'program' pick'bin/rbenv' from'gh' \
atclone'src/configure && make -C src; libexec/rbenv init - > .zinitrc.zsh' \ atclone'src/configure && make -C src; libexec/rbenv init - > .rbenv.zsh' \
atpull'%atclone' src'.zinitrc.zsh' nocompile'!' \ atpull'%atclone' src'.rbenv.zsh' nocompile'!' \
for @rbenv/rbenv for @rbenv/rbenv
# install ruby-build # install ruby-build

View File

@@ -12,8 +12,8 @@ alias tmm="tmn -s main"
# Tmuxifier # Tmuxifier
zinit light-mode wait lucid as'program' pick'bin/tmuxifier' from'gh' \ zinit light-mode wait lucid as'program' pick'bin/tmuxifier' from'gh' \
atclone'./bin/tmuxifier init - > .zinitrc.zsh' atpull'%atclone' \ atclone'./bin/tmuxifier init - > .tmuxifier.zsh' atpull'%atclone' \
src='.zinitrc.zsh' \ src='.tmuxifier.zsh' \
for @jimeh/tmuxifier for @jimeh/tmuxifier
alias m="tmuxifier" alias m="tmuxifier"

33
zshenv
View File

@@ -59,6 +59,15 @@ path_prepend () {
fi fi
} }
# ==============================================================================
# Helpers
# ==============================================================================
command-exists() {
(( ${+commands[$1]} ))
return $?
}
# ============================================================================== # ==============================================================================
# System Environment Setup # System Environment Setup
# ============================================================================== # ==============================================================================
@@ -171,35 +180,23 @@ fi
# Use custom tmux install if available # Use custom tmux install if available
path_prepend "/opt/tmux/bin" path_prepend "/opt/tmux/bin"
# Go setup (./zsh/golang.zsh)
export GOPATH="$HOME/.go"
export GOROOT="$HOME/.local/go"
path_prepend "$GOPATH/bin"
# Ruby setup for rbenv (./zsh/ruby.zsh) # Ruby setup for rbenv (./zsh/ruby.zsh)
path_prepend "$HOME/.rbenv/shims" path_prepend "$HOME/.rbenv/shims"
# Python setup for pyenv (./zsh/python.zsh)
path_prepend "$HOME/.pyenv/shims"
# Node setup for volta (./zsh/nodejs.zsh)
path_prepend "$HOME/.volta/bin"
# Rust setup # Rust setup
path_prepend "$HOME/.cargo/bin" export CARGO_HOME="$HOME/.cargo"
path_prepend "$CARGO_HOME/bin"
# RTX shim setup
path_prepend "$HOME/.rtx/shims"
# ============================================================================== # ==============================================================================
# Path setup for select binaries installed with zinit # Path setup for select binaries installed with zinit
# ============================================================================== # ==============================================================================
path_prepend "$HOME/.local/zsh/zinit/plugins/direnv---direnv" path_prepend "$HOME/.local/zsh/zinit/plugins/jdxcode---rtx"
path_prepend "$HOME/.local/zsh/zinit/plugins/junegunn---fzf" path_prepend "$HOME/.local/zsh/zinit/plugins/junegunn---fzf"
path_prepend "$HOME/.local/zsh/zinit/plugins/mvdan---sh"
path_prepend "$HOME/.local/zsh/zinit/plugins/pyenv---pyenv/bin"
path_prepend "$HOME/.local/zsh/zinit/plugins/rbenv---rbenv/bin" path_prepend "$HOME/.local/zsh/zinit/plugins/rbenv---rbenv/bin"
path_prepend "$HOME/.local/zsh/zinit/plugins/rclone---rclone"
path_prepend "$HOME/.local/zsh/zinit/plugins/stefanmaric---g/bin"
path_prepend "$HOME/.local/zsh/zinit/plugins/volta-cli---volta"
# ============================================================================== # ==============================================================================
# Local Overrides # Local Overrides

51
zshrc
View File

@@ -9,15 +9,6 @@ if [[ "$OSTYPE" == "darwin"* ]] && [ -f "/etc/zshrc" ]; then
source "/etc/zshrc" source "/etc/zshrc"
fi fi
# ==============================================================================
# Helpers
# ==============================================================================
command-exists() {
(( ${+commands[$1]} ))
return $?
}
# ============================================================================== # ==============================================================================
# Zinit # Zinit
# ============================================================================== # ==============================================================================
@@ -28,7 +19,7 @@ ZINIT[BIN_DIR]="${ZINIT[HOME_DIR]}/bin"
# Load zinit module if it exists. For more info, run: zinit module help # Load zinit module if it exists. For more info, run: zinit module help
if [ -d "${ZINIT[HOME_DIR]}/module/Src/zdharma_continuum" ]; then if [ -d "${ZINIT[HOME_DIR]}/module/Src/zdharma_continuum" ]; then
module_path+=( "${ZINIT[HOME_DIR]}/module/Src" ) module_path+=("${ZINIT[HOME_DIR]}/module/Src")
zmodload zdharma_continuum/zinit zmodload zdharma_continuum/zinit
fi fi
@@ -50,11 +41,6 @@ zinit for @OMZ::lib/history.zsh
# Enable Ruby Bundler plugin from oh-my-zsh. # Enable Ruby Bundler plugin from oh-my-zsh.
zinit for @OMZ::plugins/bundler zinit for @OMZ::plugins/bundler
zinit light-mode lucid as'program' from'gh-r' \
atclone'./starship completions zsh > _starship; ./starship init zsh --print-full-init > .zinitrc.zsh' \
atpull'%atclone' pick'starship' src'.zinitrc.zsh' \
for @starship/starship
zinit light-mode wait lucid \ zinit light-mode wait lucid \
atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \ atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \
for @zdharma-continuum/fast-syntax-highlighting for @zdharma-continuum/fast-syntax-highlighting
@@ -96,6 +82,38 @@ if [ -f "$DOTPFILES/zshrc" ]; then
source "$DOTPFILES/zshrc" source "$DOTPFILES/zshrc"
fi fi
# ==============================================================================
# Environment and Tool Managers
# ==============================================================================
if command-exists direnv; then
eval "$(direnv hook zsh)"
fi
zinit light-mode wait lucid from'gh-r' as'program' pick'rtx' mv'rtx* -> rtx' \
atclone'./rtx complete --shell zsh > _rtx && chmod +x _rtx && ./rtx activate zsh > .rtx.zsh' \
atpull'%atclone' \
src='.rtx.zsh' \
for @jdxcode/rtx
# ==============================================================================
# Prompt
# ==============================================================================
if command-exists starship; then
eval "$(starship init zsh --print-full-init)"
_starship() {
unset -f _starship
eval "$(starship completions zsh)"
}
compctl -K _starship starship
else
echo "WARN: starship not found, skipping prompt setup" >&2
echo " install with: rtx install starship" >&2
fi
# ============================================================================== # ==============================================================================
# Tool specific setup # Tool specific setup
# ============================================================================== # ==============================================================================
@@ -111,14 +129,11 @@ if [[ "$OSTYPE" == "linux"* ]]; then source "$DOTZSH/linux.zsh"; fi
source "$DOTZSH/1password.zsh" source "$DOTZSH/1password.zsh"
source "$DOTZSH/emacs.zsh" source "$DOTZSH/emacs.zsh"
source "$DOTZSH/fzf.zsh" source "$DOTZSH/fzf.zsh"
source "$DOTZSH/jq.zsh"
source "$DOTZSH/less.zsh" source "$DOTZSH/less.zsh"
source "$DOTZSH/rclone.zsh"
source "$DOTZSH/tmux.zsh" source "$DOTZSH/tmux.zsh"
# Development # Development
source "$DOTZSH/containers.zsh" source "$DOTZSH/containers.zsh"
source "$DOTZSH/direnv.zsh"
source "$DOTZSH/golang.zsh" source "$DOTZSH/golang.zsh"
source "$DOTZSH/google-cloud.zsh" source "$DOTZSH/google-cloud.zsh"
source "$DOTZSH/kubernetes.zsh" source "$DOTZSH/kubernetes.zsh"