diff --git a/private_dot_bashrc b/private_dot_bashrc index 512f4be..dd9a9bd 100644 --- a/private_dot_bashrc +++ b/private_dot_bashrc @@ -43,9 +43,7 @@ if [[ -d "/usr/local/bin" ]]; then fi if [[ -e "/opt/homebrew/bin/brew" ]]; then - eval "$(/opt/homebrew/bin/brew shellenv)" -elif [[ -e "/usr/local/bin/brew" ]]; then - eval "$(/usr/local/bin/brew shellenv)" + eval "$(/opt/homebrew/bin/brew shellenv bash)" fi # Import files from $HOME/.bashrc.d diff --git a/private_dot_bashrc.d/private_tools/private_golang.bash.tmpl b/private_dot_bashrc.d/private_tools/private_golang.bash.tmpl index 8fb54ae..f9429b1 100644 --- a/private_dot_bashrc.d/private_tools/private_golang.bash.tmpl +++ b/private_dot_bashrc.d/private_tools/private_golang.bash.tmpl @@ -1,8 +1,6 @@ # shellcheck shell=bash # shellcheck disable=SC2103,SC2155,SC2164 -if [[ -d "$HOME/.goenv" ]]; then - export GOENV_ROOT="$HOME/.goenv" -fi +export GOENV_ROOT="${GOENV_ROOT:-$HOME/.goenv}" {{- if (and (eq .chezmoi.os "linux") (or (eq .chezmoi.osRelease.id "debian") (eq .chezmoi.osRelease.id "ubuntu"))) }} if [[ -n "$GOENV_ROOT" ]] && [[ -f "$GOENV_ROOT/bin/goenv" ]]; then @@ -11,8 +9,14 @@ fi {{- end }} if command -v goenv >/dev/null 2>&1; then - eval "$(goenv init -)" - path_prepend "$GOENV_ROOT/shims" + if [[ -d "$GOENV_ROOT/shims" ]]; then + path_prepend "$GOENV_ROOT/shims" + fi + goenv() { + unset -f goenv + eval "$(command goenv init -)" + goenv "$@" + } fi if [[ -d "$HOME/Developer/go" ]]; then diff --git a/private_dot_bashrc.d/private_tools/private_node.bash.tmpl b/private_dot_bashrc.d/private_tools/private_node.bash.tmpl index 52cda4b..ab9478e 100644 --- a/private_dot_bashrc.d/private_tools/private_node.bash.tmpl +++ b/private_dot_bashrc.d/private_tools/private_node.bash.tmpl @@ -4,9 +4,7 @@ if [[ -d "$HOMEBREW_PREFIX/share/npm/bin" ]]; then path_append "$HOMEBREW_PREFIX/share/npm/bin" fi -if [[ -d "$HOME/.nodenv" ]]; then - export NODENV_ROOT="$HOME/.nodenv" -fi +export NODENV_ROOT="${NODENV_ROOT:-$HOME/.nodenv}" {{- if (and (eq .chezmoi.os "linux") (or (eq .chezmoi.osRelease.id "debian") (eq .chezmoi.osRelease.id "ubuntu"))) }} if [[ -n "$NODENV_ROOT" ]] && [[ -f "$NODENV_ROOT/bin/nodenv" ]]; then @@ -15,5 +13,12 @@ fi {{- end }} if command -v nodenv >/dev/null 2>&1; then - eval "$(nodenv init -)" + if [[ -d "$NODENV_ROOT/shims" ]]; then + path_prepend "$NODENV_ROOT/shims" + fi + nodenv() { + unset -f nodenv + eval "$(command nodenv init -)" + nodenv "$@" + } fi diff --git a/private_dot_bashrc.d/private_tools/private_ruby.bash.tmpl b/private_dot_bashrc.d/private_tools/private_ruby.bash.tmpl index 2f1109b..5aa8f9b 100644 --- a/private_dot_bashrc.d/private_tools/private_ruby.bash.tmpl +++ b/private_dot_bashrc.d/private_tools/private_ruby.bash.tmpl @@ -1,8 +1,6 @@ # shellcheck shell=bash # shellcheck disable=SC2103,SC2155,SC2164 -if [[ -d "$HOME/.rbenv" ]]; then - export RBENV_ROOT="$HOME/.rbenv" -fi +export RBENV_ROOT="${RBENV_ROOT:-$HOME/.rbenv}" {{- if (and (eq .chezmoi.os "linux") (or (eq .chezmoi.osRelease.id "debian") (eq .chezmoi.osRelease.id "ubuntu"))) }} if [[ -n "$RBENV_ROOT" ]] && [[ -f "$RBENV_ROOT/bin/rbenv" ]]; then @@ -11,5 +9,12 @@ fi {{- end }} if command -v rbenv >/dev/null 2>&1; then - eval "$(rbenv init -)" + if [[ -d "$RBENV_ROOT/shims" ]]; then + path_prepend "$RBENV_ROOT/shims" + fi + rbenv() { + unset -f rbenv + eval "$(command rbenv init -)" + rbenv "$@" + } fi diff --git a/private_dot_config/private_fish/private_conf.d/private_00-path-base.fish.tmpl b/private_dot_config/private_fish/private_conf.d/private_00-path-base.fish.tmpl index 079f74d..e55479c 100644 --- a/private_dot_config/private_fish/private_conf.d/private_00-path-base.fish.tmpl +++ b/private_dot_config/private_fish/private_conf.d/private_00-path-base.fish.tmpl @@ -7,7 +7,7 @@ if test -d "/usr/local/bin" end {{ if eq .chezmoi.os "darwin" }} if test -x "/opt/homebrew/bin/brew" - eval "$(/opt/homebrew/bin/brew shellenv)" + eval "$(/opt/homebrew/bin/brew shellenv fish)" end if test -n "$HOMEBREW_PREFIX" diff --git a/private_dot_config/private_fish/private_conf.d/private_00-path-golang.fish.tmpl b/private_dot_config/private_fish/private_conf.d/private_00-path-golang.fish.tmpl index 5022707..baefc0d 100644 --- a/private_dot_config/private_fish/private_conf.d/private_00-path-golang.fish.tmpl +++ b/private_dot_config/private_fish/private_conf.d/private_00-path-golang.fish.tmpl @@ -1,6 +1,4 @@ -if test -d "$HOME/.goenv" - set -x GOENV_ROOT $HOME/.goenv -end +set -q GOENV_ROOT; or set -x GOENV_ROOT $HOME/.goenv {{- if (and (eq .chezmoi.os "linux") (or (eq .chezmoi.osRelease.id "debian") (eq .chezmoi.osRelease.id "ubuntu"))) }} if test -n "$GOENV_ROOT" -a -f "$GOENV_ROOT/bin/goenv" @@ -10,8 +8,14 @@ end if type -q goenv && status --is-interactive set -x GOENV_PATH_ORDER front - goenv init - fish | source - fish_add_path -mpP $GOENV_ROOT/shims + if test -d "$GOENV_ROOT/shims" + fish_add_path -mpP $GOENV_ROOT/shims + end + function goenv + functions -e goenv + goenv init - fish | source + goenv $argv + end end if test -d "$HOME/Developer/go" diff --git a/private_dot_config/private_fish/private_conf.d/private_00-path-node.fish.tmpl b/private_dot_config/private_fish/private_conf.d/private_00-path-node.fish.tmpl index 66a1f64..b556423 100644 --- a/private_dot_config/private_fish/private_conf.d/private_00-path-node.fish.tmpl +++ b/private_dot_config/private_fish/private_conf.d/private_00-path-node.fish.tmpl @@ -4,9 +4,7 @@ if test -d "$HOMEBREW_PREFIX/share/npm/bin" end {{- end }} -if test -d "$HOME/.nodenv" - set -x NODENV_ROOT $HOME/.nodenv -end +set -q NODENV_ROOT; or set -x NODENV_ROOT $HOME/.nodenv {{- if (and (eq .chezmoi.os "linux") (or (eq .chezmoi.osRelease.id "debian") (eq .chezmoi.osRelease.id "ubuntu"))) }} if test -n "$NODENV_ROOT" -a -f "$NODENV_ROOT/bin/nodenv" @@ -15,8 +13,15 @@ end {{- end }} if type -q nodenv && status --is-interactive - nodenv init - fish | source + if test -d "$NODENV_ROOT/shims" + fish_add_path -mpP $NODENV_ROOT/shims + end {{- if eq .chezmoi.os "darwin" }} set -x NODE_BUILD_DEFINITIONS "$HOMEBREW_PREFIX/opt/node-build-update-defs/share/node-build" {{- end }} + function nodenv + functions -e nodenv + nodenv init - fish | source + nodenv $argv + end end diff --git a/private_dot_config/private_fish/private_conf.d/private_00-path-ruby.fish.tmpl b/private_dot_config/private_fish/private_conf.d/private_00-path-ruby.fish.tmpl index b07984e..82a0268 100644 --- a/private_dot_config/private_fish/private_conf.d/private_00-path-ruby.fish.tmpl +++ b/private_dot_config/private_fish/private_conf.d/private_00-path-ruby.fish.tmpl @@ -1,6 +1,4 @@ -if test -d "$HOME/.rbenv" - set -x RBENV_ROOT $HOME/.rbenv -end +set -q RBENV_ROOT; or set -x RBENV_ROOT $HOME/.rbenv {{- if (and (eq .chezmoi.os "linux") (or (eq .chezmoi.osRelease.id "debian") (eq .chezmoi.osRelease.id "ubuntu"))) }} if test -n "$RBENV_ROOT" -a -f "$RBENV_ROOT/bin/rbenv" @@ -9,7 +7,14 @@ end {{- end }} if type -q rbenv && status --is-interactive - rbenv init - fish | source - set -l rbenv_commands (rbenv commands) - complete -f -c rbenv -n "not __fish_seen_subcommand_from $rbenv_commands" -a update -d 'Update rbenv and rbenv plugins' + if test -d "$RBENV_ROOT/shims" + fish_add_path -mpP $RBENV_ROOT/shims + end + function rbenv + functions -e rbenv + rbenv init - fish | source + set -l rbenv_commands (rbenv commands) + complete -f -c rbenv -n "not __fish_seen_subcommand_from $rbenv_commands" -a update -d 'Update rbenv and rbenv plugins' + rbenv $argv + end end diff --git a/private_dot_config/private_fish/private_conf.d/private_20-config-op.fish.tmpl b/private_dot_config/private_fish/private_conf.d/private_20-config-op.fish.tmpl index 91db53b..e918b37 100644 --- a/private_dot_config/private_fish/private_conf.d/private_20-config-op.fish.tmpl +++ b/private_dot_config/private_fish/private_conf.d/private_20-config-op.fish.tmpl @@ -2,5 +2,14 @@ if type -q op function op-signin -d "Sign in to 1Password CLI" eval (op signin --account {{ onepasswordRead "op://Private/1Password CLI Account Name/notesPlain" }}) end - op completion fish | source + set -l _op_completion ~/.config/fish/completions/op.fish + set -l _op_bin (command -v op) + if not test -f $_op_completion; or test $_op_bin -nt $_op_completion + set -l _op_tmp (mktemp) + if op completion fish > $_op_tmp + mv $_op_tmp $_op_completion + else + rm -f $_op_tmp + end + end end diff --git a/private_dot_zprofile b/private_dot_zprofile index fb49bc6..0557d24 100644 --- a/private_dot_zprofile +++ b/private_dot_zprofile @@ -1,3 +1,3 @@ # Set PATH, MANPATH, etc., for Homebrew. -eval "$(/opt/homebrew/bin/brew shellenv)" +eval "$(/opt/homebrew/bin/brew shellenv zsh)" export HOMEBREW_CASK_OPTS="--appdir=~/Applications"