{ pkgs, lib, config, ... }: { programs.bash = { shellAliases = { cl = "clear"; g = "git"; grep = "grep --color"; j="sudo journalctl -u"; jb="sudo journalctl -b"; l = "ls -alh"; ll = "ls -al"; ls = "ls --color=tty"; md-toc = "grep '^#\\+' --color"; mem = "ps -e -orss=,user=,args= | sort -b -k1,1n"; mem-top = "smem --sort rss --autosize"; mpl = "mplayer"; nixos-clean="sudo nix-collect-garbage -d"; nixos-history="sudo nix-env --list-generations --profile /nix/var/nix/profiles/system"; nixos-rollback="sudo nixos-rebuild switch --rollback"; rsync = "rsync --no-inc-recursive --info=progress2 --inplace --partial"; s="sudo systemctl"; st="sudo systemctl status"; u="systemctl --user"; ut="systemctl --user status"; watch = "watch --color"; }; initExtra = '' shopt -s globstar # Disable ctrl-s/ctrl-q flow control stty -ixon smartctl-tbw () { device=''${1:-/dev/sda} sudo smartctl -A $device | { awk ' $0 ~ /Power_On_Hours/ { poh=$10; printf "%s / %d hours / %d days / %.2f years\n", $2, $10, $10 / 24, $10 / 24 / 365.25 } $0 ~ /Total_LBAs_Written/ { lbas = $10; bytes = $10 * 512; mb = bytes / 1024^2; gb = bytes / 1024^3; tb = bytes / 1024^4; printf "%s / %s / %d mb / %.1f gb / %.3f tb\n", $2, $10, mb, gb, tb printf "mean writes per hour: / %.2f", mb/poh } $0 ~ /Airflow_Temperature_Cel/ { print $2 " / " $10} $0 ~ /Wear_Leveling_Count/ { printf "%s / %d (%% health)\n", $2, int($4) } '; echo; } | sed -e 's:/:@:' | sed -e "s\$^\$$device @ \$" | column -ts@ } swaplist () { lastpid= swap=0 sudo grep -H '^Swap:' /proc/*/smaps 2>/dev/null | while IFS=: read -r file x size x do pid=''${file#/proc/} pid=''${pid%/smaps} size=''${size% kB} size=''${size##* } if test "$pid" = "$lastpid" then swap=$(( swap + size )) else if test "$swap" -gt 0 then printf "%u pid=%u cmd=%s\n" "$swap" "$lastpid" "$(tr '\000' ' '