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

executing vi as an external program #1360

Closed
13 tasks
nkh opened this issue Aug 24, 2018 · 4 comments
Closed
13 tasks

executing vi as an external program #1360

nkh opened this issue Aug 24, 2018 · 4 comments

Comments

@nkh
Copy link

nkh commented Aug 24, 2018

  • 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

@junegunn
Copy link
Owner

Have you tried overriding the stdin of the process?

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

@larsks
Copy link

larsks commented Mar 1, 2021

@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.

junegunn added a commit that referenced this issue Mar 25, 2021
#1360 (comment)

  # Redirect /dev/tty to suppress "Vim: Warning: Input is not from a terminal"
  ls | fzf --bind "enter:execute(vim {} < /dev/tty)"

  # With this change, we can omit "< /dev/tty" part
  ls | fzf --bind "enter:execute(vim {})"
@junegunn
Copy link
Owner

@larsks Thanks for the suggestion. Please test f84b3de.

TylerSeanRau pushed a commit to TylerSeanRau/fzf that referenced this issue Jun 4, 2021
junegunn#1360 (comment)

  # Redirect /dev/tty to suppress "Vim: Warning: Input is not from a terminal"
  ls | fzf --bind "enter:execute(vim {} < /dev/tty)"

  # With this change, we can omit "< /dev/tty" part
  ls | fzf --bind "enter:execute(vim {})"
kralicky pushed a commit to kralicky/fzf that referenced this issue Jun 23, 2021
junegunn#1360 (comment)

  # Redirect /dev/tty to suppress "Vim: Warning: Input is not from a terminal"
  ls | fzf --bind "enter:execute(vim {} < /dev/tty)"

  # With this change, we can omit "< /dev/tty" part
  ls | fzf --bind "enter:execute(vim {})"
@PatrickF1
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants