4 ms·
The problem here is the reliance upon environment variables being set by parent processes. That's always felt weird to me. I think tmux's choice is actually th
by echelon 4y ago
The problem here is the reliance upon environment variables being set by parent processes. That's always felt weird to me.
I think tmux's choice is actually the sane one. You create the server once, then there's no more question about what environment variables are going to be established in the future.
When you create a new tmux window, you should know if there's already a server spawned.
- Beldin 4y agoIt would make sense if there were 2 commands, tmux-server for starting the server and tmux-client for starting the client. The client would then support options to connect to an existing server or spawn a new one. I'm a big fan of abstracting away details of little importance. But if I risk using an old server with stale values in its environment, I prefer that to be made explicit and not abstracted away.
- deleted 4y ago[deleted]
- kelnos 4y ago> ...the reliance upon environment variables being set by parent processes. That's always felt weird to me. I don't really agree. When I start a program in a shell, I expect it to inherit the environment of that shell. That's just how things have always worked, modulo some special cases (sudo, running a new instance of the shell in login mode, whatever). I personally don't think that's weird, but even if I did, what I care most about software behavior is predictability. Software should do what is expected and common, and if it does not, it should have a very good reason, and should find a way to make that obvious to the user every time it does it. This is just bad UX on tmux's part. > When you create a new tmux window, you should know if there's already a server spawned. What? Why? I use screen on and off, not super often. When I start a screen instance, I don't always know or care if I have another instance running somewhere. And yes, because screen follows what I'd consider a more predictable model here, I end up with the environment variables I expect. I think whenever we attack a UX problem by saying "the user should know X", we've already lost. You can't assume that you know how the user is going to use your software, or what their state of mind will be when starting it. That's just silly.
- cauthon 4y ago> When I start a program in a shell, I expect it to inherit the environment of that shell. That's exactly how tmux works. You start a server, it inherits the environment of the current shell. You create a new session in that server, it inherits the environment of the server. I don't understand how forcing tmux to re-load the current local environment for each new shell is saner behavior. One natural consequence would be that new panes in existing sessions are also created with the new env vars, which is obviously undesirable.
- mananaysiempre 4y ago>> When I start a program in a shell, I expect it to inherit the environment of that shell. > That's exactly how tmux works. You start a server, it inherits the environment of the current shell. You create a new session in that server, it inherits the environment of the server. Whether that makes sense depends on if your mental model has starting a server and connecting to a server to create a new shell as distinct actions, as opposed to a singular action of connecting to a conceptually always-present persistent environment and starting a shell there. Admittedly tmux’s interface is mostly organized along the former lines, but given I prefer `tmux new -A`, my own model seems to follow the latter.
- ghshephard 4y agoI don't know about other people - but I spend greater than 99.9% of my time inside a tmux session. It is my windowing environment. I was reading the original post and just kept furrowing my brows wondering "Under what possible scenario could any of this possibly be a problem?" It's kind of interesting reading through the threads here and seeing how people don't spend their time inside tmux all the time but instead "start an instance on demand" - which I've never done but I guess works for some people's workflow? I'm genuinely crippled trying to use a terminal without tmux after having used it for so long - don't have the faintest clue how to copy/paste/search/organize windows without it.
- echelon 4y agoI want to echo this sentiment as well. I never use bare terminal sessions. Not locally, and especially not remotely. I think the tmux sentiment in question is held by people new to the tool or that don't use it as a normal part of their workflow or day-to-day.
- isaacremuant 4y agoI agree that it is more sane and predictable. I'm pretty happy with this behaviour and being able to tweak it if I need more.
- kelnos 4y agoHow is that "predictable"? The standard behavior for more or less everything is that, by default, when you run a process, it will get its environment from the parent process. Getting its environment from a magical hidden server process that a casual user may not even know about is the opposite of "predictable".
- em-bee 4y agoit's not magical or hidden. every invocation of tmux is a call to a running tmux server. the only exception is when no server is running, in which case a new one is started. i have tmux running all the time. started once when i connect to a server for the first time, it keeps running until the server is rebooted. i have tmux sessions that go back years. the only time the environment is causing me trouble is when a new ssh connection is forwarding an ssh agent, which doesn't get transferred into the tmux session when i attach. but screen would not help here either. if you connect to an existing screen session it has the same problem. we really want a way to adjust the environment for specific variables on attach.
- joshuaissac 4y agoIf you run an SSH client process to connect to an SSH server, the resulting SSH session will not inherit the environment from the parent process of the client by default. Although not the same, connecting to a tmux server is more similar to that than starting a regular child shell.
- deleted 4y ago[deleted]