summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bashrc11
-rwxr-xr-xbin/update-emacs-daemon-environment28
2 files changed, 39 insertions, 0 deletions
diff --git a/.bashrc b/.bashrc
index 10b264ba..fdd6683a 100644
--- a/.bashrc
+++ b/.bashrc
@@ -168,6 +168,17 @@ kill-remote-gpg () {
ssh -O exit "$1"
}
+upenv () {
+ # don't want to do this outside of tmux as then tmux show-environment will
+ # show values for the 'default' session which may be irrelevant to us
+ if [ -n "$TMUX" ]; then
+ for var in $(tmux show-environment | grep -v "^-"); do
+ eval "export $var"
+ done
+ fi
+ update-emacs-daemon-environment
+}
+
# build debs from a Linux kernel source tree *without* calling `make clean`.
#
# The -dbg deb takes some time to build. To get rid of it when it's
diff --git a/bin/update-emacs-daemon-environment b/bin/update-emacs-daemon-environment
new file mode 100755
index 00000000..57a59f1b
--- /dev/null
+++ b/bin/update-emacs-daemon-environment
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# Update Emacs daemon environment vars for a new interactive session. This
+# allows us to have the Emacs daemon survive restarts of the graphical desktop
+# environment, and to update Emacs on a remote host when there is a new
+# forwarded SSH agent socket.
+#
+# Note that this will start the Emacs daemon if it not up already.
+
+which emacsclient >/dev/null || exit 0
+
+for var in DISPLAY \
+ SSH_ASKPASS \
+ SSH_AUTH_SOCK \
+ SSH_AGENT_PID \
+ SSH_CONNECTION \
+ WINDOWID \
+ XAUTHORITY; do
+ eval isset=\${$var+x}
+ if [ "$isset" = "x" ]; then
+ eval value=\$$var
+ emacsclient -eval '(setenv "'$var'" "'$value'")'
+ fi
+done
+
+# finally, also call a function which now updates the values in our Lisp image
+# from Emacs' values (unimplemented)
+# emacsclient -eval '(spw/update-lisp-image-environment)'