{ config, lib, ... }: let # automatically discover functions in the relative fish functions directory fishFuncDir = ../../scripts/fish-functions; fishFuncs = lib.attrsets.mapAttrs' (name: _: lib.nameValuePair (lib.strings.removeSuffix ".fish" "${name}") ({ body = builtins.readFile (fishFuncDir + "/${name}"); })) (lib.attrsets.filterAttrs (name: type: type == "regular") (builtins.readDir fishFuncDir) ); in { home-manager.users.djai.programs.fish = { enable = true; binds = { "ctrl-f" = { command = "forward-char"; mode = "insert"; }; "alt-f" = { command = "forward-word"; mode = "insert"; }; }; shellInit = '' # start fbterm if in raw tty if string match -qr "/dev/tty[2-9]" (tty) fbterm -- env TERM=fbterm tmux new end [ -d "$HOME/.cargo/env.fish" ] && source "$HOME/.cargo/env.fish" set -g fish_greeting ''; interactiveShellInit = '' fish_vi_key_bindings starship init fish | source if test -n "$TMUX" ascii.sh else if test "$TERM" != "linux" tmux new end end # make clear also remove scrollback on kitty/tmux string match --qri -- '(screen-256color|xterm-kitty)' "$TERM" && alias clear "printf '\033[2J\033[3J\033[1;1H'" ''; loginShellInit = '' ~/Scripts/diaryEntry.sh > /dev/null # TODO: move to somewhere ''; shellAbbrs = { "webcam" = "mpv av://v4l2:/dev/video0 --profile=low-latency --untimed"; "venv" = ". .venv/bin/activate.fish"; "rug" = "sudo openconnect --protocol=gp safenet.vpn.rug.nl"; "dia" = "nvim (date +%F)"; "rm" = "rm -I"; "mv" = "mv -vn"; "make" = "make -j8"; "ll" = "ls -hlav --ignore=.."; "l" = "ls -lav --ignore=.\?\*"; "la" = "ls -A"; "lg" = "lazygit"; "fih" = "fish"; "twi" = "twitch"; "keh" = "kitten icat"; }; # discovered functions + overrides functions = fishFuncs // { tmux-updater = fishFuncs.tmux-updater // {onEvent = "fish_preexec";}; histdelete = fishFuncs.histdelete // {onEvent = "fish_postexec";}; }; }; home-manager.users."djai".home.shell.enableFishIntegration = true; }