How Pivotal Labs use Tmux for remote pair programming
pivotallabs.com
pivotallabs.com
I highly recommend the book. Absolutely love it.
https://github.com/rahulkmr/dotfiles/blob/master/.tmux.conf
C-a c new window
C-a | vertical split
C-a S horizontal split
etc etc.
As far as copy paste goes, I use this https://wiki.archlinux.org/index.php/Tmux#ICCCM_Selection_In... C-a C-c copies tmux buffer to clipboard, C-a C-v sets tmux buffer to clipboard and pastes it(it's already in the configs; just putting it here).
As far as terminal emulators go, I have tried out a lot of them(gnome-terminal, konsole, urxvt, xterm) and finally settled on terminator. gnome-terminal will keep messing with my readline settings(alt opens up the menu), urxvt won't let me copy-paste the clipboard...Terminator is no frills - you can graphically set the preferences, or have a config file; it lets you copy paste to and from the clipboard; you can configure it to copy the x-selection to clipboard(middle click to paste - just not it). For anyone looking for a terminal emulator on linux(or whatever other platforms it runs on), I highly recommend it.
When I create a couple of windows and I split one of those into 2 panes, I couldn't manage to move panes from one window to another. In screen, apps you run are absolutely detatched from any visual configuration, and everything is reachable from everywhere.
It's a bit difficult to explain, but I'm sure some screen users will understand that situation. That is what also got me hooked to ratpoison[1] wm.
Does that help?
Yeah, this kind of works, but I need to do maybe too many steps to get what I want, maybe with some tmux scripting fu I'd make it work.
The main issue is that I can open my apps always in the same order, so I know wich window number it has, then, joining-pane by window number would be doable. the problem is that after breaking and joining a few times, numbers may get scrambled.
Another issue is that if an app is in a pane, it looses the identity, and cannot be joined to another window alone.
I'm thinking on doing something in the lines of:
WINDOW=`tmux list-windows | grep active | sed -e 's/^\(.\).*/\1'`
choose-window "join-pane -s $WINDOW -t %%"
But for the moment, no luck.
Will keep trying :)
however, in tmux.. what you have is like a whole series of pane containers.. these are called windows.. now, each window can have a name.. whilst a pane on its own does not.. you can fortunately 'join' and 'send' panes between windows.. also, another thing I tend to find useful is the ability to 'break' a 'pane' out've its current window and devote a full window to it..
the .tmux.conf bits you need are
bind-key 'j' command-prompt -p "join pane from:" "join-pane -s '%%'"
bind-key '@' command-prompt -p "send pane to:" "join-pane -t ':%%'"
whilst :break-pane (or ^b ! by default) allows you to send a 'pane' away to its own window.. (apologies it that sounds awfully convoluted/confusing)
Maybe that's as far as we can get by now with it. Luckily tmux is heavily developed so there's hope for that workflow being easily usable in the future.
Screen is nice, sure, but tmux has a couple of tricks up its sleeve.
And if your net connection is a little shaky, tmux can save your sanity (whereas screen just hangs there)
Just took a screenshot to show it off, easy to understand when you look at this: http://dl.dropbox.com/u/191376/Screenshots/mb06.png
tmux being shell-friendly means I write one shell script for each project, and if I restart the system for some reason, I open the terminal and run tmux-foo. tmux-foo creates a session, cds to project root and create multiple windows, opens vim in one, rails s in another, logs in another, rails console, dbconsole etc etc.
If you are curious, pick a config which gives you screen like keybindings(tmux uses c-b; I swore to screen long back I would use c-a) and try it for some time. As far as user experience goes, you have everything you had in screen with some added benefits(no, it isn't bmw)
...except for serial communication. Because I connect to various hardware UART devices all day, I need serial communication. I hate minicom and most of the other serial comm programs don't have the features I need.
Since I'm already using screen as my serial communication software, I go ahead and use it for terminal multiplexing and session management as well.
(this makes sense if you use Ctrl-A as 'Home')
there's various different work arounds.. a recent one I came across was to make sure your vim is compiled with +xterm_clipboard and +clipboard.. then doing "r+ allows you to paste directly from your clipboard using vim rather than relying on whatever your terminal emulator gets up to..
vim --version | grep clipboard to check how your vim was compiled
also, adding the following to ~/.tmux.conf is useful
--------------
#copy tmux paste buffer to clipboard
bind C-c run "tmux show-buffer | xclip -i -selection clipboard"
#copy clipboard to tmux paste buffer and paste tmux paste buffer
bind C-v run "tmux set-buffer --- \"$(xclip -o -selection clipboard)\"; tmux paste-buffer"
If possible, upgrade the upload speed of the host or even arrange the pairing such that the person with the most upload bandwidth is hosting the remote pairing session. After an office network upgrade to 20Mbs/up desktop screen sharing -- that is, GUI-based and not ssh/tmux based -- is extremely fast and completely usable.
This means that the iTerm2 window size is the tmux window size; tabs in iTerm2 are tabs in tmux. Horizontal and vertical window splits in iTerm2 are the same in tmux too. And all of this is bound to the GUI, so resizing/reordering panes with your mouse makes the proper modifications in tmux. And because this is a 1:1 mapping of functionality, others using the same native integration will see tabs and split panes get added and removed in real time, as someone on another machine does it.
It's still in early stages and definitely not bug-free, but this is absolutely the best multiplexing experience I've found. Unfortunately, because this is specifically for iTerm2 right now, it's not cross-platform.