Fish: Difference between revisions

Pigs (talk | contribs)
Reorganized and polished content, added information about installing fish for those not using home manager
Tags: Mobile edit Mobile web edit Advanced mobile edit
Setting fish as default shell: Added a method for Gnome Console
 
(5 intermediate revisions by 4 users not shown)
Line 20: Line 20:
Replace <code>myuser</code> with the appropriate username.
Replace <code>myuser</code> with the appropriate username.


{{warning| [https://fishshell.com/docs/current/index.html#default-shell As noted in the fish documentation], using fish as your *login* shell (via <code>/etc/passwd</code>) may cause issues, particularly for the <code>root</code> user, because fish is not POSIX compliant. While using fish as the default shell for regular users is generaly safe, caution is still advised. See the [[#section Setting fish as default shell|Setting fish as default shell]] section for recommendations and mitigations.}}
{{warning| [https://fishshell.com/docs/current/index.html#default-shell As noted in the fish documentation], using fish as your *login* shell (via <code>/etc/passwd</code>) may cause issues, particularly for the <code>root</code> user, because fish is not POSIX compliant. While using fish as the default shell for regular users is generaly safe, caution is still advised. See [[#Setting fish as default shell]] for recommendations and mitigations.}}


=== Home Manager ===
=== Home Manager ===
Line 54: Line 54:
{{file|/etc/nixos/configuration.nix|nix|
{{file|/etc/nixos/configuration.nix|nix|
<nowiki>
<nowiki>
environment.systemPackages = with pkgs; [
  programs.fish = {
  ...
    enable = true;
  fishPlugins.done
    interactiveShellInit = ''
  fishPlugins.fzf-fish
      set fish_greeting # Disable greeting
  fishPlugins.forgit
    '';
  fishPlugins.hydro
  };
  fzf
 
  fishPlugins.grc
  environment.systemPackages = with pkgs; [
  grc
    ...
];
    fishPlugins.done
    fishPlugins.fzf-fish
    fishPlugins.forgit
    fishPlugins.hydro
    fzf
    fishPlugins.grc
    grc
    # Use 3rd-party fish plugins manually packaged.
    (pkgs.callPackage ../fish-colored-man.nix {buildFishPlugin = pkgs.fishPlugins.buildFishPlugin; } )
  ];
</nowiki>
|name=/etc/nixos/configuration.nix|lang=nix}}
Example of a file containing the definition of a fish plugin.
{{file|/etc/nixos/fish-colored-man.nix|nix|
<nowiki>
{
  lib,
  buildFishPlugin,
  fetchFromGitHub,
}:
buildFishPlugin {
  pname = "fish-colored-man";
  version = "0-unstable-20240416";
  src = fetchFromGitHub {
    owner = "decors";
    repo = "fish-colored-man";
    rev = "1ad8fff696d48c8bf173aa98f9dff39d7916de0e";
    hash = "sha256-uoZ4eSFbZlsRfISIkJQp24qPUNqxeD0JbRb/gVdRYlA=";
  };
}
</nowiki>
</nowiki>
}}
}}
Line 123: Line 152:
</nowiki>
</nowiki>
}}
}}
'''Setting fish as default for Gnome Console'''
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]].
==== Disable man page generation ====
Some users suffer from slow build due to fish enabling `documentation.man.generateCaches`. You may force false.
documentation.man.generateCaches = false'';''


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