I'm trying to use top in conjunction with pgrep to filter the processes that are being shown. What I have working so far is:
top -pid (pgrep dart)
Which works great for getting a single process to show in top's interactive view.
However, the macos version of top only has one way of listing multiple processes, you have to just repeat -pid [process id] again and again eg:
top -pid 354 -pid 236 -pid 287
My first thought was that I could use brace expansion and command substitution to achieve this, and I tried:
top "-pid "{(pgrep dart)}
But I get invalid option or syntax: -pid {33978}. Even when I manually add in pids it doesn't work:
top "-pid "{45, 23}
invalid option or syntax: -pid 45
Is it possible to achieve what I'm trying to do with fish? i.e insert flags into a command via a combination of command substitution and brace expansion?