mirror of
https://github.com/kforney/pentest-distro-builder.git
synced 2024-11-01 08:59:11 -06:00
Kaj Forney
a6d12f1ffc
Former-commit-id: 7bddceacd727c25153cd0ec03cf8b0d4011484d5 Former-commit-id: aaf57e63c1976b3960fee717c68c3b09dc1a94ff
48 lines
997 B
Bash
48 lines
997 B
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() {
|
|
# 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 ]
|
|
}
|