Monday, November 26, 2012

XPRA, mosh, and tmux - a little slice of heaven

XPRA is basically mosh for X environments.  It lets you connect to an X environment in a persistent way.

So, my new workflow uses mosh, tmux and XPRA to accomplish great things.

On work machine:

 xpra start :7 && DISPLAY=:7 tmux new -s remote


which will start an xpra server on display hook 7, and launch a new tmux instance with name 'remote' that is attached to said display device. This ensures that whenever we try to launch an X instance (i.e. 'ipython --pylab' ) it will be able to attach to an X device

On laptop:

 xpra attach ssh:<hostname>:7 & mosh <hostname> -- tmux attach -t remote

This will have xpra attach to the remote X session display, and run mosh for a persistent ssh connection to my work machine, and once connected attach to my remote tmux session which already is connected to the xpra display, and I have a working, fast persistent ssh + X forwarding connection to my work computer.

 What this means is that I have a connection to my work computer that behaves transparently as if it were my work computer, plus will fix itself if I put my laptop to sleep and wake it back up. So I can plot things in ipython all I want without a care in the world.

For extra fun, alias those commands on the respective machines to make your life easier.

No comments:

Post a Comment