@@ -186,6 +186,16 @@ pub fn build_interactive_shell_command(
186186 ] ,
187187 vars : vec ! [ shell_message] ,
188188 } ) ,
189+ Shell :: Nushell ( nu) => Ok ( Command {
190+ executable : nu. into ( ) ,
191+ args : vec ! [
192+ "--env-config" . into( ) ,
193+ rt. config. nu_env_file. as_os_str( ) . to_owned( ) ,
194+ "--config" . into( ) ,
195+ rt. config. nu_config_file. as_os_str( ) . to_owned( ) ,
196+ ] ,
197+ vars : vec ! [ shell_message] ,
198+ } ) ,
189199 #[ cfg( windows) ]
190200 Shell :: Powershell ( ps1) => Ok ( Command {
191201 executable : ps1. into ( ) ,
@@ -221,6 +231,26 @@ where
221231 let startup_file = match shell. kind ( ) {
222232 ShellKind :: Bash => & runtime. config . sh_startup_file ,
223233 ShellKind :: Tcsh => & runtime. config . csh_startup_file ,
234+ ShellKind :: Nushell => {
235+ let mut cmd = command. into ( ) ;
236+ for arg in args. into_iter ( ) . map ( Into :: into) {
237+ cmd. push ( " " ) ;
238+ cmd. push ( arg) ;
239+ }
240+ let args = vec ! [
241+ "--env-config" . into( ) ,
242+ runtime. config. nu_env_file. as_os_str( ) . to_owned( ) ,
243+ "--config" . into( ) ,
244+ runtime. config. nu_config_file. as_os_str( ) . to_owned( ) ,
245+ "-c" . into( ) ,
246+ cmd,
247+ ] ;
248+ return Ok ( Command {
249+ executable : shell. executable ( ) . into ( ) ,
250+ args,
251+ vars : vec ! [ ] ,
252+ } ) ;
253+ }
224254 ShellKind :: Powershell => {
225255 let mut cmd = command. into ( ) ;
226256 for arg in args. into_iter ( ) . map ( Into :: into) {
@@ -244,7 +274,6 @@ where
244274
245275 let mut shell_args = vec ! [ startup_file. into( ) , command. into( ) ] ;
246276 shell_args. extend ( args. into_iter ( ) . map ( Into :: into) ) ;
247-
248277 Ok ( Command {
249278 executable : shell. executable ( ) . into ( ) ,
250279 args : shell_args,
@@ -385,13 +414,15 @@ pub enum ShellKind {
385414 Bash ,
386415 Tcsh ,
387416 Powershell ,
417+ Nushell ,
388418}
389419
390420impl AsRef < str > for ShellKind {
391421 fn as_ref ( & self ) -> & str {
392422 match self {
393423 Self :: Bash => "bash" ,
394424 Self :: Tcsh => "tcsh" ,
425+ Self :: Nushell => "nu" ,
395426 Self :: Powershell => "powershell.exe" ,
396427 }
397428 }
@@ -404,6 +435,7 @@ pub enum Shell {
404435 Bash ( PathBuf ) ,
405436 #[ cfg( unix) ]
406437 Tcsh ( PathBuf ) ,
438+ Nushell ( PathBuf ) ,
407439 #[ cfg( windows) ]
408440 Powershell ( PathBuf ) ,
409441}
@@ -415,6 +447,7 @@ impl Shell {
415447 Self :: Bash ( _) => ShellKind :: Bash ,
416448 #[ cfg( unix) ]
417449 Self :: Tcsh ( _) => ShellKind :: Tcsh ,
450+ Self :: Nushell ( _) => ShellKind :: Nushell ,
418451 #[ cfg( windows) ]
419452 Self :: Powershell ( _) => ShellKind :: Powershell ,
420453 }
@@ -427,6 +460,7 @@ impl Shell {
427460 Self :: Bash ( p) => p,
428461 #[ cfg( unix) ]
429462 Self :: Tcsh ( p) => p,
463+ Self :: Nushell ( p) => p,
430464 #[ cfg( windows) ]
431465 Self :: Powershell ( p) => p,
432466 }
@@ -442,6 +476,7 @@ impl Shell {
442476 Some ( n) if n == ShellKind :: Bash . as_ref ( ) => Ok ( Self :: Bash ( path. to_owned ( ) ) ) ,
443477 #[ cfg( unix) ]
444478 Some ( n) if n == ShellKind :: Tcsh . as_ref ( ) => Ok ( Self :: Tcsh ( path. to_owned ( ) ) ) ,
479+ Some ( n) if n == ShellKind :: Nushell . as_ref ( ) => Ok ( Self :: Nushell ( path. to_owned ( ) ) ) ,
445480 #[ cfg( windows) ]
446481 Some ( n) if n == ShellKind :: Powershell . as_ref ( ) => Ok ( Self :: Powershell ( path. to_owned ( ) ) ) ,
447482 Some ( _) => Err ( Error :: new ( format ! ( "Unsupported shell: {path:?}" ) ) ) ,
@@ -477,7 +512,12 @@ impl Shell {
477512 }
478513 }
479514
480- for kind in & [ ShellKind :: Bash , ShellKind :: Tcsh , ShellKind :: Powershell ] {
515+ for kind in & [
516+ ShellKind :: Bash ,
517+ ShellKind :: Tcsh ,
518+ ShellKind :: Powershell ,
519+ ShellKind :: Nushell ,
520+ ] {
481521 if let Some ( path) = which ( kind) {
482522 if let Ok ( shell) = Shell :: from_path ( path) {
483523 return Ok ( shell) ;
0 commit comments