'Run command in tmux and update the status bar
I wrote a simple shell script that will show IP every 15 sec (it checks for VPN basically )...
I wanted to add that in my status bar and I did it with #()
but it just shows the result once!
and I look up the manual for that and under the format section it said:
In addition, the last line of a shell command's output may be inserted using ‘#()’. For example, ‘#(uptime)’ will insert the system's uptime. When constructing formats, tmux does not wait for ‘#()’ commands to finish; instead, the previous result from running the same command is used, or a placeholder if the command has not been run before. If the command hasn't exited, the most recent line of output will be used, but the status line will not be updated more than once a second. Commands are executed with the tmux global environment set (see the GLOBAL AND SESSION ENVIRONMENT section).
i just wanted to know is there any other way to run script and update its result on status bat?
Solution 1:[1]
You can store your script's output in a file (say, add a > ~/.ip
instead of wherever your script currently outputs from) and use #(cat ~/.ip)
in your tmux' status-right, that way instead of running said script once and reading one line from a loop, tmux will read your script's output from a file where it is changing dynamically. I did similar thing with ti
script for myself - except my creation wraps a command i give to it interactively. Still, the "indicator" itself is a file.
Said ti
script:
#!/bin/bash
while true; do
if [[ -f ~/.tistop ]]
then
rm ~/.tistop
rm ~/.ti
exit
else
bash -c "$*" >> ~/.ti; sleep 2
fi
done &
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alex Gravitos |