Enu*_*nuy 15 linux shell process tmux
有没有办法检测活动窗格中运行的进程?
tmux:找到“我的”窗口,检查它的活动是否相关,但是,它处理窗格内的检测。
我需要从外部命令(而不是从 tmux 会话中)检测到这一点。
问题很可能归结为两个步骤:
Enu*_*nuy 15
结果证明 tmux 对 list-panes 命令具有强大的格式化功能:
$ tmux list-panes -F '#{pane_active} #{pane_pid}'
0 4993
0 5382
1 6189
Run Code Online (Sandbox Code Playgroud)
上面的命令将打印
1 <process_pid>
Run Code Online (Sandbox Code Playgroud)
对于活动窗格。
Fromatting 选项描述于man tmux
:
pane_active 1 if active pane
pane_pid PID of first process in pane
Run Code Online (Sandbox Code Playgroud)
有关术语“窗格中的第一个进程”的讨论,请参阅tmux 中的“窗格的第一个 pid”是什么意思?