nix-configs

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

fish.nix (2020B)


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