about summary refs log tree commit diff
path: root/configs/shared/zsh/functions.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'configs/shared/zsh/functions.zsh')
-rw-r--r--configs/shared/zsh/functions.zsh15
1 files changed, 15 insertions, 0 deletions
diff --git a/configs/shared/zsh/functions.zsh b/configs/shared/zsh/functions.zsh
index 645426cd9044..c0f6e21e4613 100644
--- a/configs/shared/zsh/functions.zsh
+++ b/configs/shared/zsh/functions.zsh
@@ -202,6 +202,21 @@ kush() {
 }
 
 # Misc
+update_x11_forwarding() {
+  # Sometime Tmux misbehaves with X11 applications (e.g. Emacs). This is because
+  # the DISPLAY variable is not set properly to `:0`. This function w
+  # Cache the DISPLAY when outside of Tmux. When inside of Tmux, use the cached
+  # value for DISPLAY.
+  #
+  # This cooperates with my `preexec` function, which runs before every command.
+  # Adapted from here: http://alexteichman.com/octo/blog/2014/01/01/x11-forwarding-and-terminal-multiplexers/
+  if [ -z "$TMUX" ]; then
+    echo $DISPLAY > ~/.display.txt
+  else
+    export DISPLAY=$(cat ~/.display.txt)
+  fi
+}
+
 monzo_balance() {
   # Return the balance of my Monzo bank account. Intended to be used in my i3
   # status bar.