Live data from Hacker News

Getting Started with Tmux

ittavern.com

121–130 of 160 posts

Re: Getting Started with Tmux

#121
Tmux is the one tool I use every day at every company I've been with. At my current employer we have a lot of new grads and I strongly encourage them all to use tmux. We have a about a third of our devs on tmux now and they all love it. I have converted many devs, young and old, to use tmux. Once you get the hang of things you are hooked and you can learn 80% of tmux in 10 minutes.

Re: Getting Started with Tmux

#122

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.

I do this all the time to run data acquisition systems for accelerator experiments. It also allows multiple users to connect at once. We have our whole analysis pipeline hosted in tmux sessions too.

Re: Getting Started with Tmux

#123

I've used Tmux/Screen the few times I've had to be in an actual terminal, but don't really see the use for them when using a GUI terminal emulator. I just open new tabs or (rarely) windows as needed. Could anyone using these explain what it provides that you find useful in practice? I rarely ever need persistence of shell when I close the console, is that a common need? Familiarity/muscle memory of shortcuts is a val…

Doesn't it drive you crazy to lose your work whenever X11/Wayland crashes, or you have to kill your display server to diagnose a problem, or you accidentally close a terminal window?

tmux preserves everything for you unless you explicitly kill it, or you have to reboot.

I started using Screen like 20 years ago (and later moved to tmux) and I can't go back to doing real work in a "bare" terminal window. It would feel like walking on a thin layer of ice on a lake; as soon as something goes wrong, it's a minor disaster.

Re: Getting Started with Tmux

#124

I've used Tmux/Screen the few times I've had to be in an actual terminal, but don't really see the use for them when using a GUI terminal emulator. I just open new tabs or (rarely) windows as needed. Could anyone using these explain what it provides that you find useful in practice? I rarely ever need persistence of shell when I close the console, is that a common need? Familiarity/muscle memory of shortcuts is a val…

Say you have a document you are working on in LaTeX over a few weeks. You might have the command line for compiling, bibtex, and git in one pane, then vim or equivalent in another.

Now say you will be moving between home, office, and traveling. If the tmux session is hosted at work you can connect from anywhere and be in the same workspace with the same command history. If you have a dozen other projects happening at once this system can also be a big help as far as organization.

Re: Getting Started with Tmux

#125
post #22
post #5

I've only used tmux for about One of my favorite scripts to run is a tmux script that creates a new session with about 7 windows of running my company's project (one window for notes, 3 windows for the backend (runner, code, tests), and 3 windows for the client (runner, code, tests). It's even tweaked further to open up the code in vim, and when used in conjunction with something like harpoon.nvim I have access to my…

Also check out tmux-resurrect to save and restore tmux window/pane config including working directories and scrollback. It can also restore running programs, which is sometimes a reasonable thing to do. https://github.com/tmux-plugins/tmux-resurrect

I have been wanting this for years! Thanks for sharing

Re: Getting Started with Tmux

#126
post #15

My favorite mod is something simple as renumbering the windows/tabs to range starting at 1, rather than being zero indexed, this way they align with the digits on my keyboard.

Yup! That is such a major improvement. I just wish there was a way to start sessions with 1 index. The inconsistency drives me nuts!

Re: Getting Started with Tmux

#127

Earlier quoted context omitted.

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.

Reading more about Kitty now is peaking my interest. I feel like there is a reason I ignored Kitty in the past but I can't remember.

The author has a hatred of bitmap fonts for some reason.

Re: Getting Started with Tmux

#128
post #44

Among many tricks and tips, I recommend mapping `|` and `-` to split panes: bind-key | split-window -h bind-key - split-window -v More on my wiki: https://wiki.rsapkf.org/notes/unix/tmux/

I've bound the keys 'v' and 's' for vertical and horizontal splitting to match Vim's default bindings. What tmux calls horizontal and vertical splits is inverse of those in Vim - hence -h flag for what most would call as vertical split. I suspect one of the authors was Australian!

There is ambiguity in vertical / horizontal split. Does it refer to the "cut" or the result?

In Sway and i3 if I make a vertical split and open a new window, it appears below (thus vertical), but the split was like a cut horizontally across. I've seen some people use the - and | keys for tmux splits which kind of avoids the language issues and turns it into which way the new line is drawn.

Re: Getting Started with Tmux

#129

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.

Add it within a infinitive loop + `sleep 10` and now it automatically restarts if it crashes too! :)

I've started doing this with a few programs using sleep 1 and a while loop. First was ncmpcpp as it would declare itself too small and quit sometimes when my terminal with tmux resized, this way it'd either reopen when I adjusted pane sizes to fix it or when I restored the whole window to the other size. Next I did it for stig because I'd often press q to quit by accident or because it occasionally hits an issue where you can't view a torrent's detailed info anymore, fixed by a restart. Lastly for the aerc mail client which will frequently stop being able to reach mail servers and tell me I can't archive mail or something, so I just quit it and now it restarts (not sure if there's another way to make it reconnect).

Re: Getting Started with Tmux

#130
post #31

Hint for more advanced users: Tmux inside tmux works not that bad. (Ctrl-B Ctrl-B becoming the prefix for the inner Tmux-es)

Even better IMO is to use different prefixes for outer vs inner tmux sessions. These are the first lines of my .tmux.conf:

    # Use C-a for outer sessions, and C-x for nested sessions.
    unbind-key C-b
    set-option -g prefix C-a
    bind-key -n C-x send-prefix
Post reply on HN