all repos — nixfiles @ afd408369e242b66a4c8408a48286abe50500331

System and user configuration, managed by nix and home-manager

user/settings/fish.nix (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{
  config,
  pkgs,
  lib,
  ...
}:
let
  inherit (lib) getAttrs removePrefix;

  nixfiles = config.home.homeDirectory + "/projects/alin.ovh/nixfiles";
  direct_symlink = path: config.lib.file.mkOutOfStoreSymlink "${nixfiles}/${removePrefix "/" path}";

  toPluginModule = getAttrs [
    "name"
    "src"
  ];
in
{
  home.shell.enableFishIntegration = true;
  programs.fish = {
    enable = true;
    plugins = map toPluginModule (
      with pkgs.fishPlugins;
      [
        done
        fzf-fish
        fifc
        autopair
        colored-man-pages
        fishbang
        sponge
      ]
      ++ [
        pkgs.personal.fishPlugins.ghq
        pkgs.personal.fishPlugins.hydro
      ]
    );
    shellAliases = {
      hist-freq-lines = lib.mkForce "history | sort | uniq -c | sort -gr | head -n100 | less";
      hist-freq-commands = lib.mkForce "history | cut -d' ' -f 1 | sort | uniq -c | sort -gr | head -n100 | less";

      fadd = "funced --save";
      fed = "funced --save";
    };
  };
  xdg.configFile."fish/home-manager/completions" = {
    recursive = true;
    source = direct_symlink "/user/settings/fish/completions";
  };
  xdg.configFile."fish/home-manager/functions" = {
    recursive = true;
    source = direct_symlink "/user/settings/fish/functions";
  };
  xdg.configFile."fish/per-term" = {
    recursive = true;
    source = direct_symlink "/user/settings/fish/per-term";
  };
  xdg.configFile."fish/conf.d" = {
    recursive = true;
    source = "${nixfiles}/user/settings/fish/conf.d";
  };

  programs.nix-your-shell = {
    enable = true;
    nix-output-monitor.enable = true;
    enableFishIntegration = true;
  };

  programs.fish.shellInit = ''
    set fish_function_path $fish_function_path[1] ${config.xdg.configHome}/fish/home-manager/functions $fish_function_path[2..-1]
    set --prepend fish_complete_path ${config.xdg.configHome}/fish/home-manager/complete
  '';

  home.activation.sponge-configure = ''
    run ${lib.getExe config.programs.fish.package} -c '
      set --universal sponge_delay 60
    '
  '';
}