How to see only running apps in terminal and not all processes?

Solution 1:

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')