I think, ultimately, my problem comes down to not being able to 
configure tmux session or window options during initialization except 
from a configuration file via -f.

The user can't specify options to a new-session or new-window, within 
the command itself, until after it has been created, which is too late.

set-option can't be used until after the shell-command has been executed.

My best choices at this time seem to be a "env $VARS command" as the 
shell-command, or write a custom tmux config and source it with -f on 
the fly.

It's not as if I can modify the program I am running to not take it's 
configuration from the environment.

Please disagree with me if someone sees a better solution here that I don't.


On 6/1/14, 17:41, Jesse Molina wrote:
> Thanks for the suggestion. This was pretty close to what I was already
> doing as a hack.
>
> I have a lot of variables, and many of them have spaces. printenv/env
> doesn't output quoted values, so I have to alter the output further from
> there and generate a huge command list.
>
> I don't understand why tmux is a brick wall between these processes when
> the need to do this seems really obvious. Environmental variables are
> right up there with stdin. It's like not being able to pass arguments to
> a command.
>
> It's easy to find a large number of user problems with both tmux and
> screen where tmux/screen is being a brick wall between processes. People
> are writing their input to text files and pipes to read them into the
> command pipeline and doing other nonsense to get around this:
>
> https://superuser.com/questions/105954/updating-screen-session-environment-variables-to-reflect-new-graphical-login
>
> Is this an obvious badly-needed feature, or am I not taking something
> into consideration?
>
> I would suggest a command option to new-session/new-window where the
> user can list a series of vars which tmux will pass on to the new
> process.  tmux already does this with certain special variables.
>
> I've been playing around with set-environment and set-option
> update-environment too.  set-envrionment kinda works, but is a huge pain
> since it only accepts a single variable per invocation; I'll have to
> while loop it. It also doesn't solve the problem of the environment
> being in place when the command is executed. I either have to make my
> command wait for the env to be ready, or some other nonsense.
>
> update-environment seems to be pretty worthless. The man page says it
> can be used for "when a new session is created", but I assume that means
> I have to use it against the global settings *before* I create the new
> session, since I can't issue commands against a session that doesn't yet
> exist and I can't issue these options to the new session before the
> command is executed.
>
>
>
> On 6/1/14, 2:43, Balazs Kezes wrote:
>> On 2014-05-31 20:59 -0700, Jesse Molina wrote:
>>> This first bash script has a number of environmental variables which I
>>> need to exist in the new-session env to get passed on to the
>>> application/script in which the new session starts.
>> You can try passing the current environment to the session's first
>> process on its command line. Try this (beware: this is a bit unsafe this
>> way, you'll need to sanitize this command, this is just a
>> demonstration):
>>
>>      tmux new-session "env $(env | tr '\n' ' ') bash"
>>
>> After the new session already exists, you can script around the
>> set-environment command in tmux.
>>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and their
> applications. Written by three acclaimed leaders in the field,
> this first edition is now available. Download your free book today!
> http://p.sf.net/sfu/NeoTech
> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to