1 { pkgs, lib, config, ... }:
6 md-toc = "grep '^#\\+' --color";
8 rsync = "rsync --no-inc-recursive --info=progress2 --inplace --partial";
9 watch = "watch --color";
13 # Disable ctrl-s/ctrl-q flow control
17 device=''${1:-/dev/sda}
18 sudo smartctl -A $device |
20 $0 ~ /Power_On_Hours/ { poh=$10; printf "%s / %d hours / %d days / %.2f years\n", $2, $10, $10 / 24, $10 / 24 / 365.25 }
21 $0 ~ /Total_LBAs_Written/ {
27 printf "%s / %s / %d mb / %.1f gb / %.3f tb\n", $2, $10, mb, gb, tb
28 printf "mean writes per hour: / %.2f", mb/poh
30 $0 ~ /Airflow_Temperature_Cel/ { print $2 " / " $10}
31 $0 ~ /Wear_Leveling_Count/ { printf "%s / %d (%% health)\n", $2, int($4) }
34 sed -e "s\$^\$$device @ \$" |
40 sudo grep -H '^Swap:' /proc/*/smaps 2>/dev/null |
41 while IFS=: read -r file x size x
47 if test "$pid" = "$lastpid"
48 then swap=$(( swap + size ))
51 then printf "%u pid=%u cmd=%s\n" "$swap" "$lastpid" "$(tr '\000' ' ' </proc/"$lastpid"/cmdline)"
63 vim-git () { $EDITOR $(git diff-tree --no-commit-id --name-only --recursive "$@"); }
64 vim-git-grep () { $EDITOR $(git grep --name-only --recursive "$@"); }
65 zfs-mount () { for d in $(zfs list -rH -o name "$@"); do sudo zfs mount -l "$d"; done; }
66 zfs-unmount () { sudo zfs unmount -u "$@"; }
69 programs.direnv.enableBashIntegration = true;
70 programs.broot.enableBashIntegration = true;
71 home.sessionVariables = {
72 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)\$ '';
74 home.file.".inputrc".text = ''
75 "\e[1~": beginning-of-line
77 "\e[7~": beginning-of-line
79 "\eOH": beginning-of-line
81 "\e[H": beginning-of-line
83 "\e[1;5C": forward-word
84 "\e[1;5D": backward-word
86 "\e[5D": backward-word
87 "\e\e[C": forward-word
88 "\e\e[D": backward-word