Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ some limited ability to make the manipulations dynamic.

![shadowenv in action](https://burkelibbey.s3.amazonaws.com/shadowenv.gif)

In order to use shadowenv, add a line to your shell profile (`.zshrc`, `.bash_profile`, or
`config.fish`) reading:
In order to use shadowenv, add a line to your shell profile (`.zshrc`, `.bash_profile`,
`config.fish`, or `config.nu`) reading:

```bash
eval "$(shadowenv init bash)" # for bash
eval "$(shadowenv init zsh)" # for zsh
shadowenv init fish | source # for fish
# for nushell, paste the output of `shadowenv init nushell` into config.nu
```

With this code loaded, upon entering a directory containing a `.shadowenv.d` directory,
Expand Down
20 changes: 20 additions & 0 deletions sh/shadowenv.nushell.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
$env.config = ($env.config | upsert hooks.env_change.PWD { |config|
let existing = $config | get -o hooks.env_change.PWD | default []
$existing | append {||
mut flags = ["--json"]

if ($env.__shadowenv_force_run? | default false) {
hide-env -i __shadowenv_force_run
$flags = ($flags | append "--force")
}

let result = @SELF@ hook ...$flags | complete
if $result.exit_code != 0 {
return
}

$result.stdout | from json | get -o exported | default {} | load-env
}
})

$env.__shadowenv_force_run = true
3 changes: 3 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ pub enum InitCmd {

/// Prints a script which can be eval'd by fish to set up shadowenv.
Fish,

/// Prints a script which can be eval'd by nushell to set up shadowenv.
Nushell,
}

/// Options shared by all init subcommands
Expand Down
5 changes: 5 additions & 0 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ pub fn run(cmd: InitCmd) {
include_bytes!("../sh/shadowenv.fish.in"),
true, // Fish doesn't use hookbook
),
Nushell => print_script(
pb,
include_bytes!("../sh/shadowenv.nushell.in"),
true, // Nushell doesn't use hookbook
),
};
}

Expand Down
Loading