Skip to content

Instantly share code, notes, and snippets.

@gim-
Created November 24, 2024 14:41
Show Gist options
  • Save gim-/19a94b248d1f3b9a970b5658f92142ab to your computer and use it in GitHub Desktop.
Save gim-/19a94b248d1f3b9a970b5658f92142ab to your computer and use it in GitHub Desktop.
AppleScript to open files using Nvim in kitty via Automator
on run {input, parameters}
set cmd to "nvim; exit"
if input is not {} then
set filePath to POSIX path of input
set cmd to "nvim \"" & filePath & "\"; exit"
end if
tell application "System Events"
set isRunning to (exists (processes where name is "kitty"))
end tell
tell application "kitty" to activate
set activeApp to ""
repeat while activeApp is not "kitty"
tell application "System Events"
set activeApp to name of first application process whose frontmost is true
end tell
end repeat
if isRunning then
tell application "System Events"
keystroke "n" using {command down}
end tell
end if
tell application "System Events"
keystroke cmd
keystroke return
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment