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. 14
      executable/Env.re
  3. 12
      executable/FnmApp.re

6
README.md

@ -24,6 +24,12 @@ @@ -24,6 +24,12 @@
```bash
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
- [ ] Add a simpler way of installing it (`curl | bash`?)

14
executable/Env.re

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

12
executable/FnmApp.re

@ -5,7 +5,7 @@ module Commands = { @@ -5,7 +5,7 @@ module Commands = {
let listRemote = () => Lwt_main.run(ListRemote.run());
let listLocal = () => Lwt_main.run(ListLocal.run());
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;
@ -88,8 +88,16 @@ let env = { @@ -88,8 +88,16 @@ let env = {
let doc = "Show env configurations";
let sdocs = Manpage.s_common_options;
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),
);
};

Loading…
Cancel
Save