Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Setting an TMUX environment variable from the output of a shell command

26 views
Skip to first unread message

Scott Aitken

unread,
Nov 1, 2024, 10:57:33 AM11/1/24
to tmux-users
HI,
I want to set a variable (preferably hidden) from a pane with setenv and and read it with showenv but I'm struggling:

$ tmux setenv -ghF _tmux_test '#(uptime)x'
$ tmux showenv -gh _tmux_test
_tmux_test=x


Does the setenv command not support the FORMATS #() syntax?

My ultimate aim is to set a variable each time a pane takes focus (with a hook) then read that variable in the status line.

Thanks

Nicholas Marriott

unread,
Nov 1, 2024, 11:00:54 AM11/1/24
to Scott Aitken, tmux-users
Yes, #() can only be used in the status line.

You'll probably need to run a script with "run-shell" that does it.


--
You received this message because you are subscribed to the Google Groups "tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tmux-users+...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/tmux-users/3428caa6-1d5e-4b6c-b4aa-524a06c56faen%40googlegroups.com.

Scott Aitken

unread,
Nov 5, 2024, 2:29:36 AM11/5/24
to tmux-users
Thanks Nicholas,

#{} (curly braces) is parsed by the setenv command, though:

$ tmux setenv -ghF _tmux_test '#{version}x'

$ tmux showenv -gh _tmux_test
_tmux_test=3.4x

Any chance #() could be added to setenv in the future?

In the mean time I'll get my hook to run a shell script that calls tmux setenv.

Scott

Nicholas Marriott

unread,
Nov 5, 2024, 2:30:47 AM11/5/24
to Scott Aitken, tmux-users
#() needs tmux to wait for the process to finish and that is too complicated.


Reply all
Reply to author
Forward
0 new messages