1 { pkgs, lib, config, ... }:
 
   4   enable = lib.mkDefault true;
 
   8     eic = "edit-in-commit";
 
   9     eigg = "edit-in-git-grep";
 
  10     emacs = "emacsclient --create-frame";
 
  13     grep = "grep --color";
 
  14     j="sudo journalctl -u";
 
  15     jb="sudo journalctl -b";
 
  18     ls = "ls --color=tty";
 
  19     md-toc = "grep '^#\\+' --color";
 
  20     mem = "ps -e -orss=,user=,args= | sort -b -k1,1n";
 
  21     mem-top = "smem --sort rss --autosize";
 
  23     nixos-clean="sudo nix-collect-garbage -d";
 
  24     nixos-history="sudo nix-env --list-generations --profile /nix/var/nix/profiles/system";
 
  25     nixos-rollback="sudo nixos-rebuild switch --rollback";
 
  26     pass-gen = "tr -d -C A-Za-z0-9_- </dev/urandom | head -c";
 
  27     rsync = "rsync --no-inc-recursive --info=progress2 --inplace --partial";
 
  29     st="sudo systemctl status";
 
  31     ut="systemctl --user status";
 
  33     watch = "watch --color --differences";
 
  34     zfs-umount = "zfs-unmount";
 
  40     # Disable ctrl-s/ctrl-q flow control
 
  45       then sudo tee /proc/acpi/ibm/fan <<<"level $1"
 
  46       else grep '^\(level\|speed\):' /proc/acpi/ibm/fan
 
  55       device=''${1:-/dev/sda}
 
  56       sudo smartctl -A $device |
 
  58         $0 ~ /Power_On_Hours/ { poh=$10; printf "%s / %d hours / %d days / %.2f years\n",  $2, $10, $10 / 24, $10 / 24 / 365.25 }
 
  59         $0 ~ /Total_LBAs_Written/ {
 
  65             printf "%s / %s  / %d mb / %.1f gb / %.3f tb\n", $2, $10, mb, gb, tb
 
  66             printf "mean writes per hour:  / %.2f",  mb/poh
 
  68         $0 ~ /Airflow_Temperature_Cel/ { print $2 " / " $10}
 
  69         $0 ~ /Wear_Leveling_Count/ { printf "%s / %d (%% health)\n", $2, int($4) }
 
  72       sed -e "s\$^\$$device @ \$" |
 
  78       sudo grep -H '^Swap:' /proc/*/smaps 2>/dev/null |
 
  79       while IFS=: read -r file x size x
 
  85         if test "$pid" = "$lastpid"
 
  86         then swap=$(( swap + size ))
 
  89           then printf "%u pid=%u cmd=%s\n" "$swap" "$lastpid" "$(tr '\000' ' ' </proc/"$lastpid"/cmdline)"
 
 101     edit-in-commit () { $EDITOR $(git diff-tree --no-commit-id --name-only -r "$@"); }
 
 102     edit-in-git-grep () { $EDITOR $(git grep --name-only --recursive "$@"); }
 
 103     zfs-mount () { for d in $(zfs list -rH -o name "$@"); do sudo zfs mount -l "$d"; done; }
 
 104     zfs-unmount () { sudo zfs unmount -u "$@"; }
 
 109 programs.direnv.enableBashIntegration = true;
 
 110 #programs.broot.enableBashIntegration = true;
 
 111 home.sessionVariables = {
 
 112   PS1 = ''\[\033[1;32m\]\[\e]0;\u@\h: \w\a\]\W\[\033[0m\] \$(e=\$?; if [ \$e != 0 ]; then echo '\[\e[0;91m\]'\$e'\[\e[0m\]'; fi)\$ '';
 
 114 programs.readline = {
 
 115   enable = lib.mkDefault true;
 
 116   includeSystemConfig = true;
 
 118     "\\eOF"    = "end-of-line";
 
 119     "\\eOH"    = "beginning-of-line";
 
 120     "\\e[1;5C" = "forward-word";
 
 121     "\\e[1;5D" = "backward-word";
 
 122     "\\e[1~"   = "beginning-of-line";
 
 123     "\\e[4~"   = "end-of-line";
 
 124     "\\e[5C"   = "forward-word";
 
 125     "\\e[5D"   = "backward-word";
 
 126     "\\e[7~"   = "beginning-of-line";
 
 127     "\\e[8~"   = "end-of-line";
 
 128     "\\e[A"    = "history-search-backward";
 
 129     "\\e[B"    = "history-search-forward";
 
 130     "\\e[F"    = "end-of-line";
 
 131     "\\e[H"    = "beginning-of-line";
 
 132     "\\e\\e[C" = "forward-word";
 
 133     "\\e\\e[D" = "backward-word";
 
 136     colored-completion-prefix = lib.mkDefault true;
 
 137     colored-stats = lib.mkDefault true; # Note that this may cause completion text blink in some terminals (e.g. xterm).
 
 138     echo-control-characters = lib.mkDefault true;
 
 139     mark-symlinked-directories = lib.mkDefault true;
 
 140     menu-complete-display-prefix = lib.mkDefault true;
 
 141     show-all-if-ambiguous = lib.mkDefault true;
 
 142     show-all-if-unmodified = lib.mkDefault true;
 
 143     visible-stats = lib.mkDefault false; # Append char to indicate type