Last active
February 21, 2024 12:32
-
-
Save alsolovyev/838c84c0e3efd3e6e55c94e8c7fe7c33 to your computer and use it in GitHub Desktop.
A script to open a file in nvim by right-clicking on it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on run {input} | |
if (count of input) > 0 then | |
set {filePath, fileName} to getPathAndName from input | |
set cmdCd to "cd " & quoted form of filePath | |
set cmdNvim to "nvim " & quoted form of fileName | |
tell application "iTerm" | |
if exists window 1 then | |
tell current window | |
create tab with default profile | |
tell current tab | |
tell current session to write text cmdCd | |
tell current session to write text cmdNvim | |
end tell | |
activate | |
end tell | |
else | |
create window with default profile | |
tell current window | |
tell current session to write text cmdCd | |
tell current session to write text cmdNvim | |
activate | |
end tell | |
end if | |
end tell | |
else | |
display dialog "No items in the input list." | |
end if | |
end run | |
on getPathAndName from someItem | |
tell application "System Events" to tell disk item (someItem as text) | |
set absPath to the POSIX path of container | |
set {fileName} to {name} | |
end tell | |
return {absPath, fileName} | |
end getPathAndName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment