@@ -77,6 +77,7 @@ fn enumerate_shells() -> Vec<Shell> {
7777 Box :: new( Bash ) ,
7878 Box :: new( Zsh ) ,
7979 Box :: new( Fish ) ,
80+ Box :: new( Nu ) ,
8081 ]
8182}
8283
@@ -255,6 +256,50 @@ impl UnixShell for Fish {
255256 }
256257}
257258
259+ struct Nu ;
260+
261+ impl UnixShell for Nu {
262+ fn does_exist ( & self , process : & Process ) -> bool {
263+ // nu has to either be the shell or be callable for nu setup.
264+ matches ! ( process. var( "SHELL" ) , Ok ( sh) if sh. contains( "nu" ) )
265+ || utils:: find_cmd ( & [ "nu" ] , process) . is_some ( )
266+ }
267+
268+ fn rcfiles ( & self , process : & Process ) -> Vec < PathBuf > {
269+ process
270+ . var ( "XDG_CONFIG_HOME" )
271+ . ok ( )
272+ . and ( process. home_dir ( ) )
273+ . iter ( )
274+ . flat_map ( |path| {
275+ let mut p0 = path. clone ( ) ;
276+ let mut p1 = path. clone ( ) ;
277+ p0. push ( "nushell/env.nu" ) ;
278+ p1. push ( "nushell/config.nu" ) ;
279+ [ p0, p1]
280+ } )
281+ . collect ( )
282+ }
283+
284+ fn update_rcs ( & self , process : & Process ) -> Vec < PathBuf > {
285+ self . rcfiles ( process)
286+ . into_iter ( )
287+ . filter ( |rc| rc. is_file ( ) )
288+ . collect ( )
289+ }
290+
291+ fn env_script ( & self ) -> ShellScript {
292+ ShellScript {
293+ name : "env.nu" ,
294+ content : include_str ! ( "env.nu" ) ,
295+ }
296+ }
297+
298+ fn source_string ( & self , process : & Process ) -> Result < String > {
299+ Ok ( format ! ( r#"source "{}/env.nu""# , cargo_home_str( process) ?) )
300+ }
301+ }
302+
258303pub ( crate ) fn legacy_paths ( process : & Process ) -> impl Iterator < Item = PathBuf > + ' _ {
259304 let zprofiles = Zsh :: zdotdir ( process)
260305 . into_iter ( )
0 commit comments