From a9a28656b78fdce7d0aa92cc25cd8c24cb1c9b61 Mon Sep 17 00:00:00 2001 From: lelgenio Date: Fri, 29 Apr 2022 19:41:04 -0300 Subject: [PATCH] plugins: add option to toggle asdf --- config.yaml | 1 + dotfiles/fish/config.fish | 3 ++ dotfiles/fish/env.fish | 8 ++++-- dotfiles/fish/plugins.fish | 47 ++++++++++++++++++-------------- dotfiles/scripts/_install-rustup | 3 ++ 5 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 dotfiles/scripts/_install-rustup diff --git a/config.yaml b/config.yaml index e292886..8ee2348 100644 --- a/config.yaml +++ b/config.yaml @@ -23,6 +23,7 @@ variables: bar_pos: top tmux: false starship: false + asdf: false user_svdir: $HOME/.config/runit accent_fg: '#ffffff' diff --git a/dotfiles/fish/config.fish b/dotfiles/fish/config.fish index 59884e4..a868632 100644 --- a/dotfiles/fish/config.fish +++ b/dotfiles/fish/config.fish @@ -8,6 +8,9 @@ set -U fish_features stderr-nocaret qmark-noglob regex-easyesc if status is-interactive + {%@@ if asdf @@%} + set asdf + {%@@ endif @@%} source {$__fish_config_dir}/env.fish source {$__fish_config_dir}/wm.fish diff --git a/dotfiles/fish/env.fish b/dotfiles/fish/env.fish index 085c5c6..d7c5828 100644 --- a/dotfiles/fish/env.fish +++ b/dotfiles/fish/env.fish @@ -17,11 +17,13 @@ set -x XDG_DATA_DIRS "$XDG_DATA_DIRS:$HOME/.local/share" set -x XDG_CONFIG_HOME "$HOME/.config/" -set __cargo_asdf_bin ~/.asdf/installs/rust/*/bin/ -set __yarn_asdf_bin ~/.config/yarn/global/node_modules/.bin/ +if set -q asdf + set __cargo_asdf_bin ~/.asdf/installs/rust/*/bin/ + set __yarn_asdf_bin ~/.config/yarn/global/node_modules/.bin/ +end for i in ~/.local/bin $__cargo_asdf_bin $__yarn_asdf_bin ~/.yarn/bin ~/.factorio/bin/* - test -d "$i";and fish_add_path "$i" + test -d "$i";and fish_add_path --global "$i" end # needed for tmux diff --git a/dotfiles/fish/plugins.fish b/dotfiles/fish/plugins.fish index 0e44510..1c6a015 100644 --- a/dotfiles/fish/plugins.fish +++ b/dotfiles/fish/plugins.fish @@ -8,7 +8,9 @@ if not functions -q fundle and test "$USER" != root eval (curl -sfL https://git.io/fundle-install) end -# fundle plugin 'FabioAntunes/fish-nvm' +if not set -q asdf + fundle plugin 'FabioAntunes/fish-nvm' +end fundle plugin 'edc/bass' fundle init @@ -25,37 +27,42 @@ command -qs direnv && # asdf Version manager ################################################## -if not test -d ~/.asdf - and test "$USER" != root - git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.9.0 - mkdir -p ~/.config/fish/completions - and ln -s ~/.asdf/completions/asdf.fish ~/.config/fish/completions +if set -q asdf + if not test -d ~/.asdf + and test "$USER" != root + git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.9.0 + mkdir -p ~/.config/fish/completions + and ln -s ~/.asdf/completions/asdf.fish ~/.config/fish/completions - source ~/.asdf/asdf.fish + source ~/.asdf/asdf.fish - asdf plugin add nodejs - asdf install nodejs 12.13.1 - asdf install nodejs latest - asdf global nodejs latest + asdf plugin add nodejs + asdf install nodejs 12.13.1 + asdf install nodejs latest + asdf global nodejs latest - asdf plugin-add yarn - asdf install yarn latest - asdf global yarn latest + asdf plugin-add yarn + asdf install yarn latest + asdf global yarn latest - asdf plugin add rust - asdf install rust nightly - asdf global rust nightly + asdf plugin add rust + asdf install rust nightly + asdf global rust nightly + end + + test -f ~/.asdf/asdf.fish + and source ~/.asdf/asdf.fish end -test -f ~/.asdf/asdf.fish -and source ~/.asdf/asdf.fish - ################################################## # Rust tools ################################################## +command -qs rustup +or _install-rustup &> /dev/null & + command -qs sccache or _install-sccache &> /dev/null & # set -x RUSTC_WRAPPER sccache diff --git a/dotfiles/scripts/_install-rustup b/dotfiles/scripts/_install-rustup new file mode 100644 index 0000000..424754c --- /dev/null +++ b/dotfiles/scripts/_install-rustup @@ -0,0 +1,3 @@ +#!/bin/sh + +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh