Fish: Difference between revisions
PowerUser64 (talk | contribs) m Changed a space that was a unicode space into a non-unicode space. This makes the code snippet not break when you try to run it. |
→Setting fish as default shell: remove {{expansion}} as i've implemented the changes. If this change has broken something for you, please discuss at Talk:Fish#Suggested_bashrc_in_Fish#Setting_fish_as_default_shell_needs_revision |
||
| (9 intermediate revisions by 5 users not shown) | |||
| Line 1: | Line 1: | ||
{{DISPLAYTITLE:fish}} | {{DISPLAYTITLE:fish}} | ||
fish, the [ | fish, the [https://fishshell.com/ Friendly Interactive Shell], is a [[Command Shell|command shell]] designed around user-friendliness. | ||
== Installation == | == Installation == | ||
| Line 135: | Line 135: | ||
=== Setting fish as default shell === | === Setting fish as default 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. | 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. | ||
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 143: | Line 143: | ||
programs.bash = { | programs.bash = { | ||
interactiveShellInit = '' | interactiveShellInit = '' | ||
if | # "check if parent process is not fish" && "make nested shells work properly" | ||
if grep -qv fish /proc/$PPID/comm && [[ $SHLVL == [12] ]]; then | |||
# set $SHELL for better integration with programs like nix shell, tmux, etc. | |||
SHELL=${pkgs.fish}/bin/fish exec fish | |||
fi | fi | ||
''; | ''; | ||
}; | }; | ||
</nowiki> | </nowiki> | ||
}} | |||
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''' | '''Setting fish as default for Gnome Console''' | ||
| Line 160: | Line 162: | ||
dconf = { | dconf = { | ||
enable = true; | enable = true; | ||
settings."org/gnome/ | settings."org/gnome/Console" = { | ||
shell = [ " | shell = [ "fish" ]; | ||
}; | }; | ||
}; | }; | ||
| Line 172: | Line 174: | ||
Some users suffer from slow build due to fish enabling `documentation.man.generateCaches`. You may force false. | Some users suffer from slow build due to fish enabling `documentation.man.generateCaches`. You may force false. | ||
documentation.man.generateCaches = false'';'' | documentation.man.generateCaches = false'';'' | ||
For home-manager users, man cache need to be disabled in programs | |||
programs.man.generateCaches = false'';'' | |||
==== Running fish interactively with zsh as system shell on darwin ==== | ==== Running fish interactively with zsh as system shell on darwin ==== | ||
{{outdated|date=May 14, 2026|reason=I've updated the interactiveShellInit snippet that this section refers to. Either the following paragraph should be reworded or the provided zsh config be modified. For more context, please see my corresponding [https://wiki.nixos.org/w/index.php?title=Fish&oldid=31760 edit] and the linked talk page.|talk=Talk:Fish#Suggested_bashrc_in_Fish#Setting_fish_as_default_shell_needs_revision}} | |||
Zsh users on darwin will need to use a modified version of the above snippet. As written, it presents two incompatibilities. First, being BSD-derived, MacOS's <code>ps</code> command accepts different options. Second, this is a script intended for bash, not zsh. MacOS uses zsh as its default shell. | Zsh users on darwin will need to use a modified version of the above snippet. As written, it presents two incompatibilities. First, being BSD-derived, MacOS's <code>ps</code> command accepts different options. Second, this is a script intended for bash, not zsh. MacOS uses zsh as its default shell. | ||
| Line 198: | Line 206: | ||
) | ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Note|This won't work with the new {{ic|nix shell}} command, as it doesn't set {{ic|IN_NIX_SHELL}} variable. You can instead check if {{ic|$SHLVL}} is {{ic|> 1}}, or check if {{ic|$PATH}} contains paths from {{ic|/nix/store}} (which get added at the beginning of the {{ic|$PATH}} when you enter nix shell). See https://github.com/NixOS/nix/issues/6677 for more context and workarounds.}} | |||
and <code>$nix_shell_info</code> to the echo in that function, e.g.: | and <code>$nix_shell_info</code> to the echo in that function, e.g.: | ||