Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. -- TerminalVim.app
  2. -- This creates a shim Application that will enable you to open files from the Finder in vim using iTerm
  3.  
  4. -- To use this script:
  5. -- 1. Open Automator and create a new Application
  6. -- 2. Add the "Run Applescript" action
  7. -- 3. Paste this script into the Run Applescript section
  8. -- 4. Save the application as TerminalVim.app in your Applications folder
  9. -- 5. In the Finder, right click on a file and select "Open With". In that window you can set TerminalVim as a default
  10. on run {input, parameters}
  11. if input is not in {} then
  12. set myPath to POSIX path of input
  13. set cmd to "vim " & quote & myPath & quote
  14. end if
  15.  
  16.  
  17. tell application "iTerm"
  18. if it is running then
  19. -- This is in the case where Iterm is open and no window is open.
  20. if (count windows) is 0 then
  21. create window with profile "Default"
  22. tell current window
  23. tell current session
  24. write text (cmd)
  25. end tell
  26. end tell
  27. activate
  28. else
  29. tell current window
  30. -- We create a separate tab to the current window
  31. create tab with profile "Default"
  32. tell current session
  33. write text (cmd)
  34. end tell
  35. end tell
  36. activate
  37. end if
  38.  
  39. else
  40. -- At startup of iTerm...
  41. tell application "iTerm"
  42. -- We do not create a tab since we know it's at startup
  43. tell current window
  44. tell current session
  45. write text (cmd)
  46. end tell
  47. end tell
  48. activate
  49.  
  50. end tell
  51.  
  52. end if
  53.  
  54. end tell
  55. end run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement