oignon: uninstall chromium
[julm/julm-nix.git] / home-manager / profiles / bash.nix
index 7c314a67b9372759ca189d4176c6bfc30ecb911c..60dc75f69eef19c3e0edba4875a6b06d4d37bce3 100644 (file)
@@ -15,6 +15,7 @@ with lib;
       grep = "grep --color";
       j = "sudo journalctl -u";
       jb = "sudo journalctl -b";
+      ju = "sudo journalctl --user -u";
       l = "ls -alh";
       ll = "ls -al";
       ls = "ls --color=tty";
@@ -40,7 +41,6 @@ with lib;
       w10 = "watch --color --differences --interval 10";
       w = "watch --color --differences";
       watch = "watch --color --differences";
-      yt = "yt-dlp";
       zfs-umount = "zfs-unmount";
     };
     sessionVariables = {
@@ -74,6 +74,13 @@ with lib;
       mkpass () {
         tr -d -C 'A-Za-z0-9' </dev/urandom | head -c 25 | xclip
       }
+      opusenc-voice () {
+        find "$@" -depth -type f -print0 | sort -n -z |
+        xargs -0 -P "$(lscpu --online -p | grep -v "#" | wc -l)" -I {} bash -c '
+            test -e "''${0%.*}".opus ||
+            nice -n 19 ffmpeg -y -i "$0" -map 0:a -b:a 32k -application voip "''${0%.*}".opus
+          ' {} \;
+      }
       smartctl-tbw () {
         device=''${1:-/dev/sda}
         sudo smartctl -A $device |
@@ -126,8 +133,30 @@ with lib;
       }
       edit-in-commit () { $EDITOR $(git diff-tree --no-commit-id --name-only -r "$@"); }
       edit-in-git-grep () { $EDITOR $(git grep --name-only --recursive "$@"); }
-      zfs-mount () { for d in $(zfs list -rH -o name "$@"); do sudo zfs mount -l "$d"; done; }
+
+      # Recursively mount not-mounted dataset,
+      # loading their keys if needed.
+      zfs-mount () {
+        for d in $(zfs list -rH -o name "$@"); do
+          mountpoint /mnt/"$d" 2>/dev/null ||
+          sudo zfs mount -l "$d"
+        done
+      }
+      # Recursively unmount dataset,
+      # unloading their keys.
       zfs-unmount () { sudo zfs unmount -u "$@"; }
+
+      # Restore the inheritance of encryptionroot,
+      # usually broken by zfs send --raw.
+      # Note that it needs to decrypt the datasets.
+      zfs-fix-encryptionroot () {
+        zfs load-key "$1"
+        for i in $(zfs list -rHo name "$1" | tail -n +2); do
+          echo >&2 "$i"
+          test "$(zfs get -Ho value encryptionroot $i)" = "$1" ||
+          zfs change-key -li "$i"
+      done
+      }
     '';
     profileExtra = ''
     '';