@@ -71,7 +71,12 @@ pub(crate) fn cargo_home_str() -> Result<Cow<'static, str>> {
7171// TODO?: Make a decision on Ion Shell, Power Shell, Nushell
7272// Cross-platform non-POSIX shells have not been assessed for integration yet
7373fn enumerate_shells ( ) -> Vec < Shell > {
74- vec ! [ Box :: new( Posix ) , Box :: new( Bash ) , Box :: new( Zsh ) ]
74+ vec ! [
75+ Box :: new( Posix ) ,
76+ Box :: new( Bash ) ,
77+ Box :: new( Zsh ) ,
78+ Box :: new( Fish ) ,
79+ ]
7580}
7681
7782pub ( crate ) fn get_available_shells ( ) -> impl Iterator < Item = Shell > {
@@ -201,6 +206,46 @@ impl UnixShell for Zsh {
201206 }
202207}
203208
209+ struct Fish ;
210+
211+ impl UnixShell for Fish {
212+ fn does_exist ( & self ) -> bool {
213+ // fish has to either be the shell or be callable for fish setup.
214+ matches ! ( process( ) . var( "SHELL" ) , Ok ( sh) if sh. contains( "fish" ) )
215+ || matches ! ( utils:: find_cmd( & [ "fish" ] ) , Some ( _) )
216+ }
217+
218+ // > "$XDG_CONFIG_HOME/fish/conf.d" (or "~/.config/fish/conf.d" if that variable is unset) for the user
219+ // from <https://github.com/fish-shell/fish-shell/issues/3170#issuecomment-228311857>
220+ fn rcfiles ( & self ) -> Vec < PathBuf > {
221+ let p0 = process ( ) . var ( "XDG_CONFIG_HOME" ) . ok ( ) . map ( |p| {
222+ let mut path = PathBuf :: from ( p) ;
223+ path. push ( "fish/config.d/rustup.fish" ) ;
224+ path
225+ } ) ;
226+
227+ let p1 = utils:: home_dir ( ) . map ( |mut path| {
228+ path. push ( ".config/fish/config.d/rustup.fish" ) ;
229+ path
230+ } ) ;
231+
232+ p0. into_iter ( ) . chain ( p1) . collect ( )
233+ }
234+
235+ fn update_rcs ( & self ) -> Vec < PathBuf > {
236+ if let Ok ( home) = process ( ) . var ( "XDG_CONFIG_HOME" ) {
237+ let mut path = PathBuf :: from ( home) ;
238+ path. push ( "fish/config.d/rustup.fish" ) ;
239+ vec ! [ path]
240+ } else if let Some ( mut path) = utils:: home_dir ( ) {
241+ path. push ( ".config/fish/config.d/rustup.fish" ) ;
242+ vec ! [ path]
243+ } else {
244+ Vec :: new ( )
245+ }
246+ }
247+ }
248+
204249pub ( crate ) fn legacy_paths ( ) -> impl Iterator < Item = PathBuf > {
205250 let zprofiles = Zsh :: zdotdir ( )
206251 . into_iter ( )
0 commit comments