Fish: Difference between revisions

QuBe (talk | contribs)
Move "Disable man page generation" to its own sub-section. Was a sub-section of "Setting fish as default shell" which is unrelated.
Sapi (talk | contribs)
m Replaced attr def with a inherit, does the same thing.
 
(4 intermediate revisions by 2 users not shown)
Line 71: Line 71:
     grc
     grc
     # Use 3rd-party fish plugins manually packaged.
     # Use 3rd-party fish plugins manually packaged.
     (pkgs.callPackage ../fish-colored-man.nix {buildFishPlugin = pkgs.fishPlugins.buildFishPlugin; } )
     (pkgs.callPackage ../fish-colored-man.nix { inherit (pkgs.fishPlugins) buildFishPlugin; } )
   ];
   ];
</nowiki>
</nowiki>
Line 133: Line 133:
== Tips and tricks ==
== Tips and tricks ==


=== Setting fish as default shell ===
=== Setting fish as the default shell ===
It is possible to set fish as the interactive non-login shell for your terminal emulator without setting it as the login shell (the one in <code>/etc/passwd</code>).


As this is usually a user-wise setting, to configure the terminal emulator you will need to either modify its config file, or use [[Home Manager]].
==== Setting fish as default for Kitty ====
Using [[Home Manager]]:
{{File|3=programs.kitty = {
    enable = true;
    shellIntegration.enableFishIntegration = true;
    settings = {
      shell = "fish";
    };
  };|name=home.nix|lang=nix}}
Note: the <code>shellIntegration.enableFishIntegration = true;</code> is not required for setting fish as default, but provides other useful quality-of-life features, see https://sw.kovidgoyal.net/kitty/shell-integration/.
For use without home-manager, refer to https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.shell and https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.shell_integration.
'''Setting fish as default for Gnome Console'''
Using [[Home-manager|Home Manager]]:
{{File|3=home-manager.users.myuser = {
    dconf = {
        enable = true;
        settings."org/gnome/Console" = {
            shell = [ "fish" ];
        };
    };
};|name=home.nix|lang=nix}}
=== Setting fish as the login shell ===
Using fish as the the login shell can cause compatibility issues. For example, certain recovery environments such as systemd's emergency mode to be completely broken when fish was set as the login shell. ArchWiki presents an [https://wiki.archlinux.org/title/Fish#Modify_.bashrc_to_drop_into_fish alternative solution], keeping bash as the system shell but having it exec fish when run interactively.
Using fish as the the login shell can cause compatibility issues. For example, certain recovery environments such as systemd's emergency mode to be completely broken when fish was set as the login shell. ArchWiki presents an [https://wiki.archlinux.org/title/Fish#Modify_.bashrc_to_drop_into_fish alternative solution], keeping bash as the system shell but having it exec fish when run interactively.
Do note that even the following code is not full-proof, and should only be used with a thorough understanding. Prefer [[Fish#Setting fish as default shell|Setting fish as the default shell]].


Here is one solution, which launches fish unless the parent process is already fish:
Here is one solution, which launches fish unless the parent process is already fish:
Line 155: Line 187:
For a more detailed explanation, please see the [https://wiki.archlinux.org/title/Fish#Modify_.bashrc_to_drop_into_fish aforementioned ArchWiki page].
For a more detailed explanation, please see the [https://wiki.archlinux.org/title/Fish#Modify_.bashrc_to_drop_into_fish aforementioned ArchWiki page].


'''Setting fish as default for Gnome Console'''
If you are using Lix, you can change the grep condition to <code>"fish\|nix-shell"</code> so the <code>nix-shell</code> command still works, this is necessary since Lix forks before spawning the shell process so the parent process ends up being nix-shell and not fish.<ref>https://git.lix.systems/lix-project/lix/issues/1131#issuecomment-18341</ref>
 
It is possible to set fish as the interactive non-login shell for Gnome Console without setting fish as the login shell (the login shell in /etc/passwd for your user will not be fish).
 
{{File|3=home-manager.users.myuser = {
    dconf = {
        enable = true;
        settings."org/gnome/Console" = {
            shell = [ "fish" ];
        };
    };
};|name=home.nix|lang=nix}}
 


If you still want to set fish as the login shell, see [[Command Shell#Changing the default shell]].
↵If you still want to set fish as the login shell, see [[Command Shell#Changing the default shell]].


==== Running fish interactively with zsh as system shell on darwin ====
==== Running fish interactively with zsh as system shell on darwin ====