Created
January 13, 2015 04:02
-
-
Save realmtai/cdaf263db37a833756f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in your ~/.bashrc, add the following | |
# -- Improved X11 forwarding through GNU Screen (or tmux). | |
# If not in screen or tmux, update the DISPLAY cache. | |
# If we are, update the value of DISPLAY to be that in the cache. | |
function update-x11-forwarding | |
{ | |
if [ -z "$STY" -a -z "$TMUX" ]; then | |
echo $DISPLAY > ~/.tmux.display.txt | |
else | |
export DISPLAY=`cat ~/.tmux.display.txt` | |
fi | |
} | |
# This is run before every command. | |
preexec() { | |
# Don't cause a preexec for PROMPT_COMMAND. | |
# Beware! This fails if PROMPT_COMMAND is a string containing more than one command. | |
[ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return | |
update-x11-forwarding | |
# Debugging. | |
#echo DISPLAY = $DISPLAY, tmux.display.txt = `cat ~/.tmux.display.txt`, STY = $STY, TMUX = $TMUX | |
} | |
trap 'preexec' DEBUG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment