]> git.phdru.name Git - dotfiles.git/commitdiff
.bashrc: Save/restore history before/after X
authorOleg Broytman <phd@phdru.name>
Sun, 11 Sep 2022 07:20:37 +0000 (10:20 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 11 Sep 2022 07:20:37 +0000 (10:20 +0300)
.bashrc

diff --git a/.bashrc b/.bashrc
index 4f3d23ee8c68c32a1e80a900534d17b4dc7c31f0..7a874bf93d1511cc1c6afa9e288d66d8a92d481e 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -295,3 +295,22 @@ if test -x /usr/bin/git >/dev/null 2>&1; then
 
     complete -F _git_open_remote git-open-remote
 fi
+
+
+if [ "$SHLVL" -eq 1 -a "`type -t X`" = function ] && which startx >/dev/null 2>&1; then
+    # From https://stackoverflow.com/a/18839557
+
+    copy_function() {
+      test -n "$(declare -f "$1")" || return
+      eval "${_/$1/$2}"
+    }
+
+    rename_function() {
+      copy_function "$@" || return
+      unset -f "$1"
+    }
+
+    rename_function X _non_bash_X
+
+    X() { history -a; _non_bash_X; history -r; }
+fi