mirror of
https://github.com/tmux-plugins/tmux-continuum.git
synced 2024-12-22 23:58:48 +00:00
ec92b3c6b1
1) There can be other scripts whose name starts with tmux for eg tmux-mem-cpu-load, because of this the number_tmux_processes_except_current_server returned 2 even though there was only 1 server(which it excludes) and 1 client. 2) By default continuum_status returned off even though the default interval was 15 min.
51 lines
1.1 KiB
Bash
51 lines
1.1 KiB
Bash
get_tmux_option() {
|
|
local option="$1"
|
|
local default_value="$2"
|
|
local option_value=$(tmux show-option -gqv "$option")
|
|
if [ -z "$option_value" ]; then
|
|
echo "$default_value"
|
|
else
|
|
echo "$option_value"
|
|
fi
|
|
}
|
|
|
|
set_tmux_option() {
|
|
local option="$1"
|
|
local value="$2"
|
|
tmux set-option -gq "$option" "$value"
|
|
}
|
|
|
|
# multiple tmux server detection helpers
|
|
|
|
current_tmux_server_pid() {
|
|
echo "$TMUX" |
|
|
cut -f2 -d","
|
|
}
|
|
|
|
all_tmux_processes() {
|
|
# search for "^tmux " cause there can be some other running scripts,
|
|
# whose name starts with "tmux" for eg "tmux-mem-cpu-load"
|
|
# ignores `tmux source-file .tmux.conf` command used to reload tmux.conf
|
|
ps -Ao "command pid" |
|
|
\grep "^tmux " |
|
|
\grep -v "^tmux source"
|
|
}
|
|
|
|
number_tmux_processes_except_current_server() {
|
|
all_tmux_processes |
|
|
\grep -v " $(current_tmux_server_pid)$" |
|
|
wc -l |
|
|
sed "s/ //g"
|
|
}
|
|
|
|
number_current_server_client_processes() {
|
|
tmux list-clients |
|
|
wc -l |
|
|
sed "s/ //g"
|
|
}
|
|
|
|
another_tmux_server_running_on_startup() {
|
|
# there are 2 tmux processes (current tmux server + 1) on tmux startup
|
|
[ "$(number_tmux_processes_except_current_server)" -gt 1 ]
|
|
}
|