File tree Expand file tree Collapse file tree 5 files changed +64
-3
lines changed Expand file tree Collapse file tree 5 files changed +64
-3
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,33 @@ if command -v nix-your-shell > /dev/null; then
5555fi
5656```
5757
58+ ### Nushell
59+
60+ > ** Note**
61+ > Nushell requires sourced configuration files to exist before ` nu ` is started.
62+
63+ Add to your ` ~/.config/nushell/config.nu ` :
64+
65+ ``` nu
66+ source nix-your-shell.nu
67+ ```
68+
69+ To generate ` nix-your-shell.nu ` file:
70+
71+ Either manually generate it:
72+
73+ ``` sh
74+ nix-your-shell nu | save nix-your-shell.nu
75+ ```
76+
77+ Or populate its content through flakes and home-manager:
78+
79+ ``` nix
80+ { config, pkgs, ... }: {
81+ home.file."${config.xdg.configHome}/nushell/nix-your-shell.nu".source = pkgs.nix-your-shell.generate-config "nu";
82+ }
83+ ```
84+
5885## Installation
5986
6087You can either install ` nix-your-shell ` from this repository or from ` nixpkgs ` .
Original file line number Diff line number Diff line change 1+ # If you see this output, you probably forgot to pipe it into `source`:
2+ # nix-your-shell nu | save nix-your-shell.nu
3+
4+ def call-wrapper (command : string , args : list <string >) {
5+ if not (which nix-your-shell | is-empty ) {
6+ run-external nix-your-shell $command - - $args
7+ } else {
8+ run-external $command $args
9+ }
10+ }
11+
12+ extern nix-shell (...args) {
13+ call-wrapper nix-shell $args
14+ }
15+
16+ extern nix (...args) {
17+ call-wrapper nix $args
18+ }
Original file line number Diff line number Diff line change 7070 cargo fmt --check && echo "\`cargo fmt\` is OK"
7171 cargo clippy -- --deny warnings && echo "\`cargo clippy\` is OK"
7272 '' ;
73+ }
74+ //
75+ {
76+ generate-config = shell : final . runCommand "nix-your-shell-config" { } ''
77+ ${ final . nix-your-shell } /bin/nix-your-shell ${ shell } >> $out
78+ '' ;
7379 } ;
7480 }
7581 ) ;
Original file line number Diff line number Diff line change @@ -87,11 +87,15 @@ fn main() -> eyre::Result<()> {
8787 include_str ! ( "../data/env.fish" )
8888 }
8989
90+ ShellKind :: Nushell => {
91+ include_str ! ( "../data/env.nu" )
92+ }
93+
9094 ShellKind :: Other ( shell) => {
9195 return Err ( eyre ! (
9296 "I don't know how to generate a shell environment for `{shell}`"
9397 ) )
94- . note ( "Supported shells are: `zsh`, `fish`, and `bash`" )
98+ . note ( "Supported shells are: `zsh`, `fish`, `nushell` and `bash`" )
9599 }
96100 }
97101 . to_owned ( ) ;
@@ -110,8 +114,7 @@ fn main() -> eyre::Result<()> {
110114 let current_exe =
111115 current_exe ( ) . wrap_err ( "Unable to determine absolute path of `nix-your-shell`" ) ?;
112116 if args. absolute || !executable_is_on_path ( & current_exe) ? {
113- shell_code =
114- shell_code. replace ( "nix-your-shell" , & format ! ( "{current_exe} --absolute" ) ) ;
117+ shell_code = shell_code. replace ( "nix-your-shell" , current_exe. as_str ( ) ) ;
115118 }
116119
117120 println ! ( "{shell_code}" ) ;
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ pub enum ShellKind {
2020 /// <https://www.gnu.org/software/bash/>
2121 Bash ,
2222
23+ /// The `nu` shell
24+ /// <https://www.nushell.sh/>
25+ Nushell ,
26+
2327 /// A different shell.
2428 Other ( String ) ,
2529}
@@ -30,6 +34,7 @@ impl Display for ShellKind {
3034 ShellKind :: Zsh => write ! ( f, "zsh" ) ,
3135 ShellKind :: Fish => write ! ( f, "fish" ) ,
3236 ShellKind :: Bash => write ! ( f, "bash" ) ,
37+ ShellKind :: Nushell => write ! ( f, "nu" ) ,
3338 ShellKind :: Other ( shell) => write ! ( f, "{shell}" ) ,
3439 }
3540 }
@@ -57,6 +62,8 @@ impl Shell {
5762 ShellKind :: Fish
5863 } else if file_name. starts_with ( "bash" ) {
5964 ShellKind :: Bash
65+ } else if file_name. starts_with ( "nu" ) {
66+ ShellKind :: Nushell
6067 } else {
6168 ShellKind :: Other ( file_name. to_string ( ) )
6269 } ;
You can’t perform that action at this time.
0 commit comments