nix-configs

Personal NixOS and home-manager configuration files
Log | Files | Refs

fish.nix (2264B)


      1 { pkgs, vars, ... }:
      2 
      3 {
      4   programs.fish = {
      5     enable = true;
      6     functions = {
      7       # sort:start
      8       __fish_command_not_found_handler = { body = "echo fish: Unknown command $argv[1]"; onEvent = "fish_command_not_found"; };
      9       backup = "tar -zcvf (basename \$argv)_backup-(date +%F-%H%M%S).tar.gz \$argv";
     10       book = "grep -i \"$argv\" \"$SYNCDIR/src/blog.${vars.user.domain}/content/reading-list.md\"";
     11       dos2unix = "sed -i 's/\r//' \"$argv\"";
     12       fractodec = "math -s2 \"$argv\"";
     13       fullpath = "set -l dir (test (count \$argv) -gt 0; and echo \$argv[1]; or echo .); realpath \$dir/*";
     14       hextodec = "math \"0x$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       ncdu = ''set arg (count $argv); if test $arg -eq 0; set argv .; end; "${pkgs.rclone}/bin/rclone" ncdu $argv'';
     18       vat = "math $argv + \"($argv * 0.2)\"";
     19       # sort:end
     20     };
     21     shellInit = ''
     22       set fish_greeting # Disable greeting
     23       set -gx DOMAIN ${vars.user.domain}
     24       set -gx EDITOR nvim
     25       set -gx EMAIL ${vars.user.email}
     26       set -gx SYNCDIR $HOME/vault
     27       set -gx VISUAL $EDITOR
     28     '';
     29     shellAliases = {
     30       # sort:start
     31       cdv = "cd $HOME/vault/";
     32       crypto-sum = "${pkgs.rbw}/bin/rbw get 'crypto purchases' | awk '/^20/ {print $2}' | paste -sd+ | math";
     33       empties = "find . -maxdepth 3 -mount -not -path \"*/\.*\" -empty -print";
     34       extract = "${pkgs.atool}/bin/aunpack";
     35       jdupes = "jdupes -A"; # exclude hidden files
     36       ncdusteam = "ncdu $HOME/.local/share/Steam/steamapps/common/ 2>/dev/null";
     37       vaultedit = "find \"$SYNCDIR\" -maxdepth 5 -type f -not -path \"\*/\.git\" | ${pkgs.fzf}/bin/fzf --preview \"cat {}\" --layout reverse | xargs -r -I{} \"$EDITOR\" {}";
     38       week = "date +%V";
     39       # sort:end
     40     };
     41     interactiveShellInit = ''
     42       set -g fish_greeting
     43       function fish_prompt
     44       echo
     45       set_color green
     46       echo (dirs)
     47       set_color normal
     48       printf "%s ❯ " (hostname)
     49       end
     50     '';
     51 
     52 
     53 #    binds = {
     54     #      "ctrl-h".command = "backward-kill-path-component";
     55     #      "ctrl-backspace".command = "kill-word";
     56     #    };
     57   };
     58 }