Created
November 5, 2014 20:55
-
-
Save eresonance/9184fc348af21081a66f to your computer and use it in GitHub Desktop.
Changing an environment variable on every open shell on a remote machine
This file contains 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
#this only works if your home dir is shared/mounted on every machine | |
remote="remote.machine.name" | |
user=$USER | |
shell=bash | |
#on login, see if this is an exceed session or not | |
if [ -n "$XCONFIG_NAME" -a -n "$XSTART_NAME" ]; then | |
#following is not totally necessary | |
echo $DISPLAY > ~/.display | |
#do something crazy, change the DISPLAY variable in every bash terminal | |
# to the newly created exceed client, but do that on las-sw-01, not the | |
# current box :P | |
for pid in $(ssh $remote ps -u $user -U $user | awk "/$shell/"' { print $1 }'); do | |
echo "pid: $pid" | |
cat > ~/tmp/gdb_bash <<EOF | |
attach $pid | |
call putenv ("DISPLAY=$DISPLAY") | |
detach | |
quit | |
EOF | |
ssh $remote gdb -quiet -x ~/tmp/gdb_bash 2> /dev/null | |
done | |
rm -f ~/tmp/gdb_bash | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Work is using exceed on demand for X11 forwarding (it's actually fairly nice for GUI stuff) but I like using mosh for shell stuff since it's lighter-weight. What this does is sets the DISPLAY variable in every bash shell open on a specific box (the one I'm using mosh+tmux to connect to) every time a new exceed session is started. This allows me to use mosh for shell stuff onto a box, and then when I run
diffuse
orgvim
or whatever on that shell it will X11 forward using exceed, which renders everything a lot faster than normal ssh X11 forwarding.