Created
September 1, 2017 03:06
-
-
Save grandcolline/b09b95055fb2558a686ef74175d35978 to your computer and use it in GitHub Desktop.
ファイルをiTerm2のviで開くapp
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 argv | |
set the_path to POSIX path of (item 1 of argv) | |
set cmd to "vi " & escapeSpace(the_path) | |
if isAppRunning("iTerm2") then | |
tell application "iTerm" | |
activate | |
select last window | |
tell current window | |
set newtab to (create tab with default profile) | |
tell newtab | |
tell current session | |
write text cmd | |
end tell | |
activate | |
end tell | |
end tell | |
end tell | |
else | |
activate application "iTerm" | |
tell application "iTerm" | |
tell current window | |
tell current session | |
write text cmd | |
end tell | |
activate | |
end tell | |
end tell | |
end if | |
end run | |
on isAppRunning(appName) | |
tell application "System Events" to (name of processes) contains appName | |
end isAppRunning | |
on escapeSpace(myText) | |
set oldDel to AppleScript's text item delimiters | |
set AppleScript's text item delimiters to " " | |
set myText to every text item of myText | |
set AppleScript's text item delimiters to "\\ " | |
set myText to myText as string | |
set AppleScript's text item delimiters to oldDel | |
return myText | |
end escapeSpace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment