tmux can't read variables inside other running processes. You'll need to store them somewhere from inside the pane, perhaps put in PS1 something like (untested):
[ -n "$TMUX" ] && (mkdir -p ~/.panes; env >~/.panes/$TMUX_PANE) Then you can read them from outside by doing similar to: if -shell "test $(awk -F= '/^HOST/ {print $2}' ~.panes/#{pane_id}) = whatever" If you make sure you are using a version late enough that if-shell uses formats. This'll only work on the local machine of course, to make it work over ssh you'll need to get more complicated. You could also do it for single variables and put them either in the tmux environment (eg "tmux setenv -g HOST_${TMUX_PANE} $HOST") or as user options. On Wed, Apr 23, 2014 at 11:15:05AM +0100, Gil Rutter wrote: > Hi, > It would be useful in multiple cases to access environment variables set > in the shell of the active pane. Here are two such cases. > > 1 - Put the active pane's $PWD on tmux's paste buffer. I currently achieve > this by 'send-keys'ing the pwd command and automatically entering > copy-mode to grab the result. Quite inelegant. > > 2 - When a pane is SSHed to a different machine, I'd like new splits I > make while that pane is in focus to automatically SSH in. This would work: > > bind ! if-shell "test $HOST = 'mySecondPC'" "split-window -v \"ssh > mySecondPC\"" "split-window -v" > > except that $HOST is evaluated in the environment that launched tmux, not > the target pane. (Same for #H and #h format specifiers.) > > So is there a neat way to access the active pane's environmental > variables? > > Thanks, > > Gil Rutter > ------------------------------------------------------------------------------ > Start Your Social Network Today - Download eXo Platform > Build your Enterprise Intranet with eXo Platform Software > Java Based Open Source Intranet - Social, Extensible, Cloud Ready > Get Started Now And Turn Your Intranet Into A Collaboration Platform > http://p.sf.net/sfu/ExoPlatform > _______________________________________________ > tmux-users mailing list > tmux-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/tmux-users ------------------------------------------------------------------------------ Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users