{
programs.bash = {
enable = mkDefault true;
+ enableCompletion = mkDefault true;
shellAliases = {
+ afk = "xset s activate dpms force off";
black-on-white = "echo -e '\\033]11;black\\007\\033]10;white\\007'";
c = "bat";
cl = "clear";
- eic = "edit-in-commit";
- eigg = "edit-in-git-grep";
emacs = "emacsclient --create-frame";
g = "git";
+ ge = "git-edit-commit";
gg = "git grep";
+ gge = "git-grep-edit";
grep = "grep --color";
j = "sudo journalctl -u";
jb = "sudo journalctl -b";
w10 = "watch --color --differences --interval 10";
w = "watch --color --differences";
watch = "watch --color --differences";
+ ze = "sudo zpool export";
zfs-umount = "zfs-unmount";
+ zi = "sudo zpool import";
+ zl = "zfs list";
+ zlb = "zfs list -t bookmarks";
+ zls = "zfs list -t snap";
+ zm = "zfs-mount";
+ zu = "zfs-unmount";
};
+ historyControl = [ "erasedups" "ignorespace" ];
+ historyIgnore = [
+ "torify"
+ "mpv"
+ ];
+ historySize = 42000;
sessionVariables = {
- HISTCONTROL = "erasedups:ignorespace";
- HISTSIZE = "42000";
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)\$ '';
};
initExtra = ''
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 ~ /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
+ 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) }
+ $0 ~ /Percentage Used:/ { printf "Percentage_Used / %d\n", int($3) }
'; echo; } |
sed -e 's:/:@:' |
sed -e "s\$^\$$device @ \$" |
done |
sort -nk1,1
}
- edit-in-commit () { $EDITOR $(git diff-tree --no-commit-id --name-only -r "$@"); }
- edit-in-git-grep () { $EDITOR $(git grep --name-only --recursive "$@"); }
+ git-edit-commit () { $EDITOR $(git diff-tree --no-commit-id --name-only -r "$@"); }
+ git-grep-edit () { $EDITOR $(git grep --name-only --recursive "$@"); }
# Recursively mount not-mounted dataset,
# loading their keys if needed.
# unloading their keys.
zfs-unmount () { sudo zfs unmount -u "$@"; }
+ # Create bookmarks for all the snapshots of the given datasets.
+ # Bookmarks are only useful on source datasets
+ # But syncoid --create-bookmark only creates
+ # a bookmark for the latest snapshot,
+ # possibly leaving the *_daily or *_monthly snapshots without a bookmark.
+ zfs-fix-bookmarks () {
+ local d
+ local -
+ set -x
+ for d in "$@"; do
+ for s in $(zfs list -Hrpt snapshot -o name "$d"); do
+ zfs bookmark "$s" "''${s//@/#}"
+ done
+ done
+ }
+
# Restore the inheritance of encryptionroot,
# usually broken by zfs send --raw.
# Note that it needs to decrypt the datasets.