Commit 1d47091

HPCesia <me@hpcesia.com>
2026-09-02 15:22:57
shell: make history save immediately
1 parent 9bc2fd2
Changed files (1)
modules
modules/core/shell.nix
@@ -56,5 +56,23 @@
         '';
       };
     };
+
+    provides.to-users = {
+      hjem = {lib, ...}: {
+        files.".bashrc".text = lib.mkOrder 2000 ''
+          shopt -s histappend
+          __ix_history_flush() {
+            history -a
+          }
+          if [[ ";''${PROMPT_COMMAND[*]:-};" != *";__ix_history_flush;"* ]]; then
+            if [[ "$(declare -p PROMPT_COMMAND 2>&1)" == "declare -a"* ]]; then
+              PROMPT_COMMAND=(__ix_history_flush "''${PROMPT_COMMAND[@]}")
+            else
+              PROMPT_COMMAND="__ix_history_flush''${PROMPT_COMMAND:+;$PROMPT_COMMAND}"
+            fi
+          fi
+        '';
+      };
+    };
   };
 }