At 00:11 +0100 13 Aug 2013, Thomas Adam <tho...@xteddy.org> wrote:
>On Mon, Aug 12, 2013 at 04:01:46PM -0400, Aaron Schrab wrote:
>> Add -s option to the shown-environment command which will alter the
>> output format to Bourne shell commands, allowing import of the
>> environment into current shell with:
>
>What use-case is this for?  Note that "current shell" is really either
>$SHELL or default-shell if in tmux, where escaping beyond POSIX might still
>be necessary.
>
>It's also somewhat confusing though because whatever goes in to tmux with
>update-environment is already in the environment for all tmux windows (with
>exceptions from those environment variables which have been unset; reflected
>in the output from show-environment).

Commands running in tmux windows have the values for the variables that 
were set when the command was started, but those values can change such 
as when a new tmux client attaches.

My main use case for this is that I run mutt inside of tmux to read my 
mail.  I'll often leave a single instance of mutt running for weeks at a 
time, while connecting to that via ssh from different client computers.  
When a new client connects I need to use different values for variables 
like DISPLAY, XAUTHORITY, and various SSH_* variables in order for some 
programs started from mutt to be able to work properly.  To help with 
this I have a `twrap` script which I prefix to all commands run from 
mutt (like setting the $editor option to `twrap vim`).  That script 
checks if it's being run from within tmux and if so sources the output 
from `tmux showenv -s`, after that it runs the command specified by the 
remaining arguments.

If a non-POSIX shell was being used, there may certainly need to be 
additional or different escaping.  But even in that case this could 
help.  The output format currently used can't properly represent 
environment values which contain a newline.  Those aren't common, but I 
prefer to have my scripts be robust in handling of unusual values.

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to