mirror of
https://github.com/jbranchaud/til
synced 2026-03-03 22:48:45 +00:00
Compare commits
3 Commits
6fdadfa1fb
...
bd58be8fda
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd58be8fda | ||
|
|
35f1f0b807 | ||
|
|
81afd44913 |
@@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/).
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
|
||||
|
||||
_1726 TILs and counting..._
|
||||
_1728 TILs and counting..._
|
||||
|
||||
See some of the other learning resources I work on:
|
||||
|
||||
@@ -1566,6 +1566,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Kill Other Connections To A Session](tmux/kill-other-connections-to-a-session.md)
|
||||
- [Kill The Current Session](tmux/kill-the-current-session.md)
|
||||
- [List All Key Bindings](tmux/list-all-key-bindings.md)
|
||||
- [List Processes Running Across All Session](tmux/list-processes-running-across-all-sessions.md)
|
||||
- [List Sessions](tmux/list-sessions.md)
|
||||
- [Open New Splits To The Current Directory](tmux/open-new-splits-to-the-current-directory.md)
|
||||
- [Open New Window With A Specific Directory](tmux/open-new-window-with-a-specific-directory.md)
|
||||
@@ -1756,6 +1757,7 @@ If you've learned something here, support my efforts writing daily TILs by
|
||||
- [Show A File Preview When Searching With FZF](unix/show-a-file-preview-when-searching-with-fzf.md)
|
||||
- [Show Disk Usage For The Current Directory](unix/show-disk-usage-for-the-current-directory.md)
|
||||
- [Show The Size Of Everything In A Directory](unix/show-the-size-of-everything-in-a-directory.md)
|
||||
- [Show Tree View Of Processes And Subprocesses](unix/show-tree-view-of-processes-and-subprocesses.md)
|
||||
- [Skip Paging If Output Fits On Screen With Less](unix/skip-paging-if-output-fits-on-screen-with-less.md)
|
||||
- [SSH Escape Sequences](unix/ssh-escape-sequences.md)
|
||||
- [SSH With Port Forwarding](unix/ssh-with-port-forwarding.md)
|
||||
|
||||
46
tmux/list-processes-running-across-all-sessions.md
Normal file
46
tmux/list-processes-running-across-all-sessions.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# List Processes Running Across All Session
|
||||
|
||||
I wanted an overview of all the processes running across all the tmux sessions
|
||||
that I have running on my machine right now. The `list-panes` command (with the
|
||||
`-a` flag) gives me a listing of all the panes across all session of the current
|
||||
tmux server.
|
||||
|
||||
That output on its own isn't giving me quite the info I'm looking for though.
|
||||
With the `-f` (_format_) flag, I can use variables available in that context
|
||||
like `session_name`, `pane_pid`, and `pane_current_command`.
|
||||
|
||||
I can assemble the details I want into a command like this:
|
||||
|
||||
```bash
|
||||
❯ tmux list-panes -a -F "#{session_name}:#{window_index}.#{pane_index} #{pane_pid} #{pane_current_command}"
|
||||
PLP:1.1 62364 zsh
|
||||
TIL:1.1 62345 nvim
|
||||
TIL:1.2 65838 task
|
||||
TIL:2.1 11428 tmux
|
||||
client-app:1.1 62373 ssh
|
||||
client-app:1.2 10796 zsh
|
||||
client-app:1.3 63081 zsh
|
||||
client-app:2.1 61115 overmind
|
||||
client-app:3.1 82608 zsh
|
||||
visualmode-dev:1.1 52237 zsh
|
||||
```
|
||||
|
||||
This gives me the details I want, but I can take it a step further by piping it
|
||||
to the `column` command to improve the formatting a little:
|
||||
|
||||
```bash
|
||||
❯ tmux list-panes -a -F "#{session_name}:#{window_index}.#{pane_index} #{pane_pid} #{pane_current_command}" \
|
||||
| column -t
|
||||
PLP:1.1 62364 zsh
|
||||
TIL:1.1 62345 nvim
|
||||
TIL:1.2 65838 task
|
||||
TIL:2.1 11428 tmux
|
||||
client-app:1.1 62373 ssh
|
||||
client-app:1.2 10796 zsh
|
||||
client-app:1.3 63081 zsh
|
||||
client-app:2.1 61115 overmind
|
||||
client-app:3.1 82608 zsh
|
||||
visualmode-dev:1.1 52237 zsh
|
||||
```
|
||||
|
||||
See `man tmux` and, in particular, the `FORMATS` section for more details.
|
||||
36
unix/show-tree-view-of-processes-and-subprocesses.md
Normal file
36
unix/show-tree-view-of-processes-and-subprocesses.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Show Tree View Of Processes And Subprocesses
|
||||
|
||||
Though you can cobble together a command on a MacOS Unix system to output a
|
||||
hierarchical tree view of a parent process and its descendent subprocesses, it
|
||||
is easier to [`brew install pstree`](https://github.com/FredHucht/pstree) and
|
||||
use that.
|
||||
|
||||
Here is what I see when I run it for a _pid_ that corresponds to a `tmux`
|
||||
session that I have running locally:
|
||||
|
||||
```bash
|
||||
❯ pstree 61690
|
||||
-+= 61690 lastword tmux new-session -d -s TIL -c /Users/lastword/dev/jbranchaud/til
|
||||
|--= 63081 lastword /bin/zsh
|
||||
|-+= 11428 lastword zsh
|
||||
| \-+= 48511 lastword pstree 61690
|
||||
| \--- 48512 root ps -axwwo user,pid,ppid,pgid,command
|
||||
|-+= 62345 lastword zsh
|
||||
| \--= 06031 lastword claude
|
||||
|--= 62364 lastword /bin/zsh
|
||||
|-+= 62373 lastword zsh
|
||||
| \--= 64407 lastword ssh my-app-staging
|
||||
|-+= 61115 lastword /bin/zsh
|
||||
| \-+= 61579 lastword overmind start -f Procfile.dev
|
||||
| \--- 61586 lastword tmux -C -L overmind-my-app-abc123 new -n web -s my-app -P -F %overmind-process #{pane_id} web #{pane_pid} /var/folders/zc/abc123/T/overmin
|
||||
|--= 52237 lastword /bin/zsh
|
||||
|--= 82608 lastword /bin/zsh
|
||||
\--= 10796 lastword /bin/zsh
|
||||
```
|
||||
|
||||
I was looking for a frozen `claude` process that was part of this session. And I
|
||||
found it about halfway down that list -- `06031`. Now I can run `kill` on that
|
||||
process as needed.
|
||||
|
||||
For some additional context, I initially found the _pid_ for the `tmux` session
|
||||
by running `ps aux | grep tmux` and looking through those results.
|
||||
Reference in New Issue
Block a user