Browse Source

Add fish shell setup to `env` command and README (#10)

introduced a `--fish` flag to the env command, so fish users can add this line to their `config.fish` to set up fnm:

```fish
eval (fnm env --fish)
```
remotes/origin/add-simple-redirecting-site
Spencer Elliott 6 years ago committed by Gal Schlezinger
parent
commit
1d9018b05e
  1. 6
      README.md
  2. 8
      executable/Env.re
  3. 12
      executable/FnmApp.re

6
README.md

@ -25,6 +25,12 @@
eval `fnm env` eval `fnm env`
``` ```
If you are using [fish shell](https://fishshell.com/), add this line to your `config.fish` file:
```fish
eval (fnm env --fish)
```
## Future Plans ## Future Plans
- [ ] Add a simpler way of installing it (`curl | bash`?) - [ ] Add a simpler way of installing it (`curl | bash`?)
- [ ] Feature: make versions complete the latest: `10` would infer the latest minor and patch versions of node 10. `10.1` would infer the latest patch version of node 10.1 - [ ] Feature: make versions complete the latest: `10` would infer the latest minor and patch versions of node 10. `10.1` would infer the latest patch version of node 10.1

8
executable/Env.re

@ -1,9 +1,15 @@
open Fnm; open Fnm;
let run = () => { let run = isFishShell => {
if (isFishShell) {
Console.log(
Printf.sprintf("set PATH %s/bin $PATH", Directories.currentVersion),
);
} else {
Console.log( Console.log(
Printf.sprintf("export PATH=%s/bin:$PATH", Directories.currentVersion), Printf.sprintf("export PATH=%s/bin:$PATH", Directories.currentVersion),
); );
}
Lwt.return(); Lwt.return();
}; };

12
executable/FnmApp.re

@ -5,7 +5,7 @@ module Commands = {
let listRemote = () => Lwt_main.run(ListRemote.run()); let listRemote = () => Lwt_main.run(ListRemote.run());
let listLocal = () => Lwt_main.run(ListLocal.run()); let listLocal = () => Lwt_main.run(ListLocal.run());
let install = version => Lwt_main.run(Install.run(~version)); let install = version => Lwt_main.run(Install.run(~version));
let env = () => Lwt_main.run(Env.run()); let env = isFishShell => Lwt_main.run(Env.run(isFishShell));
}; };
open Cmdliner; open Cmdliner;
@ -88,8 +88,16 @@ let env = {
let doc = "Show env configurations"; let doc = "Show env configurations";
let sdocs = Manpage.s_common_options; let sdocs = Manpage.s_common_options;
let man = help_secs; let man = help_secs;
let isFishShell = {
let doc = "Output an env configuration for fish shell.";
Arg.(
value & flag & info(["fish"], ~doc)
);
};
( (
Term.(const(Commands.env) $ const()), Term.(const(Commands.env) $ isFishShell),
Term.info("env", ~version, ~doc, ~exits=Term.default_exits, ~man, ~sdocs), Term.info("env", ~version, ~doc, ~exits=Term.default_exits, ~man, ~sdocs),
); );
}; };

Loading…
Cancel
Save