Skip to content

Instantly share code, notes, and snippets.

@sascha-wolf
Created July 16, 2019 14:50
Show Gist options
  • Save sascha-wolf/02a05356677bcb4db3931d5cca3e825f to your computer and use it in GitHub Desktop.
Save sascha-wolf/02a05356677bcb4db3931d5cca3e825f to your computer and use it in GitHub Desktop.
Fuzzy version manager commands for asdf
#!/bin/sh
# Install one or more versions of specified language
# e.g. `vmi rust` # => fzf multimode, tab to mark, enter to install
# if no plugin is supplied (e.g. `vmi<CR>`), fzf will list them for you
# Mnemonic [V]ersion [M]anager [I]nstall
version-manager::install() {
local lang=${1}
if [[ ! $lang ]]; then
lang=$(asdf plugin-list | fzf)
fi
if [[ $lang ]]; then
local versions=$(asdf list-all $lang | fzf -m --tac)
if [[ $versions ]]; then
for version in $(echo $versions);
do; asdf install $lang $version; done;
fi
fi
}
# Remove one or more versions of specified language
# e.g. `vmi rust` # => fzf multimode, tab to mark, enter to remove
# if no plugin is supplied (e.g. `vmi<CR>`), fzf will list them for you
# Mnemonic [V]ersion [M]anager [C]lean
version-manager::clean() {
local lang=${1}
if [[ ! $lang ]]; then
lang=$(asdf plugin-list | fzf)
fi
if [[ $lang ]]; then
local versions=$(asdf list $lang | fzf -m)
if [[ $versions ]]; then
for version in $(echo $versions);
do; asdf uninstall $lang $version; done;
fi
fi
}
alias vmi='version-manager::install'
alias vmc='version-manager::clear'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment