nix-configs

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

fish.nix (2180B)


      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       notes = ''set file (find "$SYNCDIR/notes" -name ".git" -prune -o -type f | fzf --preview 'cat {}' --preview-window='right:60%:wrap'); and nvim "$file"'';
     16       vat = "math $argv + \"($argv * 0.2)\"";
     17     };
     18     shellInit = ''
     19       set fish_greeting # Disable greeting
     20       set -gx DOMAIN ${vars.user.domain}
     21       set -gx EDITOR nvim
     22       set -gx EMAIL ${vars.user.email}
     23       set -gx SYNCDIR $HOME/vault
     24       set -gx VISUAL $EDITOR
     25     '';
     26     shellAliases = {
     27       cdv = "cd $HOME/vault/";
     28       crypto-sum = "${pkgs.rbw}/bin/rbw get 'crypto purchases' | awk '/^20/ {print $2}' | paste -sd+ | math";
     29       empties = "find . -maxdepth 3 -mount -not -path \"*/\.*\" -empty -print";
     30       extract = "${pkgs.atool}/bin/aunpack";
     31       jdupes = "jdupes -A"; # exclude hidden files
     32       vaultedit = "find \"$SYNCDIR\" -maxdepth 5 -type f -not -path \"\*/\.git\" | ${pkgs.fzf}/bin/fzf --preview \"cat {}\" --layout reverse | xargs -r -I{} \"$EDITOR\" {}";
     33       week = "date +%V";
     34     };
     35     interactiveShellInit = ''
     36       set -g fish_greeting
     37       function fish_prompt
     38       echo
     39       set_color green
     40       echo (dirs)
     41       set_color normal
     42       printf "❯ "
     43       end
     44     '';
     45 
     46 
     47 #    binds = {
     48     #      "ctrl-h".command = "backward-kill-path-component";
     49     #      "ctrl-backspace".command = "kill-word";
     50     #    };
     51   };
     52 }