70 comments

[ 3.0 ms ] story [ 191 ms ] thread
I'd add <prefix> w to that list, which shows an interactive list of opened windows which is very friendly to newcomers, does away with the base-index setting that's needed to fix cognitive dissonance of tab order vs key order, and circumvents the inconvenience of having to use shift to reach for numbers on non-US layouts.

> Ctrl a (a little faster to type, doesn’t conflict with vim

... but conflicts with beginning-of-line emacs-style bindings, widely in use in readline/libedit/zsh.

Exactly. I use C-z on mine
Doesn't that mess with job control in your shell?
I think I could live w having to “quote” ^Z to suspend a job, but worry I’m going to have ^Z baked-into my muscle memory and end up accidentally suspending jobs on non-tmux sessions.
But that's not a bad thing.. fg it back. ^z is my preference for tmux too.
Interesting. After I posted my comment I saw elsewhere that you can simply hit ^z twice to suspend so I guess that's not a big deal after all.
Yeah I just hit ^z twice to suspend now, and if I do it by mistake (which really rarely happens) I can fg.
(comment deleted)
I had remapped <prefix> w to cycle to the next pane so I had no idea of the window list. Thanks for that.
> I'd add

I'd add stuff too, but I think we need to resist the temptation. The article succeeds in presenting the absolute bare minimum you need to get started. In fact, I think the author chose his features well but used too many words to present them.

C-a seems to be quite a common prefix, but as you said, it conflicts with the beginning-of-line command. I’ve been quite happy with C-s so far; if it conflicts with something, I have no idea.
^S is XOFF of software control flow fame. You shouldn't need to worry about it though.
It's a common prefix because it's what gnu-screen uses by default, which is what everyone was using for 20 years before tmux came along.
C-s searches forward where C-r searches backwards, if you're used to using C-r to retrieve an earlier command via incremental search.

If not otherwise configured with stty, it's frequently set up for control flow along with C-q. If you find your terminal freezes after typing C-s, C-q will unfreeze it.

Disable with:

    stty -ixon start undef stop undef
Thanks, I didn’t know that! I use the fish shell, which does history searching differently but this is useful for those few times when I’m in bash.
Ctrl-j is excellent for me as a vim user. It's default behavior is to just move the cursor one line down which you can already do by pressing... j (although Ctrl-j can be used in insert mode if I recall correctly).
Mapped mine to Ctrl-Space, no conflicts.
I use ^_ (0x1F) which can be "typed" with Ctrl + 7 and Ctrl + / in most terminals.
As a long-time ‘screen’ user, the Ctrl-A issue is almost completely a non-issue. One can easily send a Ctrl-A to the underlying shell using Ctrl-A A. I assume ‘tmux’ has something similar. It’s also pretty rare to need the “beginning of the line” movement in a shell, when compared to the number of times one needs to control the multiplexor. Ctrl-A is also very close at hand, and the vast majority of people are using PC keyboards which also have a Home key that work just as well for movement.
Took me a while to figure out why I had to press C-b twice to go back in emacs. Reconfigure your tmux prefix ;)
I had "fun" nesting ansi-terms with tmux sessions of emacs in emacs (as you do).

so much quinning

C-b C-b C-b C-b. Oh my... happened to me too. I think this is when I finally understood what was happening.

  # remap prefix from 'C-b' to 'C-a'
Still hate the tmux devs for that default value, but hell there is so much good they did, so I can forgive them that :D
C-a is a non-starter for people who use Emacs/OS X key bindings for move-beginning-of-line.
C-b is pretty bad for the same reason for users like me with with well-worn emacs key memory. I end up using the backtick, but it does make sharing a session that little bit more difficult.
adding

  bind C-a send-prefix  
to your .tmux.conf file will allow you to type C-a twice and still get to the front of the line
I'm not sure about tmux, but you can still move to the beginning of the line by pressing C-a a in screen.
the urban legend is that they were developing and testing tmux inside of screen, which is why they needed a different prefix
my minimalist guide to tmux : I use byobu.
Of all the previous tmux discussions, the most practical help was given when this article was discussed 2 months ago:

[dupe] https://news.ycombinator.com/item?id=15776995 (267 points, 96 comments)

Surprised to see it again so soon -- darn you Medium flexible URLs!

PS. Anyone willing to earn $400 implementing mosh ssh port forwarding https://www.bountysource.com/issues/4471419-ssh-port-forward..., or should I move on to the mentioned alternative https://mistertea.github.io/EternalTCP?

PPS. Bountysource feels sketch: https://hn.algolia.com/?query=bountysource

Tmux is awesome. Although I never understood why they used ctrl-b instead of ctrl-a as the default though - incompatible with screen and hard to reach with one hand.
Probably since ctrl-a is a well-loved bash shortcut for goto start-of-line.
I assume that shortcut predates the existence of the Home key? Maybe we can let it die.
The home key is in a terrible, terrible place on the keyboard and missing in many laptop keyboards. Ctrl-A is much easier to reach while touch typing, especially after remapping Caps Lock to Ctrl.
I hope not. I actually find C-a and C-e (for end) _much_ easier to type, especially with Caps Lock remapped to CTRL.
And my own personal muscle memory prefers a different setup, so that's why these things should be configurable, but the defaults should probably match common conventions don't you think?
I disliked ctrl-a and ctrl-b as prefixes because both conflict with using emacs keybindings. However, it was convenient that, by default, they were different. When I first used tmux I was still using screen on some servers (that I didn't fully control). Being able to use screen on the server through my tmux session without having to double type the prefix was useful.
I used ` for a long time, but it got old pasting old-fashioned shell scripts (which use `…` instead of $(…)).

Nowadays I use C-z: easy to hit with one hand, and easy enough to do C-z C-z if I actually want to suspend something.

start using keyboards that allow you to use left ctrl with your palm instead of your pinky, it's a life saver.
CTRL-A is the default for GNU Screen, and when you're developing a terminal multiplexor, you sometimes want to work on it inside the terminal multiplexor you're hoping to improve upon. :)

See the tmux FAQ: https://github.com/tmux/tmux/wiki/FAQ

> Let’s say you’re using vim to edit code on a remote computer using ssh, and you want to open a new terminal tab to start a development server.

vim 8 has a built-in terminal.

  :terminal ./start-development-server.sh --port 8080
will open a new buffer in a split window that executes the given command line. And it even supports all the regular vim keybindings.

  :help terminal.txt
for details.
Somewhat off topic: the wonders of competition, at work! :)
Thanks for sharing this! Vim is the kind of tool I use all the time, but never check for new features. Will definitely use :terminal all the time now :).

(For anyone interested, it looks like only more recent releases of vim 8 have :terminal.)

Yes, it was added only recently after Neovim showed the idea of terminal buffers to be feasible.

So it may not be available on $random_rhel6_server, but since the article described the scenario of a development server, I figured that package versions on there should be fairly recent.

I've stopped using tmux locally because vim terminals are so darned convenient
nvi (default vi on (I believe) Net (and therefore Minix), Free, and OpenBSD) supports what sounds similar via “:script”. You have to split your window (or fg/bg the buffer) manually, though.
tmux always seems kind of cool but I have a hard time seeing an advantage over just running multiple terminal windows, using mosh if remote.
Sometimes you're in an actual TTY, not a windowed terminal.
Being able to bring up my shell session if I accidentally quit the terminal emulator has been a really helpful feature for me.

    tmux new-session -d [-s <session_name>] <command>
is nohup/dtach on steroids.
I like the ability to close the window without losing my workspace and, for the specific case of mosh, tmux allows me to have scrollback history.
When working remote from a DSL line with random disconnects or stupid 24 reconnects / ip address changes, or via unreliable mobile tethering, a screen/tmux session saves you from accidentally killing important, long running jobs or missing important outputs, among other things.
A while ago I saw comments here about tmuxinator. Which was a fantastic improvement to my tmux use. Create a layout manually, get the layout from tmux and then set it up to launch a custom set of windows, panes, and programs based on my project needs. Doing this easily and repeatedly makes it trivial for me to set aside a task and come back to it later and be confident I will have everything in view that I need.

https://github.com/tmuxinator/tmuxinator

been using mosh + tmux for couple years and it's been great. Amazing how a tiny bit of work flow improvement increase productivity.
I could never get into tmux since it doesn't play nicely with iTerm2 and the mouse. With iTerm2 panes, you can select/copy/paste text within the pane even if it's over multiple lines. In a tmux session, you select all text across all panes.

Ditto goes for scrolling: Native windows scroll more naturally than tmux with mouse support.

There are two things you can do:

1. iTerm2 has tmux integration, a new panel in tmux automatically maps to a new tab in iTerm2 2. You can enter copy/paste mode in tmux.

Agree- this is a "pain." When I want to select text I make all panes horizontal. Not elegant, but it works. Then I put them back.
Hold option while you're selecting
iTerm has a setting that makes it respect "soft boundaries" that solves this problem. (Edit -> Selection Respects Soft Boundaries)
Awesome Guide. Definitely liking the move to tmux!
I've never used tmux because I've always used screen. Is there a reason to drop screen for tmux?
Apparently I'm the only one who doesn't mind ctrl-b as the prefix.
Highly recommended: byobu, a screen+tmux configuration that works well and is available on Ubuntu and in other places.