main
1{lib, ...}: {
2 den.aspects.core.shell.fish = {
3 includes = [
4 ({user, ...}: {
5 persistUser = {
6 files = lib.optional (!(lib.elem "homeManager" user.classes)) ".local/share/fish/fish_history";
7 };
8 persistHome = {config, ...}: {
9 files = ["${config.xdg.dataHome}/fish/fish_history"];
10 };
11 })
12 ];
13
14 nixos = {
15 programs.fish = {
16 enable = true;
17 useBabelfish = true;
18
19 shellInit = ''
20 set -U fish_greeting
21 '';
22 };
23 };
24
25 homeManager = {pkgs, ...}: {
26 programs.fish = {
27 enable = true;
28 generateCompletions = true;
29 plugins = with pkgs.fishPlugins; [
30 {
31 inherit (puffer) src;
32 name = "puffer";
33 }
34 {
35 inherit (autopair) src;
36 name = "autopair";
37 }
38 ];
39
40 shellInit = ''
41 set -U fish_greeting
42 '';
43 };
44 };
45 };
46
47 den.aspects.core.shell.fish.themes = {
48 catppuccin = {
49 homeManager = {pkgs, ...}: {
50 programs.fish = {
51 shellInit = ''
52 fish_config theme choose catppuccin-mocha
53 '';
54 };
55 xdg.configFile."fish/themes/catppuccin-mocha.theme".source = pkgs.fetchurl {
56 pname = "fish-theme-catppuccin-mocha.theme";
57 url = "https://github.com/catppuccin/fish/raw/5fc5ae9c2ec22eb376cb03ce76f0d262a38960f3/themes/static/catppuccin-mocha.theme";
58 hash = "sha256-sAn4eJy6tmloWbN0p+mBdku3CK5TUeKVtVsaH/CBnGk=";
59 };
60 };
61 };
62 };
63
64 den.aspects.core.shell.fish.bashOverlay = {
65 nixos = {config, ...}: {
66 programs.bash = {
67 interactiveShellInit = ''
68 # "check if parent process is not fish" && "make nested shells work properly"
69 if grep -qv fish /proc/$PPID/comm && [[ $SHLVL == [12] ]]; then
70 # set $SHELL for better integration with programs like nix shell, tmux, etc.
71 SHELL=${config.programs.fish.package}/bin/fish exec fish
72 fi
73 '';
74 };
75 };
76 };
77}