summaryrefslogtreecommitdiff
path: root/home/ebisu/kansai/system/shell/fish.nix
blob: c954261457747cb56ebf5e47005b46aac3468f54 (plain) (blame)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
{
  pkgs,
  config,
  secrets,
  self,
  lib,
  ...
}:
{
  programs.fish = {
    enable = true;

    shellInit = ''
      if status is-interactive
        set fish_greeting

        fish_vi_key_bindings

        function fish_postexec --on-event fish_postexec
          if test "$argv" != "clear"
            echo
          end
        end

        function vpn
          env BIND_INTERFACE=wgpia0 LD_PRELOAD=/usr/lib/bindToInterface.so $argv
        end

        function nh
          if test "$argv[1]" = "home" -a "$argv[2]" = "switch"
            command nh $argv -- --impure
          else
            command nh $argv
          end
        end

        function nix-find
          doas find $argv -type f -exec test ! -L {} \; -exec realpath {} \; | grep -v "^/nix/store"
        end

        function code
          command code $argv --wait
        end

        function code!
          command code $argv
        end

        function pvpn
            doas protonvpn $argv
        end
      end

      set -l config_home (set -q XDG_CONFIG_HOME; and echo $XDG_CONFIG_HOME; or echo ${config.xdg.configHome})
      set HISTSIZE -1
      set HISTFILESIZE -1
      set SAVEHIST -1
      set GPG_TTY (tty)

      bind \ce edit_command_buffer

      cat ${config.xdg.cacheHome}/wal/sequences

      zoxide init fish | source
    '';

    plugins = [
      {
        name = "fzf.fish";

        src = pkgs.fetchFromGitHub {
          owner = "patrickf1";
          repo = "fzf.fish";
          rev = "8920367cf85eee5218cc25a11e209d46e2591e7a";
          sha256 = "sha256-T8KYLA/r/gOKvAivKRoeqIwE2pINlxFQtZJHpOy9GMM=";
        };
      }
      {
        name = "bass";

        src = pkgs.fetchFromGitHub {
          owner = "edc";
          repo = "bass";
          rev = "79b62958ecf4e87334f24d6743e5766475bcf4d0";
          sha256 = "sha256-3d/qL+hovNA4VMWZ0n1L+dSM1lcz7P5CQJyy+/8exTc=";
        };
      }
      {
        name = "nvm.fish";

        src = pkgs.fetchFromGitHub {
          owner = "jorgebucaran";
          repo = "nvm.fish";
          rev = "b8edb1ee24cbbf7259196b0cb3c6c4ab65b07929";
          sha256 = "sha256-7JxIQSseBv81SSpWH1pufx8fh9EQhbo3r2nVVREwc58=";
        };
      }
      {
        name = "sponge";

        src = pkgs.fetchFromGitHub {
          owner = "meaningful-ooo";
          repo = "sponge";
          rev = "384299545104d5256648cee9d8b117aaa9a6d7be";
          sha256 = "sha256-MdcZUDRtNJdiyo2l9o5ma7nAX84xEJbGFhAVhK+Zm1w=";
        };
      }
      {
        name = "autopair.fish";

        src = pkgs.fetchFromGitHub {
          owner = "jorgebucaran";
          repo = "autopair.fish";
          rev = "4d1752ff5b39819ab58d7337c69220342e9de0e2";
          sha256 = "sha256-qt3t1iKRRNuiLWiVoiAYOu+9E7jsyECyIqZJ/oRIT1A=";
        };
      }
    ];

    shellAliases =
      let
        proxyEnvironment = "http_proxy=$(cat ${
          config.sops.secrets."proxy/i2p/http".path
        }) HTTP_PROXY=$(cat ${config.sops.secrets."proxy/i2p/http".path}) https_proxy=$(cat ${
          config.sops.secrets."proxy/i2p/https".path
        }) HTTPS_PROXY=$(cat ${config.sops.secrets."proxy/i2p/https".path}) socks_proxy=$(cat ${
          config.sops.secrets."proxy/i2p/socks5".path
        }) SOCKS_PROXY=$(cat ${config.sops.secrets."proxy/i2p/socks5".path})";
      in
      {
        # Verbosity
        cp = "cp -iv";
        mv = "mv -iv";
        # rm = "rm -vI";
        bc = "bc -ql";
        rsync = "rsync -vrPlu";
        mkd = "mkdir -pv";
        yt = "yt-dlp --embed-metadata -i";
        yta = "yt -x -f bestaudio/best";
        ytt = "yt --skip-download --write-thumbnail";
        ffmpeg = "ffmpeg -hide_banner";
        wdic = "wdic --homophones --kanji --color --pager";
        hakuneko = "hakuneko-desktop --no-sandbox";
        fastfetch = "clear && /usr/bin/env fastfetch";
        wget = "wget --hsts-file=${config.xdg.dataHome}/wget-hsts";
        mosh = "mosh --predict=experimental";

        # Modern Alternatives & Alias Rewrites
        unzip = "ripunzip unzip-file";
        nvim = "lvim";
        vim = "lvim";
        vimdiff = "lvim -d";
        rm = "rip";

        # Colourise
        ls = "exa -h --no-quotes --color=auto --group-directories-first";
        grep = "grep --color=auto";
        diff = "diff --color=auto";
        ccat = "highlight --out-format=ansi";
        ip = "ip -color=auto";

        # Abbreviations
        ka = "killall";
        g = "git";
        sdn = "shutdown -h now";
        e = "$EDITOR";
        v = "$EDITOR";
        ff = "fastfetch";

        # Other
        chan = "chan-downloader -c 10";
        rotd = "systemctl --user restart opentabledriver.service";
        ks = "kaguya stream --user-agent 'Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0'";
        def = "myougiden";
        suzuri = "SUZURI_MINIMAL=1 SUZURI_REVERSE=1 ${pkgs.tsutsumi.suzuri}/bin/suzuri";
        "5ch" = "html2md -i 'https://ff5ch.syoboi.jp/' -s section | glow";
        shinobu = "curl --silent https://shinobu.fuwn.workers.dev/shinobu -o /tmp/shinobu && feh /tmp/shinobu";
        auto_subtitle = "source ${config.home.homeDirectory}/Documents/Code/Git/Random/auto-subtitle/venv/bin/activate && auto_subtitle --model medium --task translate --srt_only True";
        steamy = "mangohud gamemoderun steam-runtime";
        koix = "koi -f";
        seamonkey = "${config.home.homeDirectory}/.local/src/seamonkey/seamonkey-bin";
        doom = "${config.xdg.configHome}/emacs/bin/doom";
        epiphany-i2p = "${proxyEnvironment} epiphany";
        eolie-i2p = "${proxyEnvironment} eolie";
        notion = "notion-app ${import "${self}/lib/electron-flags.nix" { inherit lib; }}";
      };
  };
}