@@ -67,6 +67,7 @@ fn enumerate_shells() -> Vec<Shell> {
6767 Box :: new( Zsh ) ,
6868 Box :: new( Fish ) ,
6969 Box :: new( Nu ) ,
70+ Box :: new( Tcsh ) ,
7071 ]
7172}
7273
@@ -318,6 +319,55 @@ impl UnixShell for Nu {
318319 }
319320}
320321
322+ struct Tcsh ;
323+
324+ impl UnixShell for Tcsh {
325+ fn does_exist ( & self , process : & Process ) -> bool {
326+ matches ! ( process. var( "SHELL" ) , Ok ( sh) if sh. contains( "tcsh" ) )
327+ || utils:: find_cmd ( & [ "tcsh" ] , process) . is_some ( )
328+ }
329+
330+ fn rcfiles ( & self , process : & Process ) -> Vec < PathBuf > {
331+ let mut paths = vec ! [ ] ;
332+
333+ if let Some ( home) = process. home_dir ( ) {
334+ paths. push ( home. join ( ".tcshrc" ) ) ;
335+ paths. push ( home. join ( ".cshrc" ) ) ;
336+ }
337+
338+ paths
339+ }
340+
341+ fn update_rcs ( & self , process : & Process ) -> Vec < PathBuf > {
342+ for f in self . rcfiles ( process) {
343+ if f. is_file ( ) {
344+ return vec ! [ f] ;
345+ }
346+ }
347+
348+ // If neither exists, default to ~/.tcshrc
349+ if let Some ( home) = process. home_dir ( ) {
350+ return vec ! [ home. join( ".tcshrc" ) ] ;
351+ }
352+
353+ vec ! [ ]
354+ }
355+
356+ fn env_script ( & self ) -> ShellScript {
357+ ShellScript {
358+ name : "env.tcsh" ,
359+ content : include_str ! ( "env.tcsh" ) ,
360+ }
361+ }
362+
363+ fn source_string ( & self , process : & Process ) -> Result < String > {
364+ Ok ( format ! (
365+ r#"source "{}/env.tcsh""# ,
366+ self . cargo_home_str( process) ?
367+ ) )
368+ }
369+ }
370+
321371pub ( crate ) fn legacy_paths ( process : & Process ) -> impl Iterator < Item = PathBuf > + ' _ {
322372 let zprofiles = Zsh :: zdotdir ( process)
323373 . into_iter ( )
0 commit comments