mirror of
https://github.com/jbranchaud/til
synced 2026-01-06 16:48:01 +00:00
Add Interactively Switch asdf Package Versions as a Unix TIL
This commit is contained in:
30
unix/interactively-switch-asdf-package-versions.md
Normal file
30
unix/interactively-switch-asdf-package-versions.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Interactively Switch asdf Package Versions
|
||||
|
||||
I use [`asdf`](https://asdf-vm.com/) to manage versions for a couple different
|
||||
languages that I use across projects. I mostly use it for `node` and `ruby`.
|
||||
|
||||
When setting up a new project or needing to set the version for an existing
|
||||
one, I run some version of:
|
||||
|
||||
```bash
|
||||
$ asdf local nodejs <some-version-here>
|
||||
```
|
||||
|
||||
But before I can do that, I need to figure out what versions I have installed
|
||||
(`asdf list nodejs`), so I end up running two commands and having to remember
|
||||
the nuances of the sub-commands for each.
|
||||
|
||||
I decided to make this small interaction easier by making it _interactive_ with
|
||||
[`fzf`](https://github.com/junegunn/fzf).
|
||||
|
||||
```bash
|
||||
asdf local nodejs $(
|
||||
asdf list nodejs | fzf | xargs | sed 's/^\*//'
|
||||
)
|
||||
```
|
||||
|
||||
This grabs the list of installed `nodejs` versions, turns it into an
|
||||
interactive list with `fzf`, and then passes my selection to `asdf local` to
|
||||
set that version.
|
||||
|
||||
I can substitute `ruby` for `nodejs` to do the same thing for Ruby versions.
|
||||
Reference in New Issue
Block a user