-
-
Save charlietran/43639b0f4e0a01c7c20df8f1929b76f2 to your computer and use it in GitHub Desktop.
-- TerminalVim.app | |
-- This creates a shim Application that will enable you to open files from the Finder in vim using iTerm | |
-- To use this script: | |
-- 1. Open Automator and create a new Application | |
-- 2. Add the "Run Applescript" action | |
-- 3. Paste this script into the Run Applescript section | |
-- 4. Save the application as TerminalVim.app in your Applications folder | |
-- 5. In the Finder, right click on a file and select "Open With". In that window you can set TerminalVim as a default | |
on run {input, parameters} | |
tell application "iTerm" | |
create window with default profile | |
tell front window | |
tell current session | |
write text ("vim " & quote & POSIX path of input & quote & "; exit") | |
end tell | |
end tell | |
end tell | |
end run |
THANK YOU. Been scavenging the internet for a while for something like this.
Thank you!
Amazing! Thanks!
Thank you. Took some inspiration from this and did one for nvim
https://gist.github.com/sdkks/a017564ea65a781a9ce416d716e08f1e
@sdkks
Nice, you make my day :), I just started Nvim
It works.Thanks!And I think It will be great if can creat new tab when iTerm is running.
Many thanks for this script. It works on High Sierra.
It works.Thanks!And I think It will be great if can creat new tab when iTerm is running.
for opening in a new tab in possible opened iTerm2 (3.2.3 on OS X Mojave)
on run {input, parameters}
set myPath to POSIX path of input
set cmd to "vim " & quote & myPath & quote
tell application "iTerm"
activate
tell current window
create tab with default profile command cmd
end tell
end tell
end run
I made a version of this that handles opening multiple files.
https://gist.github.com/SilverEzhik/cec3f065e7ab7b93d9102df70fa60d9b
https://gist.github.com/cinakyn/a965c695b5d95def68ee84eb3d36befa
Above is cominated version of above. thanks authors.
- multiple file wil be open with multiple vim tabs
- new window will be created if not exist.
- new tab will be created if window is not new one
Heres my two versions
- One edits any selected text in place (e.g. in Mail, Safari etc.) on recent MacOS versions
- The other can open files as an app or a quick action, just like the versions here. It also supports multiple files (tabs) and .vim session files.
Grab here: https://github.com/normen/vim-macos-scripts
So good! Thanks!
can this be a one line command not apple script
can this be a one line command not apple script
You want a one line command to open a file in vim? How about vim myfile.txt
?
can this be a one line command not apple script
You want a one line command to open a file in vim? How about
vim myfile.txt
?
I success done this use
nvim.app
this app made by applescript
so I can open -a nvim.app filename
one line ~
This is brilliant :) Thanks Charlie!