Skip to content

automatic tty redirection should not statically target /dev/tty, but the current pty/pts #4242

@andreaskremser

Description

@andreaskremser

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.59.0 (bbe1721)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

Since 0.53.0 fzf will automatically redirect execute actions to /dev/tty,

so that the usual hack

ls | fzf --bind 'space:execute:vim {} < /dev/tty >/dev/tty'  > selected

could be simplified, without worrying about any redirection

ls | fzf --bind `space:execute:vim {}' > selected

but the static /dev/tty is not universally understood/not always a working solution.
A more robust approach would be to query the current pty (e.g. with /usr/bin/tty), which would return something like /dev/pts/4

The more general solution, that also works with programs like emacsclient, should probably be equivalent to something like this:

CURRENT_TTY=$(tty)
ls | fzf --bind "space:execute:emacsclient -t -a \"\" -c {} < $CURRENT_TTY > $CURRENT_TTY" > selected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions