all repos — nixfiles @ 26d9a238751a7d70006cfd25fac24e55eebd3808

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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{
  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.tide
      ]
    );
    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/completions" = {
    recursive = true;
    source = direct_symlink "/user/settings/fish/completions";
  };
  xdg.configFile."fish/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/functions/tide $fish_function_path[2..-1]
  '';
  home.activation.tide-configure = ''
    run ${lib.getExe config.programs.fish.package} -c '
      tide configure \
        --auto \
        --style=Lean \
        --prompt_colors="16 colors" \
        --show_time="24-hour format" \
        --lean_prompt_height="Two lines" \
        --prompt_connection=Disconnected \
        --prompt_spacing=Compact \
        --icons="Few icons"
      set --universal tide_left_prompt_items shlvl context pwd vcs newline character

      set --local idx (contains --index context $tide_right_prompt_items)
      and set --universal --erase tide_right_prompt_items[$idx]
      '
  '';

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