Skip to content

Instantly share code, notes, and snippets.

@andrewp-as-is
Last active April 22, 2024 12:33
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save andrewp-as-is/1ab9807998e82dfbb7d774f98cf6df9c to your computer and use it in GitHub Desktop.
Save andrewp-as-is/1ab9807998e82dfbb7d774f98cf6df9c to your computer and use it in GitHub Desktop.
macOS app frontmost
#!/usr/bin/env bash
{ set +x; } 2>/dev/null
lsappinfo info -only name `lsappinfo front` | awk -F'"' '{print $4}'
lsappinfo info -only pid `lsappinfo front` | awk -F'"=' '{print $2}'
lsappinfo info -only bundlepath `lsappinfo front` | awk -F'"' '{print $4}'
lsappinfo info -only bundleID `lsappinfo front` | awk -F'"' '{print $4}'
#!/usr/bin/env bash
{ set +x; } 2>/dev/null
osascript <<EOF
tell application "System Events"
name of (first process whose frontmost is true)
end tell
EOF
@NightMachinery
Copy link

lsappinfo info `lsappinfo front` has stopped working for me after updating to Sonoma. Does it work for you?

@amake
Copy link

amake commented Apr 22, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment