fish.nix (1863B)
1 { pkgs, domain, ... }: 2 3 { 4 programs.fish = { 5 enable = true; 6 functions = { 7 __fish_command_not_found_handler = { body = "echo fish: Unknown command $argv[1]"; onEvent = "fish_command_not_found"; }; 8 backup = "tar -zcvf (basename \$argv)_backup-(date +%F-%H%M%S).tar.gz \$argv"; 9 book = "grep -i \"$argv\" \"$SYNCDIR/src/blog.${domain}/content/reading-list.md\""; 10 dos2unix = "sed -i 's/\r//' \"$argv\""; 11 mcd = "mkdir -p $argv[1] && cd $argv[1]"; 12 mergeinto = "rsync --progress --remove-source-files -av \"$argv[1]\" \"$argv[2]\" && find \"$argv[1]\" -empty -delete"; 13 vat = "math $argv + \"($argv * 0.2)\""; 14 ncdu = ''set arg (count $argv); if test $arg -eq 0; set argv .; end; "${pkgs.rclone}/bin/rclone" ncdu $argv''; 15 }; 16 shellInit = '' 17 set fish_greeting # Disable greeting 18 set -gx DOMAIN ${domain} 19 set -gx EDITOR nvim 20 set -gx EMAIL (whoami)@${domain} 21 set -gx SYNCDIR $HOME/vault 22 set -gx VISUAL $EDITOR 23 ''; 24 shellAliases = { 25 crypto-sum = "${pkgs.rbw}/bin/rbw get 'crypto purchases' | awk '/^20/ {print $2}' | paste -sd+ | math"; 26 empties = "find . -maxdepth 3 -mount -not -path \"*/\.*\" -empty -print"; 27 extract = "${pkgs.atool}/bin/aunpack"; 28 jdupes = "jdupes -A"; # exclude hidden files 29 vaultedit = "find \"$SYNCDIR\" -maxdepth 5 -type f -not -path \"\*/\.git\" | ${pkgs.fzf}/bin/fzf --preview \"cat {}\" --layout reverse | xargs -r -I{} \"$EDITOR\" {}"; 30 week = "date +%V"; 31 }; 32 interactiveShellInit = '' 33 set -g fish_greeting 34 function fish_prompt 35 echo 36 set_color green 37 echo (dirs) 38 set_color normal 39 printf "❯ " 40 end 41 ''; 42 43 44 # binds = { 45 # "ctrl-h".command = "backward-kill-path-component"; 46 # "ctrl-backspace".command = "kill-word"; 47 # }; 48 }; 49 }