Skip to content

Instantly share code, notes, and snippets.

@chew-z
Created February 19, 2017 16:12
Show Gist options
  • Save chew-z/d6cdf21ba7df2d1089ad5127000c7c75 to your computer and use it in GitHub Desktop.
Save chew-z/d6cdf21ba7df2d1089ad5127000c7c75 to your computer and use it in GitHub Desktop.
Glue between MacVim - fzf - iTerm
#!/usr/bin/env zsh
# https://github.com/junegunn/fzf/wiki/On-MacVim-with-iTerm2
# used for MacVim fzf
# 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 "iTerm"
if not application "iTerm" is running then
activate application "iTerm"
end if
set fzf_term to (create window with profile "fzf")
tell current session of first window
repeat while not is at shell prompt
delay 0.1
end repeat
select
tell application "System Events"
keystroke "u" using {control down}
delay 0.1
end tell
write text "cd " & quoted form of (item 2 of argv)
write text (item 1 of argv) & " && exit"
end tell
repeat while (exists fzf_term)
delay 0.1
end repeat
end tell
tell application old_frontmost
activate
end tell
end run' "$1" "$PWD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment