9 ms·
This is written for the Linux-on-the-Desktop crowd, and good for them. But tmux really shines for folks using MacBooks with iTerm2. Its tmux integration is so g
by jelder 1y ago
This is written for the Linux-on-the-Desktop crowd, and good for them. But tmux really shines for folks using MacBooks with iTerm2. Its tmux integration is so good that it simply disappears into my workflow.
With this in my `~/.ssh/config`, I can just type `ssh tmux` to get back to my remote dev box whenever I wake my computer or change connections.
Host tmux
HostName 1.2.3.4
IdentityFile ~/.ssh/etc.etc.etc
RequestTTY force
RemoteCommand tmux -CC new -A -s 0
With iTerm2's tmux integration enabled, this will pop open a new window where the remote tmux tabs and scroll buffer look and act just like native, local iTerm2 tabs and scroll buffer. I don't even know any tmux commands.
- crtasm 1y agoThen a nice addition is to save typing it each time alias looptmux='while true; do ssh tmux; sleep 2; done'
- nolist_policy 1y agoBetter: autossh -M0 tmux
- suslik 1y agoWow, I've tried tmux like a hundred times and could never learn to like it, falling back to screen and promising to myself - never again. I'm going to break my promise to try this.
- antonvs 1y ago> falling back to screen So you're saying you're a masochist
- hdgvhicv 1y agoI’ve used screen for 25 years. What am I missing without tmux?
- em-bee 1y agomainly sessions, i think, and maybe scripability. sessions are groups of windows. i have one session per project or work mode. (one for email and connecting to remote machines, one for writing stuff, one for managing my hobbies, one for dev work...)
- nothrabannosir 1y agoScreen has sessions. You can name them, and choose which session to resume when you reconnect. I use tmux now because it’s supposed to be cool but secretly like gp I also wonder what the actual difference is , besides a different default leader key. Oh and killer iterm2 integration.
- em-bee 1y agoit's been a long time since i used screen. afaik screen had one session per process. you could switch processes by detaching from one and attaching to another. in tmux it's all one process, which allows you to create new sessions and switch them interactively and move windows from one session to another, or even have a window in more than one session. i can also see all windows from all sessions: (0) - main: 6 windows (1) ├─> 0: elvish- (2) ├─> 1: elvish*: "[mosh] embee@foo:~" (3) ├─> 2: elvish (4) ├─> 3: elvish: "embee@bar:~" (5) ├─> 4: elvish: "[mosh] embee@fedora:/etc" (6) └─> 5: elvish (7) - local: 6 windows (attached) (8) ├─> 0: elvish (9) ├─> 1: elvish- (M-a) ├─> 2: [tmux]* (M-b) ├─> 3: elvish (M-c) ├─> 4: elvish (M-d) └─> 5: elvish (M-e) - dev: 7 windows (attached) (M-f) ├─> 0: elvish* (M-g) ├─> 1: elvish- (M-h) ├─> 2: elvish (M-i) ├─> 3: elvish (M-j) ├─> 4: elvish
- nolist_policy 1y agoIsn't the screen equivalent literally this? Host tmux HostName 1.2.3.4 IdentityFile ~/.ssh/etc.etc.etc RequestTTY force RemoteCommand screen -dR Edit: I guess it's missing the iTerm integration
- fouc 1y agoI've always found screen's ctrl-a is so much easier to reach for than tmux's ctrl-b. I recommend re-mapping ctrl-b to ctrl-a
- _kst_ 1y agoI use Ctrl-Space. unbind-key C-b set -g prefix C-Space bind-key C-Space send-prefix I find it a lot easier to type than either Ctrl-A or Ctrl-B.
- cyberpunk 1y agoThe real superpower prefix key is ` especially if you have a british mac keyboard.
- __david__ 1y agoBoth C-a and C-b are so commonly used that I don’t like either of them. I ended up going with C-\ since I only rarely use that one.
- anthk 1y agoI just remapped the keys to ctrl-z after I swapped ctrl and caps lock. As you'd never suspend stuff under tmux for obvious reasons, you'll get the whole keyset for any cli/tui software.
- rcakebread 1y agoI'll bite. What's so obvious? I suspend jobs in bash all the time while using tmux.
- anthk 1y agoOften TMUX it's for tasks you woudn't suspend. And, if any, you can just use kill -STOP and kill -CONT among other signals from another tmux pane.
- deleted 1y ago
- mike-cardwell 1y agoI use a combination of mosh and screen for this. I only need to type something to get my session back, after a reboot. Changing networks or putting my laptop to sleep for days doesn't drop my sessions: https://www.grepular.com/Immortal_SSH_Sessions https://www.grepular.com/Immortal_SSH_Sessions
- ghkbrew 1y agoMosh looks very cool, though I've never used it. Does Screen provide some advantage over tmux in this setup?
- jvanderbot 1y agoYes. Mosh is a seamless replacement for ssh, and screen is a mostly seamless replacement for tmux. One more level is Mosh+byobu, which is so useful I don't even bother with plain terminals most the time.
- positr0n 1y agoHaha I think you have the history backwards here. Tmux was created as a replacement for screen when it was 20 years old! Speaking as someone with ‘set -g prefix c-a’ in their .tmux.conf because my muscle memory is so used to the screen hotkeys. GNU screen was released in 1987. tmux was created in 2007.
- jvanderbot 1y agoHey maybe I do! Great to learn the history here. Regardless, my point is that Byobu is very nice compared to either. That may now be lost due to my careless comment.
- saagarjha 1y agoIt's seamless until you want to scroll.
- lostdog 1y ago
- aargh_aargh 1y agoDoes any Linux terminal have a comparable integration? I'm still using GNU Screen but willing to give tmux another shot.
- cpuguy83 1y agoPretty sure iTerm is the only term that implements that tmux protocol.
- kzrdude 1y agoITerm2 seems really cool, it has so many features. The developer(s?) must be really productive, they churn it out. They support a lot of Kitty protocols for example.
- tristan957 1y agoGhostty has infrastructure to support it from my understanding, like Mitchell did the initial plumbing. It just takes a spirited individual to finish it up.
- dizhn 1y agowezterm
- edoceo 1y agoThere was one called Terminator which had some tmux like features, split panes, broadcast, etc. It's not been maintained in a bit. https://gnome-terminator.org/ https://gnome-terminator.org/
- rhesa 1y agoI used to use terminator for a long time, but i've switched to tilix (https://gnunn1.github.io/tilix-web/ https://gnunn1.github.io/tilix-web/) with little pain.
- edoceo 1y agoI'll check it out. Note: that Terminator I linked is a re-boot (I'll be back) so, I might give it another go as well.
- scelerat 1y agoI ran into so many little annoying color and font issues with vim, tmux and iTerm2 that I gave up on tmux (for local work). What small benefit I got from tmux on my local machine (basically surviving updates and a little more session persistence) I rarely miss. I wanted it to be better, and might go back if I could figure out the font issues, but I just don't have the time right now.
- quesera 1y ago> vim, tmux and iTerm2 Interesting, I've been using exactly that combination for ... as long as tmux and iTerm2 have been around? I am not aware of any color or font issues. What am I missing?
- scelerat 1y agoI could never get italics to work correctly when in iTerm2/tmux mode. Pure tmux, yes, iTerm no tmux yes, iTerm+tmux I would get weird background colors instead of italics. It's been a while so I don't remember specifics
- op00to 1y agoWould mosh stop you from having to reconnect to SSH at least after wake? You'd still need to reestablish a mosh connection after rebooting.
- paradox460 1y agoTmux cc mode doesn't work over mosh. Something to do with how it mangles binary going over the wire. Breaks other iTerm2 features like local copy paste from remote paste boards, drag and drop uploaf and download
- op00to 1y agoBummer!
- alexozer 1y agoWow, I was wondering if e.g. Ghostty could implement something like this but that's cool it's already proven out. Does everything still go "through" tmux (so parsing etc. is still done twice), or does iTerm handle most of the rendering and just delegate scrollback storage/session persistence to tmux? The latter seems like the best of both worlds.
- gorjusborg 1y agoComposing simpler tools works better than complicated tools that try to solve everything. I am a former Kitty user and current Ghostty user and hope Ghostty stays basic and good.
- jayknight 1y agoI've just now learned about tmux's control mode. Can you explain what that tmux -CC command does? I use `ssh -t <host> tmux attach -d` from bash history to (re)establish my remote tmux session. `new -A -s 0` would do the about same thing, I just don't see how -CC is supposed to work here. Edit: It appears to be related to iterm2's tmux integration. Neat.
- sigwinch 1y agoYou might not need control mode for that, try `autossh foo ‘tmux new-session -A’`
- saghm 1y agoAs someone who uses Linux on all my personal machines but has usually had to use a MacBook for work, tmux is also pretty useful as a platform- independent tool for me to reuse the same workflow without needing to worry about differences between the two. I use Alacritty on Linux, but when I've tried using it on MacOS, there have things that don't seem to work for me out of the box the same way they do in Linux (which I'm struggling to remember exactly at the moment, but I think one of them might have been the setting to have the window maximized on startup). Rather than spend time trying to tinker around on an operating system that I don't have any particular desire to use outside of just getting my work done, it's pretty nice to be able to use tmux on iTerm to get basically the same experience I do on Linux. From that perspective, having something like an entirely independent way of scrolling back in a session is a feature to me, not an annoyance. A lot of these arguments against tmux seem like they're more relevant to someone developing a terminal rather than using it. It's fine for people working on their own terminals to decide they don't care to support it, but I don't really find the arguments convincing as something I should care about, and I'd personally just switch to another terminal with better support for it rather than stop using it.