5

I want to see how only the running apps and not a list of all processes. I want to see the same apps I see with the Force Quit Applications(Mac), but I want the list of the apps in the terminal via a command.

Can I use top -o mem or ps aux with some regex, or is there a better way to do it?

enter image description here

1 Answers1

5

In Terminal:

osascript -e 'tell application "System Events" to return name of processes whose background only is false'

Returns the same applications in Force Quit Applications as an unsorted comma separated list.

PS: To get the PIDs replace name with unix id. And to have ps display only applications use

ps ux -p $(osascript -e 'tell application "System Events" to return unix id of processes whose background only is false')
nohillside
  • 100,768
user3439894
  • 58,676
  • Just make sure that Terminal, or whatever app you are using, is authorized to send Apple Events to System Events. – ErniePC12 Dec 11 '21 at 14:23
  • Do you know if there's any documentation that shows the correlation between the states available from ps, and process properties available from System Events? – Seamus Dec 12 '21 at 00:08