Skip to content

Instantly share code, notes, and snippets.

@andrewpetrochenkov
Last active August 3, 2024 18:53
Show Gist options
  • Select an option

  • Save andrewpetrochenkov/1ab9807998e82dfbb7d774f98cf6df9c to your computer and use it in GitHub Desktop.

Select an option

Save andrewpetrochenkov/1ab9807998e82dfbb7d774f98cf6df9c to your computer and use it in GitHub Desktop.

Revisions

  1. andrewpetrochenkov revised this gist Aug 3, 2024. 2 changed files with 11 additions and 16 deletions.
    19 changes: 11 additions & 8 deletions lsappinfo.sh → mac-frontmost-app.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,11 @@
    #!/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}'

    osascript <<EOF
    tell application "System Events"
    name of (first process whose frontmost is true)
    end tell
    EOF

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

    8 changes: 0 additions & 8 deletions osascript.sh
    Original file line number Diff line number Diff line change
    @@ -1,8 +0,0 @@
    #!/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
  2. andrewpetrochenkov revised this gist Jul 19, 2021. No changes.
  3. andrewpetrochenkov created this gist Jun 7, 2019.
    8 changes: 8 additions & 0 deletions lsappinfo.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    #!/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}'

    8 changes: 8 additions & 0 deletions osascript.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    #!/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