Skip to content

Commit 351b801

Browse files
author
Sergei Gerasenko
committed
Refactor all_tmux_processes
When counting the number of running tmux processes, count only those that belong to the current user. `tmux a` shows as a separate process (must be the client process) and thus needs to be excluded from the calculation as well. The previous exclusion of `tmux source` was also incorporated.
1 parent 90f4a00 commit 351b801

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

scripts/helpers.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ current_tmux_server_pid() {
2323
}
2424

2525
all_tmux_processes() {
26-
# ignores `tmux source-file .tmux.conf` command used to reload tmux.conf
27-
ps -Ao "command pid" |
28-
\grep "^tmux" |
29-
\grep -v "^tmux source"
26+
# finds all tmux processes for the current user ignoring the following:
27+
# 1) `tmux source-file .tmux.conf` (used to reload tmux.conf)
28+
# 2) `tmux a` (which shows an additional process)
29+
30+
ps -Ao "command pid uid" |\
31+
grep $UID |\
32+
grep -E '^tmux' |\
33+
grep -vE '^tmux\s+(a|source)'
3034
}
3135

3236
number_tmux_processes_except_current_server() {

0 commit comments

Comments
 (0)