From 51e99ef9f495da644c040b083285d19009eeac29 Mon Sep 17 00:00:00 2001 From: Alan MacDougall Date: Fri, 10 Jun 2016 12:31:16 -0400 Subject: [PATCH] Added iTerm2 version 3.0-compatible Applescript block --- On-MacVim-with-iTerm2.md | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/On-MacVim-with-iTerm2.md b/On-MacVim-with-iTerm2.md index fe73e31..cb48853 100644 --- a/On-MacVim-with-iTerm2.md +++ b/On-MacVim-with-iTerm2.md @@ -1,3 +1,5 @@ +# For iTerm2 version 2.x + (Originally posted by @gleachkr) To open fzf from MacVim in a new iTerm2 window, it should work to make the following script executable somewhere in your Vim's PATH (with the title, for example, "In_a_new_term_function") and to let g:fzf_launcher = "In_a_new_term_function %s" @@ -74,4 +76,34 @@ end run' $1 $PWD And put it in PATH (I've put it in `/usr/local/bin`) -Note: it doesn't work very well if you've got an instance of iTerm2 running in full screen \ No newline at end of file +Note: it doesn't work very well if you've got an instance of iTerm2 running in full screen + +# For iTerm2 version 3.0 and higher + +(Added by @amacdougall) + +The Applescript API for iTerm2 has changed with version 3.0. This updated script works for me: + +```bash +# update for iterm2 3.0+ +osascript -e \ +'on run argv + tell application "System Events" + set old_frontmost to item 1 of (get name of processes whose frontmost is true) + end tell + tell application "iTerm2" + set myterm to (create window with default profile) + tell current session of first window + -- exec command "bash" + write text "cd " & quoted form of (item 2 of argv) + write text (item 1 of argv) & " && exit" + end tell + repeat while (exists myterm) + delay 0.1 + end repeat + end tell + tell application old_frontmost + activate + end tell +end run' "$1" "$PWD" +``` \ No newline at end of file