3 ms·
I have a feeling tmux would be useful to me, but it seems to be one of these things where all the documentation is useless unless you already understand it. I
by kps 13y ago
I have a feeling tmux would be useful to me, but it seems to be one of these things where all the documentation is useless unless you already understand it.
I understand it's a terminal multiplexer: so, on the one side, I have one or more terminals (typically pseudo; X or ssh in my case), and one or more ∗nix sessions (typically each a single process group; shells and their children like editors). In between sits tmux, with its 'sessions' and 'windows' and 'clients' and 'buffers' and 'panes'. What are these things, how are they related, and how do they correspond to ∗nix sessions and terminals?
Or have I got it all wrong?
http://i.imgur.com/zJGunty.png http://i.imgur.com/zJGunty.png
- ihodes 13y agoI just wrote a little blog post that explains these terms and gives you my basic use-case for tmux. Let me know if it's helpful? http://copperthoughts.com/p/tmux-simply-explained/ http://copperthoughts.com/p/tmux-simply-explained/
- elwin 13y agoWhen you type "tmux" into a terminal, that starts a client. A client is the instance of tmux that's running in your terminal emulator. tmux manages a collection of pseudoterminals, and clients display whatever is going on in that collection. (Warning: some oversimplifications.) This collection of pty's is called a session. Each pty within it is called a window. When you start, there will be one session containing one window. You can add more windows (C-b c) and switch the one your client is currently viewing (C-b p, C-b n, etc.) Each new window will start a shell that you can use to run programs independently. Detaching (C-b d) means disconnecting your client from the session and exiting. Attaching ("tmux attach") reconnects to the session. Multiple sessions and multiple clients are an advanced topic. Don't worry about them yet. Unix sessions are unrelated to tmux sessions. Technically, each pty managed by tmux has its own Unix session. Buffers and panes are advanced topics. Buffers help with copying and pasting; panes let you split windows into multiple pty's. Don't worry about either of them yet.
- kps 13y agoThanks. I'm primarily interested in the m:n case, but your explanation has given me the right terminology to use in searches.
- jholman 13y agoNice PNG, heh. First of all, "clients" are the things that TFA labels "tmux (screen)". Each of "windows" and "panes" are things you can ignore, or not, as you find them useful. Windows are like browser tabs, panes are screen-splits. I use windows, I don't (yet) use panes. Otoh, many people are in it just for the planes. YMMV. But you cannot use tmux without "clients" and "sessions". Second of all, `man screen` does discuss the theory and how things interact. So if you have 20 or 30 minutes, you can read the man page and basically Learn All The Things. ---------- Third, you said you're interested in m:n. Maybe my tmux workflow is relevant to you. I have, let's imagine, a need for 5 terminals. "notes", version-control, make/tests/etc, misc-bash, and vim. I make space on my desktop physical monitor for three terminals (100x60); but only one on my laptop (100x40). I start by creating one Session that contains five Windows, and each window corresponds to one of the five ptys that I want (notes, vcs, make, bash, vim). But I can only view one of these at a time, right? TMUXSESS=foo tmux new -d -n notes -s "$TMUXSESS"1 # new detached session "foo1", with window "notes" tmux neww -P -n vcs -t "$TMUXSESS"1: # new window "vcs" in existing session "foo1" tmux neww -P -n make -t "$TMUXSESS"1: tmux neww -P -n bash -t "$TMUXSESS"1: tmux neww -P -n vim -t "$TMUXSESS"1: So now I could connect three (or twenty) clients all to the same session. BUT, this isn't the solution, because they'd all the same view of what I'm doing (which is amusing at first, but useless). But, hooray, introducing another tmux concept, "groups". "Groups" are groups of sessions, that contain the same windows, but do not have to share a view. tmux new -d -s "$TMUXSESS"2 -t "$TMUXSESS"1 # new session "foo2" grouped with "foo1" tmux new -d -s "$TMUXSESS"3 -t "$TMUXSESS"1 Now I open my three gnome-terminals. In the first one I do tmux a -t "$TMUXSESS"1 # attach to "foo1" and likewise for the second and third. And if I feel like working from my laptop, I vpn+ssh to my desktop, and just attach another tmux client to foo1 or foo2 or foo3. This one shares a lock-stepped view with the session it's attached to, but who cares, I'm not watching the desktop. Tmux resizes every session to the minimum-sized attached client, so it's important that I detach my laptop-client when I wanna go back to my desktop. If I forget, no problem, tmux lets me do that from either keyboard (though I have to look up the syntax to do it from my desktop's keyboard). So, 5 things to look at, 3 or 4 views into those things, arbitrary swapping each to the other. I haven't been using this very long. It's GLORIOUS. Does that help?
- 13y ago