Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacVim and iTerm2 #65

Closed
gleachkr opened this issue Jun 22, 2014 · 11 comments
Closed

MacVim and iTerm2 #65

gleachkr opened this issue Jun 22, 2014 · 11 comments
Labels

Comments

@gleachkr
Copy link

Howdy,

This is a really neat project. I thought it might be helpful to add some information about how to get it running with MacVim and iTerm2, for users as inept as myself. The following script is, so far, a passible stand-in for "xterm -e". You just need to add it to your Vim's PATH as an executable titled, for example, "In_a_new_term_function" and let g:fzf_launcher = "In_a_new_term_function %s"

#!/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"
@junegunn
Copy link
Owner

This is really cool thanks! Works like a charm.
Could you create a new wiki page for this? I'd love to add it to the README.

@junegunn junegunn added the tip label Jun 23, 2014
@gleachkr
Copy link
Author

Sure, I'd be happy to.

@junegunn
Copy link
Owner

Thank you! I'll update the README page.

@junegunn
Copy link
Owner

Hey, I've added the link to the wiki page. Thanks a lot!
Would it be possible to customize the size of the iTerm2 window?
(I really don't know applescript)

@gleachkr
Copy link
Author

Yep, to control the size you just need to insert the lines

      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). You can also control the position of the window by setting its bounds, but this creates some flicker---the window pops into existence in one place and is abruptly repositioned.

@junegunn
Copy link
Owner

Thanks, it works flawlessly! And thanks for updating the wiki page 😃

@cabhishek
Copy link

@junegunn I have the (apple) script named fzf_launch on Vim's PATH and I can see it by typing :set runtimepath?. Apple script works fine when I invoke it manually but I'm unable to make it work with let g:fzf_launcher
Getting Error running fzf_launch '/Users/cabhishek/.fzf/bin/fzf --expect ctrl-v,ctrl-x,ctrl-m,ctrl-t' when I type :FZF in Vim. I'm missing something ?

@junegunn
Copy link
Owner

junegunn commented Jul 6, 2015

@cabhishek The script should be in your shell's $PATH, not Vim's runtimepath. Or you can just specify the full path to the script in launcher option.

@cabhishek
Copy link

@junegunn Thanks worked.

@krasnovpro
Copy link

Error detected while processing function 122_cmd[10]..fzf#run[63]..122_execute:
line 12:
E767: Too many arguments to printf()

@rewop
Copy link

rewop commented Aug 12, 2017

I have a similar error as @krasnovpro :

Error detected while processing function <SNR>70_cmd[14]..fzf#run[79]..<SNR>70_execute:
line   12:
E767: Too many arguments to printf()  

junegunn pushed a commit that referenced this issue Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants