TIL: How to change the fish greeter

In this post I will show you how you can change your fish shell greeter from the default

snippet.sh
Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish
bash 2 lines
"snippet.sh" 2L

To something custom, this will run every time you open a new shell!

Fish Greeting

To do this, go to your fish_greeter.fish file which can usually be found at ~/.config/fish/functions/fish_greeting.fish. Where mine looks like:

snippet.fish
function fish_greeting
    fortune | lolcat -f | chara say -c kitten
end
fish 3 lines
"snippet.fish" 3L

fortune generates a random quote, then lolcat colours that quote as a rainbow and finally chara prints out the kitten.

Nix (Optional)

If you are using fish to configure your fish shell you can do something like (I do this in a file called fish.nix):

snippet.nix
{ lib, pkgs, ... }:

{
  programs.fish = {
    enable = true;
    functions = {
      fish_greeting = {
        description = "Greeting to show when starting a fish shell";
        body = "fortune | lolcat -f | chara say -c kitten";
      };
    };
  }
}
nix 13 lines
"snippet.nix" 13L