Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi-user environments #49

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions scripts/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ current_tmux_server_pid() {
}

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"
# finds all tmux processes for the current user ignoring the following:
# 1) `tmux source-file .tmux.conf` (used to reload tmux.conf)
# 2) `tmux a` (which shows an additional process)

ps -Ao "command pid uid" |\
grep $UID |\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose using ps -u $UID. grep $UID can match tmux process pid.

grep -E '^tmux' |\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add -E flag?

grep -vE '^tmux\s+(a|source)'
}

number_tmux_processes_except_current_server() {
Expand Down