DEV Community

Cover image for Using FNM with Nushell
Vaibhav Dwivedi
Vaibhav Dwivedi

Posted on

Using FNM with Nushell

A new type of shell

Nushell is a cross-platform shell with a built-in powerful plugin system, but where the Nushell shines is in the way it displays the output.

Output of ls command

Outputs are in table format and can be filtered and sorted.

Output of ls command, filtered to display only the directories sorted by recently modified

The output of ls command, filtered to display only the directories sorted by recently modified.


FNM - Fast Node Manager

FNM describes itself as a fast and simple Node.JS version manager, built in Rust.

Install and configure FNM

  • Open the terminal and switch to Nushell.

  • Install FNM using the following command.

curl -fsSL https://fnm.vercel.app/install | bash
Enter fullscreen mode Exit fullscreen mode
  • Find the Nushell config by running the following command.
$nu.config-path
Enter fullscreen mode Exit fullscreen mode

$nu.config-path output

  • Open the config file in any text editor like vim and add the following lines at the end.
let-env PATH = ($env.PATH | prepend "/home/vaibhavdn/.fnm")
Enter fullscreen mode Exit fullscreen mode

Here we are adding the location where the FNM was installed to the PATH environment.

load-env (fnm env --shell bash | lines | str replace 'export ' '' | str replace -a '"' '' | split column = | rename name value | where name != "FNM_ARCH" && name != "PATH" | reduce -f {} {|it, acc| $acc | upsert $it.name $it.value })
Enter fullscreen mode Exit fullscreen mode

Then we load the FNM_MULTISHELL_PATH

The output of the command used to load FNM_MULTISHELL_PATH
Loading FNM multi-shell path

let-env PATH = ($env.PATH | prepend $"($env.FNM_MULTISHELL_PATH)/bin")
Enter fullscreen mode Exit fullscreen mode

Finally we add the loaded FNM_MULTISHELL_PATH to the PATH environment.

Save the file and restart the terminal.
FNM is ready to be used now!!


References

  1. https://www.nushell.sh/book/
  2. https://github.com/Schniz/fnm
  3. https://github.com/Schniz/fnm/issues/463

Discussion (0)