junegunn/fzf

executing vi as an external program

nkh opened this issue · 4 comments

nkh commented
  • Category
    • fzf binary
    • fzf-tmux script
    • Key bindings
    • Completion
    • Vim
    • Neovim
    • Etc.
  • OS
    • [x ] Linux
    • Mac OS X
    • Windows
    • Windows Subsystem for Linux
    • Etc.
  • Shell
    • [ x] bash
    • zsh
    • fish

Hi, I read this
https://github.com/junegunn/fzf#executing-external-programs

which seemed to be what I wanted, having list I can execute a command on and then be able to do it again.

my command is: parallel -X --tty ra edit

Where 'ra' is an application that starts vim; that does nothing.

I tried command: ra edit {}

that worked but when I get back in fzf it's frozen and takes all the cpu, had to kill it.

note that shell command "fzf | parallel -X --tty ra edit" works just fine

Have you tried overriding the stdin of the process?

fzf --bind 'ctrl-v:execute(vim {} < /dev/tty)'

@junegunn I was about to post an issue that is really just a generalization of this one. I was wondering if it would be beneficial to add an option to run commands with an attached tty (e.g., some sort of executetty action), or if it would make sense to make this a global option (fzf --exec-on-tty ...), or if redirecting from /dev/tty is really the best option.

I was certainly tripped up by this when I first started working with fzf.

@larsks Thanks for the suggestion. Please test f84b3de.

Sorry to rez this thread but thought this would be a good place to add some important info.
IF

  1. you are using fish
  2. you are trying to execute external programs that write to stdout from fzf
  3. you are executing fzf as part of a pipe or a command substitution, then you will need to explicitly send standard out (and preferably standard error) to /dev/tty
set v (ls | fzf --bind "ctrl-v:execute(nvim {} &> /dev/tty)")

See PatrickF1/fzf.fish#203