Fish: Difference between revisions

imported>Onny
mNo edit summary
imported>Onny
Cleanup
Line 2: Line 2:
fish is the [http://fishshell.com/ Friendly Interactive Shell].
fish is the [http://fishshell.com/ Friendly Interactive Shell].


==Setting fish as the default shell==
== Installation ==
See [[Command Shell#Changing default shell]].


== Managing fish plugins with Home Manager ==
For setting fish as the default shell system wide, see [[Command Shell#Changing default shell]].


In order to manage fish with home manager you also have to enable it in your <code>home.nix</code>.
A user specific installation with [[Home Manager]] looks like this


Then you can add new ones by adding them to the list of submodules of <code>programs.fish.plugins</code>.
<syntaxhighlight lang="nix">
=== Manual ===
home-manager.users.myuser = {
  programs.fish.enable = true;
};
</syntaxhighlight>


So for example for the plugin <code>z</code> from jethrokuan on github.
Change <code>myuser</code> with the username you want to configure.
 
You can enable the fish shell and manage fish configuration and plugins with home manager, but to enable vendor fish completions provided by Nixpkgs you will also want to enable the fish shell in <code>/etc/nixos/configuration.nix</code>:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
   programs.fish.enable = true;
   programs.fish.enable = true;
   programs.fish.plugins = [
</syntaxhighlight>
    {
 
== Configuration ==
 
An example configuration in Home Manager for adding plugins and changing options could look like this
 
<syntaxhighlight lang="nix">
home-manager.users.myuser = {
   programs.fish = {
    enable = true;
    interactiveShellInit = ''
      set fish_greeting # Disable greeting
    '';
    plugins = [
      # Enable a plugin (here grc for colorized command output) from nixpkgs
      { name = "grc"; src = pkgs.fishPlugins.grc.src; }
      # Manually packaging and enable a plugin
      {
       name = "z";
       name = "z";
       src = pkgs.fetchFromGitHub {
       src = pkgs.fetchFromGitHub {
Line 26: Line 46:
       };
       };
     }
     }
    { name = "grc"; src = pkgs.fishPlugins.grc.src; }
   ];
   ];
</syntaxhighlight>
</syntaxhighlight>


=== nixpkgs ===
See [https://search.nixos.org/packages?channel=unstable&from=0&size=50&buckets=%7B%22package_attr_set%22%3A%5B%22fishPlugins%22%5D%2C%22package_license_set%22%3A%5B%5D%2C%22package_maintainers_set%22%3A%5B%5D%2C%22package_platforms%22%3A%5B%5D%7D&sort=relevance&query=fishPlugins fishPlugins package set] for available plugins in nixpkgs.


Or you can use some of the [https://search.nixos.org/packages?channel=unstable&from=0&size=50&buckets=%7B%22package_attr_set%22%3A%5B%22fishPlugins%22%5D%2C%22package_license_set%22%3A%5B%5D%2C%22package_maintainers_set%22%3A%5B%5D%2C%22package_platforms%22%3A%5B%5D%7D&sort=relevance&query=fishPlugins packaged plugins], by just adding them to your installed packages (or with nix-env)
== Useful scripts ==
 
==Fish completions==
 
You can enable the fish shell and manage fish configuration and plugins with home manager, but to enable vendor fish completions provided by Nixpkgs you will also want to enable the fish shell in <code>/etc/nixos/configuration.nix</code>:
 
<syntaxhighlight lang="nix">
  programs.fish.enable = true;
</syntaxhighlight>


== Useful scripts ==
=== Show that you are in a nix-shell ===
=== Show that you are in a nix-shell ===
Add this to the <code>fish_prompt</code> function (usually placed in <code>~/.config/fish/functions/fish_prompt.fish</code>):
Add this to the <code>fish_prompt</code> function (usually placed in <code>~/.config/fish/functions/fish_prompt.fish</code>):
Line 102: Line 112:


== See also ==
== See also ==
* [[Command Shell]]
* [[Command Shell]]


[[Category:Applications]]
[[Category:Applications]]