18 November 2013
Vim’s yank/paste inside of a Tmux instance on OSX is broken. I’ve tried the copy-pipe workaround, but I don’t like it. It’s too bad, because Tmux is fantastic otherwise. That said, I probably use 20% of it’s functionality at most. iTerm2 is ok, but I miss session support. Enter dvtm and dtach, which combined, emulate almost all of Tmux’s functionality that I used.
Install dvtm and dtach with
brew install dvtm dtach (assuming you have homebrew installed), and start a new instance of dvtm with
The default modifier for dvtm is
Ctrl g. With Tmux, I’d rebound the modifier to
Ctrl A, and was planning on doing that here, but I actually like
Ctrl g more. I’d you’d like to change it, use the
-m command flag. IE:
dvtm -m a will set the modifier to
Now that you’ve got dvtm started, create a new window with
MOD c. Close it with
Moving between open windows is simple. You can use your mouse or use
MOD j or
MOD k to switch back and forth. Additionally,
MOD #, where
# is the window number, will move you to the apporpriate window.
Exit dvtm with
dvtm gives you some flexibility in how you’d like to manage your windows. The simplest is
MOD h or
MOD l, which will resize the window laterally.
In addition, dvtm supports the following layouts:
Cycle between the layouts with
Last thing I’ll mention here is the ability to minimize windows. I use this frequently when I’m starting any sort of watch process that I want to group with what I’m working on, but not something I necessarily want to see. Minimize with
Integrating with the system copy/paste
The only wonky thing you’ll have to deal with is copying and pasting from dvtm to the system clipboard, but it’s easy.
MOD M will enable mouse selection of whatever it is you want to grab. Your native copy command will grab what you need.
Using dvtm with dtach
From the man page:
dtach is intended for users who want the detach feature of screen without the other overhead of screen. It is tiny, does not use many libraries, and stays out of the way as much as possible… dtach relies on the ability of the attached terminals to manage the screen
- Create, and attach to a new session with
dtach -A /tmp/sessionName -r winch dvtm
- Do your thang
- Detach with
- Reattach with
dtach -a /tmp/sessionName
If you want to delete the session entirely:
In the few dtach examples I’ve seen, everyone kept referring to
winch. What’s that you ask? It deals with how dtach redraws windows.
WINCH is a signal sent to a process when its controlling terminal changes its size.
Why this is useful? Image you open 2 dvtm windows. You close one. The screen changes. Without
WINCH, the remaining window wouldn’t redraw to fill the space vacated.
- 2 Alternatives to GNU Screen for Linux Terminal Multitasking
- Screen, TMUX, and dvtm + dtach