Fun with tmux & dtach

Generally the problem with running a terminal multiplexer like tmux or screen on a remote server: is if the server goes down so does your session. Like wise an issue will eventually crop up where in you have to SSH into another server or even the box you’re sitting in front of, if you don’t want a seperate xterm in order to do it; thus losing all that multiplexer goodness.

Well, I pretty much run the session (tmux btw) on my system, and then use dtach for running things I may want to detach from—like a big compile. One perk of this is I get to have my “notes” window in tmux without double the latency.

Today, I was thinking about how can I link this notes window to various tmux sessions? It is possible to link windows (linkw) in a session and entire sessions (new -t {other session}) but that is not what I want. dtach again to the rescue! My notes script already amounts to opening my “Scratch” note file in vim, and changing the window name to “notes” if used in tmux. So I modified it to be smart enough to run vim in dtach, or reattach. Thusly, I can have tmux sessions by project, home, etc, and share the same vim session between them using dtach.

Note tacular!