nix-configs

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

fish.nix (2106B)


      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       fullpath = "set -l dir (test (count \$argv) -gt 0; and echo \$argv[1]; or echo .); realpath \$dir/*";
     13       mcd = "mkdir -p $argv[1] && cd $argv[1]";
     14       mergeinto = "rsync --progress --remove-source-files -av \"$argv[1]\" \"$argv[2]\" && find \"$argv[1]\" -empty -delete";
     15       ncdu = ''set arg (count $argv); if test $arg -eq 0; set argv .; end; "${pkgs.rclone}/bin/rclone" ncdu $argv'';
     16       vat = "math $argv + \"($argv * 0.2)\"";
     17       # sort:end
     18     };
     19     shellInit = ''
     20       set fish_greeting # Disable greeting
     21       set -gx DOMAIN ${vars.user.domain}
     22       set -gx EDITOR nvim
     23       set -gx EMAIL ${vars.user.email}
     24       set -gx SYNCDIR $HOME/vault
     25       set -gx VISUAL $EDITOR
     26     '';
     27     shellAliases = {
     28       # sort:start
     29       cdv = "cd $HOME/vault/";
     30       crypto-sum = "${pkgs.rbw}/bin/rbw get 'crypto purchases' | awk '/^20/ {print $2}' | paste -sd+ | math";
     31       empties = "find . -maxdepth 3 -mount -not -path \"*/\.*\" -empty -print";
     32       extract = "${pkgs.atool}/bin/aunpack";
     33       jdupes = "jdupes -A"; # exclude hidden files
     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       # sort:end
     37     };
     38     interactiveShellInit = ''
     39       set -g fish_greeting
     40       function fish_prompt
     41       echo
     42       set_color green
     43       echo (dirs)
     44       set_color normal
     45       printf "%s ❯ " (hostname)
     46       end
     47     '';
     48 
     49 
     50 #    binds = {
     51     #      "ctrl-h".command = "backward-kill-path-component";
     52     #      "ctrl-backspace".command = "kill-word";
     53     #    };
     54   };
     55 }