mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Interactively Switch asdf Package Versions as a Unix TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1383 TILs and counting..._
|
||||
_1384 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -1351,6 +1351,7 @@ _1383 TILs and counting..._
|
||||
- [Ignore A Directory During ripgrep Search](unix/ignore-a-directory-during-ripgrep-search.md)
|
||||
- [Ignore The Alias When Running A Command](unix/ignore-the-alias-when-running-a-command.md)
|
||||
- [Interactively Browse Available Node Versions](unix/interactively-browse-availabile-node-versions.md)
|
||||
- [Interactively Switch asdf Package Versions](unix/interactively-switch-asdf-package-versions.md)
|
||||
- [Jump To The Ends Of Your Shell History](unix/jump-to-the-ends-of-your-shell-history.md)
|
||||
- [Kill Everything Running On A Certain Port](unix/kill-everything-running-on-a-certain-port.md)
|
||||
- [Killing A Frozen SSH Session](unix/killing-a-frozen-ssh-session.md)
|
||||
|
||||
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