Get The Name Of The Current Mac App In OSA/JXA JavaScript
TL;DR
Run this to get the name of the currnet app
#!/usr/bin/env osascript -l JavaScript
const appName = Application("System Events").processes.whose(
{frontmost: {'=': true }}
)[0].name()
console.log(appName)
Output:
iTerm2
Notes
- When run in Emacs Org Mode the return value is blank. I'm guessing that has to do with the way it does the execution process
- I spent an hour figuring out that the reason I couldn't get the name to was due to running it in Emacs. I love having executable source code blocks in my grimoire, but sometimes you run into things like that
-- end of line --