%20%E3%82%92%E8%A6%8B%E3%81%A4%E3%81%91%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%97%E3%82%87%E3%81%86%E3%81%8B%3F.png)
gnome-terminal は多数のウィンドウを開くことができ、1 つのウィンドウに複数のタブが存在する場合があります。
bash の CWD がポータブル ディスクの正常な取り出しを妨げているため、タブの 1 つで bash が実行されている gnome-terminal ウィンドウを 1 つアクティブにしたいと考えています。
lsof によって、bash pid が 25938 であることがわかりました。
私の例では、ウィンドウが 5 つ、タブが 8 つあることがわかりました。問題は、もちろん cmd を使用して、どのウィンドウに 25938 があるかをどのように判断するかです。
$ echo $$
24674
$ ps --ppid $(pgrep gnome-terminal)
PID TTY TIME CMD
6080 pts/0 00:00:00 bash
6742 pts/1 00:00:00 bash
20340 pts/5 00:00:00 bash
23354 pts/7 00:00:00 bash
24674 pts/8 00:00:00 bash
25938 pts/9 00:00:00 bash
30028 pts/12 00:00:00 bash
30492 pts/13 00:00:00 bash
$ wmctrl -lp | grep "$(pidof gnome-terminal-server)"
0x02800006 0 6070 bill me@bill: ~/m
0x0281016b 0 6070 bill me@bill: ~/c
0x02824e87 0 6070 bill me@bill: /c
0x02827a5d 0 6070 bill me@bill: ~/b
0x0282bc75 0 6070 bill me@bill: ~/a