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