From c624940b8e81301744a5357698949e6d207aa667 Mon Sep 17 00:00:00 2001 From: Ben Atkin Date: Wed, 2 Aug 2017 12:08:11 -0700 Subject: [PATCH] Move iTerm 2 v3 above iTerm 2 v2 because it's probably more common --- On-MacVim-with-iTerm2.md | 163 ++++++++++++++++++++------------------- 1 file changed, 82 insertions(+), 81 deletions(-) diff --git a/On-MacVim-with-iTerm2.md b/On-MacVim-with-iTerm2.md index a613a6c..afe5682 100644 --- a/On-MacVim-with-iTerm2.md +++ b/On-MacVim-with-iTerm2.md @@ -1,83 +1,3 @@ -# For iTerm2 version 2.x - -(Originally posted by @gleachkr) - -To open fzf from MacVim in a new iTerm2 window, create an executable script with the following content and add `let g:fzf_launcher = "PATH_TO_THE_SCRIPT_FILE %s"` to your Vim configuration. - -```bash -#!/bin/bash - -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 "iTerm" - activate - set myterm to (make new terminal) - tell myterm - set mysession to (make new session at the end of sessions) - tell mysession - 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 - end tell - tell application old_frontmost - activate - end tell -end run' "$1" "$PWD" -``` - -to control the size of the generated iTerm window you just need to insert the lines - -```applescript - set number of columns of myterm to C - set number of rows of myterm to R -``` -for some numbers C,R after `set myterm to (make new terminal)` - -**And for zsh**: - -```sh -#!/usr/local/bin/zsh - -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 "iTerm" - activate - set myterm to (make new terminal) - # set number of columns of myterm to 250 - # set number of rows of myterm to 30 - tell myterm - set mysession to (make new session at the end of sessions) - tell mysession - exec command "env PATH=/usr/local/bin/:$PATH /usr/local/bin/zsh -f" - 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 - end tell - tell application old_frontmost - activate - end tell -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 - # For iTerm2 version 3.0 and higher (Added by @amacdougall) @@ -167,4 +87,85 @@ and then put inside fzf_MacVim.sh (your g:fzf_launcher). osascript -l JavaScript /path/to/fzf_MacVim.scpt "$1" $PWD ``` -I recommend creating separate iTerm profile for fzf interaction. \ No newline at end of file +I recommend creating separate iTerm profile for fzf interaction. + +# For iTerm2 version 2.x + +(Originally posted by @gleachkr) + +To open fzf from MacVim in a new iTerm2 window, create an executable script with the following content and add `let g:fzf_launcher = "PATH_TO_THE_SCRIPT_FILE %s"` to your Vim configuration. + +```bash +#!/bin/bash + +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 "iTerm" + activate + set myterm to (make new terminal) + tell myterm + set mysession to (make new session at the end of sessions) + tell mysession + 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 + end tell + tell application old_frontmost + activate + end tell +end run' "$1" "$PWD" +``` + +to control the size of the generated iTerm window you just need to insert the lines + +```applescript + set number of columns of myterm to C + set number of rows of myterm to R +``` +for some numbers C,R after `set myterm to (make new terminal)` + +**And for zsh**: + +```sh +#!/usr/local/bin/zsh + +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 "iTerm" + activate + set myterm to (make new terminal) + # set number of columns of myterm to 250 + # set number of rows of myterm to 30 + tell myterm + set mysession to (make new session at the end of sessions) + tell mysession + exec command "env PATH=/usr/local/bin/:$PATH /usr/local/bin/zsh -f" + 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 + end tell + tell application old_frontmost + activate + end tell +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 +