Skip to content

Instantly share code, notes, and snippets.

@Fechin
Last active April 8, 2018 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fechin/d72b3f0f5247d14cc2174c117d96bf15 to your computer and use it in GitHub Desktop.
Save Fechin/d72b3f0f5247d14cc2174c117d96bf15 to your computer and use it in GitHub Desktop.
Open file in iTerm vim for MacOS Sierra
-- 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}
if input is equal to {} then
set cmd to "vim"
else
set filename to POSIX path of input
set cmd to "cd `dirname " & filename & "`;vim " & filename
end if
tell application "iTerm"
activate
tell the current window
create tab with default profile
tell the current session
write text cmd
end tell
end tell
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment