# terminal 1, start a fresh first tmux session, which magically spawns a daemon with the same env
$ env FOO=bar tmux
# terminal 2, start another tmux session, which reuses the daemon's env
$ tmux
$ echo $FOO
bar
Try the same with `screen` and you're safe.This is especially annoying when you're using, say, direnv, and project-specific env vars appear magically on an unrelated subsequent session because your first `tmux` turned out to be from a direnv-enabled directory, which polluted the global environment, which in turn pollutes every subsequent session environment as long as a session (not necessarily the original one) is alive.
Replace FOO with SOME_SECRET/ACCESS_KEY/TOKEN and you can actually accidentally expose/leak stuff or point to the wrong thing.
The unattended workaround is to have the tmux daemon spawn at login via `start-server` + enable some tmux settings like `exit-empty` plus some I can't recall regarding environment handling, but nobody does that.
I just have my terminal emulator spin up tmux when it starts, and I start my terminal emulator from my desktop, so it always runs in a clean environment.
I wish they didn't support that. There's not actually a security boundary there since you can't just reattach to another user's session anyway, and a lot of security people make stupid rules like "if something supports a password, you always have to use one".
screen has improved a lot since then, but it lagged behind substantially for years.
Also a benefit was actually being able to understand and edit my conf file without having to RTFM everything. Certainly not a reason to switch by itself, but a nice plus.
One of the things I like most about it is how easy it is to extend. In the role I was in last year, I'd have several long-lasting SSH sessions to various hosts. With a very simple bash script I was able to create a prompt in tmux that I could trigger to ask me where I wanted to ssh to. If I already had a connection to that host, it would switch me to that window, if not, it would create a new one and ssh to the host.
I wanted to do that in screen for years, but it just didn't have the features to facilitate it. On top of that I was able to easily re-map all of the keybindings to be just like screen for my muscle memory.
Screen seems to cover all my needs and it learning it is easy. I came for the tabs (windows), sessions, copy and paste - but the must have for everyone is the scrollback buffer. You need it! Especially since we can scroll one the plain terminal.
I very rarely use screen/tmux nowadays, but as I recall tmux is a better fit for someone who wants to script their interaction. It makes it easy to send keys to other panes/windows in the session, and also to capture the content from other existing panes/windows.
in what way?
As someone who uses `set -o emacs` I cannot possibly imagine pressing C-a C-a to go to the beginning of the line
Also, as an iTerm2 user: the integration with tmux control mode (tmux -CC) is just amazing for the way I use tmux
escape ^Ff
So we had to find another prefix for those machines; fortunately, tmux can have two.
This (space->@->NUL) is mentioned in the tmux docs, tbh.
escape ^^^I'm wondering if the use of wcwdith() will improve my luck with using UTF-8 characters in my caption and hardstatus lines. I'd like to be using nerdfonts in there but it just makes a mess.
Any program has to expect wide, narrow, or an inconsistent mixture of both if font substitutions are invoked. With no actual API to reliably discover a codepoint display width, your best option is to print some candidates and check the cursor position as a heuristic.
https://mitchellh.com/writing/grapheme-clusters-in-terminals
I use p in screen and tmux as prefix key. I usually prefer tmux.
I usually never do heavy editing in a tmux window. Rarely I use emacs in a terminal window these days. I use tramp to remote connect and edit comfortably in my X session.
Even without tmux, this can be an issue - a long time ago I was using the X windows "drag the selection" middle mouse button action and accidentally let go of the button while the cursor was over an emacs text window - I sent my first email to some big listserv I subscribed to consisting of weird fragments from the log file I was trying to paste.a
I do not use C-b as the tmux prefix key because it interferes with my muscle memory for Emacs where C-b invokes backward-char (i.e., move the cursor back by character(s)).
So I use C-j instead as the prefix key. While C-j also happens to be a useful Emacs key-binding, I use it quite rarely in Emacs. As a result, I do not have strong muscle memory for C-j and I can use it as the prefix key in tmux quite comfortably.
Here is my tiny .tmux.conf: https://github.com/susam/dotfiles/blob/main/.tmux.conf
I sometimes like to program using Unicode variable names when doing physics/math, and this is an easy way to do so built into Emacs.
That conflicts with the standard Emacs binding to move to the beginning of the current line. Many years ago, I switched to C-z instead, on the theory that it is really easy to type C-z C-z when I really want to suspend whatever is currently running.
Pity that (AFAICT) terminals have no concept of Super and Hyper (USB doesn’t know about Hyper, either, but at least X11 does).
Also in Bash.
Looks like you can set a password on it now, which is cool (though I personally like having linux perms govern access to my screen/tmux). Multiinput sounds interesting as well, though in the past that was a feature I thought I'd love to have, but once I had I never use.
I'm glad to see Screen is still getting some love :-)
I ran screen for years before finally switching to tmux around 2011, and it's impact is still heavy as my tmux config is still rocking my "make tmux controls like screen while transitioning" setup which I intended to be temporary. Ctrl+a from my cold dead fingers