Skip to content

Instantly share code, notes, and snippets.

@DrGo
Forked from chaadow/TerminalVim.scpt
Last active September 9, 2019 23:07
Show Gist options
  • Select an option

  • Save DrGo/4f6a29739a9992ac934aa78f44d3597d to your computer and use it in GitHub Desktop.

Select an option

Save DrGo/4f6a29739a9992ac934aa78f44d3597d to your computer and use it in GitHub Desktop.

Revisions

  1. DrGo revised this gist Sep 9, 2019. 1 changed file with 6 additions and 4 deletions.
    10 changes: 6 additions & 4 deletions TerminalVim.scpt
    Original file line number Diff line number Diff line change
    @@ -18,20 +18,22 @@ on run {input, parameters}
    if it is running then
    -- This is in the case where Iterm is open and no window is open.
    if (count windows) is 0 then
    create window with profile "Base16"
    create window with profile "Default"
    tell current window
    tell current session
    write text (cmd)
    end tell
    end tell
    activate
    else
    tell current window
    -- We create a separate tab to the current window
    create tab with profile "Base16"
    create tab with profile "Default"
    tell current session
    write text (cmd)
    end tell
    end tell
    activate
    end if

    else
    @@ -43,11 +45,11 @@ on run {input, parameters}
    write text (cmd)
    end tell
    end tell
    activate

    end tell

    end if

    end tell

    end run
    end run
  2. Chedli Bourguiba revised this gist Dec 31, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions TerminalVim.scpt
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ on run {input, parameters}
    if it is running then
    -- This is in the case where Iterm is open and no window is open.
    if (count windows) is 0 then
    create window with default profile
    create window with profile "Base16"
    tell current window
    tell current session
    write text (cmd)
    @@ -27,7 +27,7 @@ on run {input, parameters}
    else
    tell current window
    -- We create a separate tab to the current window
    create tab with default profile
    create tab with profile "Base16"
    tell current session
    write text (cmd)
    end tell
  3. Chedli Bourguiba created this gist Dec 24, 2016.
    53 changes: 53 additions & 0 deletions TerminalVim.scpt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    -- 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 not in {} then
    set myPath to POSIX path of input
    set cmd to "vim " & quote & myPath & quote
    end if


    tell application "iTerm"
    if it is running then
    -- This is in the case where Iterm is open and no window is open.
    if (count windows) is 0 then
    create window with default profile
    tell current window
    tell current session
    write text (cmd)
    end tell
    end tell
    else
    tell current window
    -- We create a separate tab to the current window
    create tab with default profile
    tell current session
    write text (cmd)
    end tell
    end tell
    end if

    else
    -- At startup of iTerm...
    tell application "iTerm"
    -- We do not create a tab since we know it's at startup
    tell current window
    tell current session
    write text (cmd)
    end tell
    end tell

    end tell

    end if

    end tell

    end run