Open terminal app

Hi

I’d like KM to open terminal, maximize the window and open the terminal app vi.

Wondering what’s the right way to do that.

Thanks.

Hey @anon65815102,

All of that can be done with Keyboard Maestro actions, but it will be smoother and more bombproof with AppleScript.

-Chris

------------------------------------------------------------

set winBounds to desktopBounds()

tell application "Terminal"
  if not running then
    run
    delay 0.25
  end if
  activate
  set bounds of front window to winBounds
  
  tell application "Terminal"
    activate
    tell front window
      if busy = false then
        set shCMD to "vi"
        do script shCMD in selected tab
      end if
    end tell
  end tell
  
end tell

------------------------------------------------------------
--» HANDLERS
------------------------------------------------------------
on desktopBounds()
  tell application "Finder"
    set _bnds to bounds of window of desktop
    return _bnds
  end tell
end desktopBounds
------------------------------------------------------------
2 Likes

Thanks, @ccstone. Works like a charm.

1 Like