Live data from Hacker News

Getting Started with Tmux

ittavern.com

111–120 of 160 posts

Re: Getting Started with Tmux

#111
post #74

Earlier quoted context omitted.

I've only recently started running my servers this way, and I've taken this to the next level with bubblewrap: https://tobykurien.com/simpler-linux-selfhosting/

Nice! From my experience, really what you want next is a working tmux-resurrect. Or, at least, all your services runners to be in .sh scripts (and not just in your so evanescant bash history)

Hmm, "evanescant" seems wrong... sure enough, that's an obscure Latin word, vs intended "evanescent" (~synonymous w/ "ephemeral", ie soon-disappearing).

PS comment is in spirit of knowlege-sharing not pedantry. :)

Re: Getting Started with Tmux

#112

The best way to use tmux is with -CC, which iTerm maps to native UI. tmux tabs and panes become native tabs and panes and your session is immortal, and it’s a far better experience than mosh or whatever the latest thing in this area is. I have never bothered to figure out how the keybindings actually work and I probably never will, but I enjoy using it all the time because of this.

I had trouble getting the tmux setup working in iterm.

The main page suggests -CC, but the best practices wiki[0] says to use `-CC new -A -s main`, but this causes iterm to warn that a session is already started and doesn't actually create or reattach like I expected. I also had trouble getting the tmux select-layout to work: when I tried it all my panes just exited with an error. I would like to have iterm behave similarly to Kitty's tall layout[1] which I think is the same thing as tmux's main layout, but haven't figured out how to make it work. Anybody have tips on making these wek?

[0]: https://gitlab.com/gnachman/iterm2/-/wikis/tmux-Integration-... [1]: https://sw.kovidgoyal.net/kitty/layouts/#the-tall-layout

Re: Getting Started with Tmux

#113
I’ve had to stop using tmux on macOS (MacBook Pro 2018).

For some reason I kept getting extreme slowdowns/laggy behaviour when using neovim.

I’ve seen this thread: https://github.com/tmux/tmux/issues/353

I tried everything in the thread and still end up with a laggy terminal. For now I just use iterm2 with tabs but I miss my tmux.

On my personal Linux laptop, I never encounter the same lag with the same setup.

Re: Getting Started with Tmux

#114

Tmux becomes more awesome when you use something like Alacritty or Kitty [EDIT: scratch Kitty, this mainly applies to Alacritty] and map your system's key (Apple's command key or... whatever it would be on Linux or Windows) and use that as your "tmux key". That way you can make single-chord bindings for all things tmux and life becomes better. If you use Vim, adding VimTmuxNavigator[0] improves things so much. For ex…

Interestingly enough, one of the stated goals of kitty is to make the usage of tmux unnecessary. Considering your comment (and many others like it), I don't think that has quite worked out. Still, kitty is one of my favorite terminal emulators and I'd urge anyone who hasn't tried it to give it a shot.

I use kitty locally and only usr tmux on remote servers where I would not like to lose my session.

Running remote tmux inside a local tmux is just to error prone and forces you to remember different bindings.

Re: Getting Started with Tmux

#115

I’ve had to stop using tmux on macOS (MacBook Pro 2018). For some reason I kept getting extreme slowdowns/laggy behaviour when using neovim. I’ve seen this thread: https://github.com/tmux/tmux/issues/353 I tried everything in the thread and still end up with a laggy terminal. For now I just use iterm2 with tabs but I miss my tmux. On my personal Linux laptop, I never encounter the same lag with the same setup.

iTerm2 actually offers nice interfacing with tmux. If you run `tmux -CC` it will start a tmux session that iTerm abstracts away letting you split and switch panes as you normally would in iTerm, but still allowing you to join the tmux session on another terminal.

https://iterm2.com/documentation-tmux-integration.html

Re: Getting Started with Tmux

#116

My favorite antipattern is, you can just leave a script that does an event loop running in the foreground, detatch tmux, and voila, you have a 'server'. Works great in a pinch or when you just don't need to finish it.

lol a startup I worked at literally have a prod web server deployed through tmux like this.

why? (actually curious)

Re: Getting Started with Tmux

#117
post #74

Earlier quoted context omitted.

Nice! From my experience, really what you want next is a working tmux-resurrect. Or, at least, all your services runners to be in .sh scripts (and not just in your so evanescant bash history)

Hmm, "evanescant" seems wrong... sure enough, that's an obscure Latin word, vs intended "evanescent" (~synonymous w/ "ephemeral", ie soon-disappearing). PS comment is in spirit of knowlege-sharing not pedantry. :)

True.

[to be limpid, I just meant that a reboot could kill that server-in-tmux strategy ;P ]

Re: Getting Started with Tmux

#118
post #115

I’ve had to stop using tmux on macOS (MacBook Pro 2018). For some reason I kept getting extreme slowdowns/laggy behaviour when using neovim. I’ve seen this thread: https://github.com/tmux/tmux/issues/353 I tried everything in the thread and still end up with a laggy terminal. For now I just use iterm2 with tabs but I miss my tmux. On my personal Linux laptop, I never encounter the same lag with the same setup.

iTerm2 actually offers nice interfacing with tmux. If you run `tmux -CC` it will start a tmux session that iTerm abstracts away letting you split and switch panes as you normally would in iTerm, but still allowing you to join the tmux session on another terminal. https://iterm2.com/documentation-tmux-integration.html

That looks interesting, I’ll have to give that a try thanks!

Re: Getting Started with Tmux

#119
post #117

Earlier quoted context omitted.

Hmm, "evanescant" seems wrong... sure enough, that's an obscure Latin word, vs intended "evanescent" (~synonymous w/ "ephemeral", ie soon-disappearing). PS comment is in spirit of knowlege-sharing not pedantry. :)

True. [to be limpid, I just meant that a reboot could kill that server-in-tmux strategy ;P ]

Not sure if you read the linked article, but there is a strategy to restart services on boot, using crontab's @reboot feature

Re: Getting Started with Tmux

#120
post #81

Tmux becomes more awesome when you use something like Alacritty or Kitty [EDIT: scratch Kitty, this mainly applies to Alacritty] and map your system's key (Apple's command key or... whatever it would be on Linux or Windows) and use that as your "tmux key". That way you can make single-chord bindings for all things tmux and life becomes better. If you use Vim, adding VimTmuxNavigator[0] improves things so much. For ex…

For what it's worth, you can just do this using Alt (i.e. 'meta'). No special terminal required. Just use `bind -n M- ` to say 'no prefix' and use meta- . For example, `bind -n M-1 select-window -t 1` means Alt-1 goes to Window 1 for me. I use Alt-h, Alt-j, Alt-k, Alt-l for vim-aware pane switching (with some vim config too), e.g. via `bind -n 'M-h' if-shell "$is_vim" 'send-keys M-h' 'select-pane -L'`. I have a load…

Meta interferes with some of my vim bindings, though, as well as some readline bindings (`alt-f`, `alt-b`). I like using the system key because it's essentially unused in Alacritty and it provides a clean separation between tools.

And actually, I didn't mention that my VinTmuxNav commands are bound to `alt-j` and the like so that I can still use `ctrl-h` and `ctrl-l` on the command line. [EDIT: ...and then alacritty binds `cmd-j` and friends to the meta version when inside vim]

And yes, can confirm you do need to make Alt be Esc+ in iTerm!

Post reply on HN