clean dirty flake
[julm/julm-nix.git] / home-manager / profiles / bash.nix
index 13a77dbce7ad34cc4348716755499bc8bcf8009c..993b8f000525cd361e4b1ce465927cc174fd5e88 100644 (file)
@@ -3,39 +3,48 @@ with lib;
 {
   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";
+      d = "sudo resolvectl";
+      dust = "dust --bars-on-right --full-paths";
       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";
-      ju = "sudo journalctl --user -u";
+      jf = "sudo journalctl -f -u";
+      jf200 = "sudo journalctl -f -n 200 -u";
+      jftoday = "sudo journalctl -f --since today -u";
+      ju = "journalctl --user -u";
       l = "ls -alh";
       ll = "ls -al";
       ls = "ls --color=tty";
+      lst = "ls --sort=time --reverse -1";
       md-toc = "grep '^#\\+' --color";
       mem = "ps -e -orss=,user=,args= | sort -b -k1,1n";
       mem-top = "smem --sort rss --autosize";
       mpl = "mplayer";
+      n = "sudo networkctl";
       nf = "sudo nft list ruleset | less";
       nix-du-svg = "nix-du | dot -Tsvg >nix-du.svg";
       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";
+      nt = "sudo networkctl status";
       pass-gen = "tr -d -C A-Za-z0-9_- </dev/urandom | head -c";
       r = "reset";
       rot13 = "tr A-Za-z N-ZA-Mn-za-m";
       rot135 = "tr A-Za-z0-9 N-ZA-Mn-za-m5-90-4";
       rsync = "rsync --no-inc-recursive --info=progress2 --inplace --partial";
       s = "sudo systemctl";
+      sr = "sudo systemctl restart";
+      ssh-unknown = "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null";
       st = "sudo systemctl status";
+      smt-on = "echo on | sudo tee /sys/devices/system/cpu/smt/control";
+      smt-off = "echo off | sudo tee /sys/devices/system/cpu/smt/control";
       t = "tmux";
       t0 = "tmux new -t 0";
       t1 = "tmux new -t 1";
@@ -43,12 +52,15 @@ with lib;
       theme-black-on-white = "echo -e '\\033]10;black\\007\\033]11;white\\007'";
       theme-white-on-black = "echo -e '\\033]10;white\\007\\033]11;black\\007'";
       u = "systemctl --user";
+      ud = "resolvectl";
+      ur = "systemctl --user restart";
       ut = "systemctl --user status";
+      w = "watch --color --differences";
       w1 = "watch --color --differences --interval 1";
-      w5 = "watch --color --differences --interval 5";
       w10 = "watch --color --differences --interval 10";
-      w = "watch --color --differences";
+      w5 = "watch --color --differences --interval 5";
       watch = "watch --color --differences";
+      z = "zfs";
       ze = "sudo zpool export";
       zfs-umount = "zfs-unmount";
       zi = "sudo zpool import";
@@ -56,12 +68,22 @@ with lib;
       zlb = "zfs list -t bookmarks";
       zls = "zfs list -t snap";
       zm = "zfs-mount";
+      zp = "sudo zpool";
+      zs = "zpool status";
+      zs5 = "w5 zpool status";
       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)\$ '';
+      # More throughput than chacha20-poly1305@openssh.com
+      # on hardware with AES acceleration.
+      RSYNC_RSH = "ssh -c aes128-gcm@openssh.com,chacha20-poly1305@openssh.com";
     };
     initExtra = ''
       # Alias completion
@@ -77,7 +99,7 @@ with lib;
 
       ffmpeg-audio () {
         for i in "$@"; do
-          ffmpeg -i "$i" -vn -map 0:a -acodec copy "''${i%.*}".audio
+          ffmpeg -i "$i" -vn -map 0:a -acodec copy "''${i%.*}".audio-only.mkv
         done
       }
       ffmpeg-opus () {
@@ -85,6 +107,13 @@ with lib;
           ffmpeg -i "$i" -vn -map 0:a -c:a libopus -b:a 64k -application voip "''${i%.*}".opus
         done
       }
+      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
+          ' {} \;
+      }
       ibm-fan () {
         if [ $# -gt 0 ]
         then sudo tee /proc/acpi/ibm/fan <<<"level $1"
@@ -99,13 +128,6 @@ 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 |
@@ -160,19 +182,17 @@ with lib;
         done |
         sort -nk1,1
       }
-      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.
       zfs-mount () {
-        local d
-        local -
+        (
         set -e
         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.
@@ -189,7 +209,7 @@ with lib;
         set -x
         for d in "$@"; do
           for s in $(zfs list -Hrpt snapshot -o name "$d"); do
-            zfs bookmark "$s" "''${s//@/#}"
+            sudo zfs bookmark "$s" "''${s//@/#}"
           done
         done
       }
@@ -203,7 +223,7 @@ with lib;
         for d in $(zfs list -rHo name "$1" | tail -n +2); do
           echo >&2 "$d"
           test "$(zfs get -Ho value encryptionroot $d)" = "$1" ||
-          zfs change-key -li "$d"
+          sudo zfs change-key -li "$d"
       done
       }
 
@@ -212,14 +232,13 @@ with lib;
         local d
         for d in "$@"; do
           zfs list -t snapshot -rHo name "$d" |
-          xargs --no-run-if-empty -L1 zfs destroy
+          sudo xargs --no-run-if-empty -L1 zfs destroy
         done
       }
     '';
     profileExtra = ''
     '';
   };
-  programs.direnv.enableBashIntegration = true;
   #programs.broot.enableBashIntegration = true;
   programs.readline = {
     enable = mkDefault true;