Top
Best
New

Posted by speckx 3 days ago

Make tmux pretty and usable (2024)(hamvocke.com)
269 points | 184 commentspage 3
thcipriani 3 days ago|
Ctrl-a interferes with readline shortcuts. I've been using Ctrl-<Space>: nothing, as far as I know, binds to that.

    unbind C-b
    set-option -g prefix C-Space
    bind-key C-Space send-prefix
data-ottawa 3 days ago||
I very recently learned that with most readline apps and terminal password inputs, ctrl+u clears the input.

Very handy when you make a typo far into a long password and can't keep track of whether you've mashed backspace enough.

mhw 3 days ago|||
I’ve been using Ctrl-s for years. Nothing else uses it because it’s historically been used for terminal flow control, but that doesn’t really have much use in a graphical terminal with history and scrollbars and so I’ve never missed it. Has similar two-finger ergonomics to the Ctrl-a bind as well.

edit: oh, and I think Ctrl-space is the keystroke to get a nul character, and vi uses that character to insert the last entered piece of text in insert mode. It looks like Ctrl-@ does the same things, but tmux might not be able to tell the difference either.

kombine 3 days ago||
Same, I used C-a for a while until I found out its default mapping is jumping to the beginning of the line so I rebound tmux prefix to C-Space. Now my only problem is on a few servers where I haven't copied my dotfiles.
monological 3 days ago||
The only reason I don't use tmux is because of how annoying it is to look at scrollback. Am I using it wrong?
lancebeet 3 days ago||
I would "just" do C-B PgUp and then use vi-like movement keys like hj, gg/G etc., and q to escape the pager, but I realize now that I say it that it doesn't sound very convenient or discoverable.
client4 3 days ago||
C-b [ allows you to scroll up/down
hamasho 3 days ago||
I use c-q for prefix key because it doesn’t conflict with common zsh and vim bindings.

Because the author suggested swapping caps lock and control key, I also recommend mapping escape key at the control key and change the behavior based on whether another key is pressed. For example, if you press control + a, it sends c-a, but if you only press control key and then release, it sends escape. It makes your vim life (and in general) a lot easier. You don’t have to compete the most variable real estate on the keyboard, right next to the A key.

For most bindings like moving, resizing, and splitting,I emulate vim bindings.

Also, -r flag for bind-key command is impotent, because it enables to repeat commands like changing the pane size or move focus. You don’t have to press prefix key each time.

If you want to get fancy look with minimal setting, use plugins like nord tmux theme.

podoman 3 days ago||
Big fan of all of the items mentioned here. I love the "intuitive split commands" -- I'll add that.

For the vim/nvim fans out there, I try my best to add "vim-style" key bindings for navigating between panes, so that e.g. ctrl-h, ctrl-j, ctrl-k, and ctrl-l can be used to move around qukcly. My dotfiles are here:

https://github.com/jay-khatri/dotfiles/blob/main/.tmux.conf

amdivia 3 days ago||
My main gripe with tmux is the nested use case (tmux session on my local machine, in which I ssh to another machine, only to tmux attach within the remote machine too). Is there a terminal multiplexer/session daemon that supports nested sessions out of the box with ease?
she46BiOmUerPVj 3 days ago|
I wrote quite a bit of configuration to support an "outer" tmux process and "inner" tmux processes on all the remote hosts I have various and different tasks to accomplish. I am not sure how some software would manage these, but in the very least configuring my outer session to use Ctrl+a while the inner one uses Ctrl+b is working well. I have aliases that specify a socket so I can refer to the sessions easily and not get them confused.
shye 3 days ago||
What I don't see discussed is why tmux (and screen) are still a thing, when we have windowed desktops for 40+ years now.

Disconnecting a session's lifetime from the connection's lifetime hardly need such lengthy tutorial.

And displaying and arranging multiple virtual terminals was supposed to be the job of the terminal emulator and the windowing system.

em-bee 2 days ago|
windowed terminals and tabs don't keep their state without something like tmux. and they don't let me have multiple terminals on a remote machine.

only now we are seeing gui terminals to integrate such features: wezterm, ghostty, ttypoon, ... so we are discussing tmux because it took more than 40 years for those features to make it to the gui layer.

pavel_lishin 3 days ago||
Hard agree on intuitive splits, I do this as well.

My hotkey is the backtick, `, rather than a chord.

The one thing I still struggle with - because it happens rarely - is easily copying the contents, full or partial, of a particular pane.

kenforthewin 3 days ago||
I'm constantly fighting with tmux copying. I want it to perform like native copying, but in mouse mode it seems to copy more characters than I want, copy newlines when I don't want them, and doesn't copy to clipboard in tmux-in-tmux situations.
maleldil 3 days ago|
You can use vi copy mode. It makes selection a lot easier.
post-it 3 days ago||
I appreciate that tmux has theoretical advantages over screen, but man does the implementation suck. On Mac it still seems like there's no way to copy text if you have mouse mode on (at least in code-server).
adamors 3 days ago||
Select copies, what do you mean?
post-it 3 days ago||
Not for me. Some kind of OSC 52 problem.
szopa 3 days ago|||
Yeah, that really sucks. I couldn’t quite believe what was the case and spent many hours trying to debug it.
ramses0 3 days ago|||
Often, holding down "Shift" while making mouse selections will "break through" and let you get at the O.S. copy/paste/selection mechanism. Highly terminal dependent, though!
post-it 3 days ago||
Not in browsers, unfortunately. Both my work and Home Assistant OS use tmux in a browser tty, and I have to turn off mouse mode to copy.
ihowlatthemoon 3 days ago|||
Maybe you could try this - https://github.com/tmux-plugins/tmux-yank
post-it 3 days ago||
I haven't tried it, but it looks like it just calls pbcopy, which won't work in a browser. There's no programmatic way to do it, because tmux can't access the clipboard.
chasd00 3 days ago||
I was wondering about tmux vs screen (+splitvt) but didn’t want to ask. What are the advantages?
knubie 3 days ago|
I stopped using tmux when I started using kitty terminal with native split windows. I prefer the native window management of kitty, but I do miss the session saving of tmux (e.g. if I accidentally close a tab).
kjs3 3 days ago||
but I do miss the session saving of tmux

Interesting...I kinda thought that was 90% of the use case for using tmux.

qudat 3 days ago|||
Check out: https://github.com/neurosnap/zmx

It uses libghostty to restore scrollback history and terminal state.

leephillips 3 days ago|||
Recent versions of Kitty have sessions. https://sw.kovidgoyal.net/kitty/sessions/
jpeeler 3 days ago||
I was going to say, but zellij doesn't connect the session to the GUI. However, I did not know about kitty's --use-foreground-process, which doesn't solve the problem completely but may be good enough.

https://sw.kovidgoyal.net/kitty/sessions/#more-complex-sessi...

orbital-decay 3 days ago||
There are many separate session persistence daemons: dtach, zmx, hauntty, shpool, diss, abduco - take your pick
0xbadcafebee 3 days ago||
screen's another nice one. been using it for 25 years, so far so good
vessenes 3 days ago||
I used screen until like 2010 or so -- but you triggered me to look back at it again today. One nicety there now is that you can easily get a dump of what's showing in the pty with screen -S <session_name> -X hardcopy. This is actually somewhat hard to do in tmux, but it's a thing you want your AI agents to do all the time. I'm curious if claude / codex are comfortable with screen, I'll check it out.
More comments...