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

ZSH and subshell has two prompts #1550

Open
3 of 15 tasks
chrissound opened this issue Apr 6, 2019 · 5 comments
Open
3 of 15 tasks

ZSH and subshell has two prompts #1550

chrissound opened this issue Apr 6, 2019 · 5 comments

Comments

@chrissound
Copy link

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

If I run fzf within a subshell, it seems to 'prompt' twice - and the first selection is ignored. In other words, it requires two "enter" to be pressed twice on the keyboard before it returns back to the cli.

This behaviour only occurs within zsh for me - works fine in bash.

echo "$(echo 'test' | fzf)" can be used to reproduce the issue.

zsh --version
zsh 5.6.2 (x86_64-pc-linux-gnu)
fzf --version
0.17.4
@chrissound
Copy link
Author

Peek 2019-04-06 16-22

@junegunn
Copy link
Owner

I can't reproduce the problem on zsh 5.6.2 with fzf 0.18.0. My zshrc has only a single line, [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh, so you might want to check if it's caused by some configuration.

@Mange
Copy link

Mange commented Jul 4, 2019

I have the same issue and can replicate the problem with the above command.

fzf 0.18.0
zsh 5.7.1

› setopt
autocontinue
autopushd
autoresume
extendedglob
histignorealldups
histignorespace
histverify
interactive
kshglob
monitor
nonomatch
promptsubst
pushdignoredups
shinstdin
transientrprompt
zle

› which fzf
/usr/bin/fzf

› file /usr/bin/fzf
/usr/bin/fzf: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0,
Go BuildID=Vek4RudxVh00gKGFFHHP/yN-c3wjMGEYRSw50pnzZ/7jcep3k4gAkidOoXzm3_/rsMeRcTJtPJoND6uUG5u,
BuildID[sha1]=409413e3c41b58a1658b699aa60987d3c12a116e, stripped

@Mange
Copy link

Mange commented Jul 4, 2019

I found my cause of the problem!

My process:

If I start zsh without loading my profile, the problem goes away. So it has to do with my settings somehow.

I found that when I uncomment a line to add a preexec hook, then the problem goes away.

In that preexec command, I try to set the title of the terminal. The title should contain the command name. This is a good hint. It might also have to do with my promptsubst option set.

I so I tried changing that part of the code:

  # From
  local terminal_title_format="$2 [%4~]"
  print -Pn "\033]0;${terminal_title_format}\007"

  # To
  (
    setopt nopromptsubst
    local terminal_title_format="$2 [%4~]"
    print -Pn "\033]0;${terminal_title_format}\007"
  )

and now there is no problem, but my terminal title still works.

I've been suffering this for weeks, but didn't really investigate until now.

@chrissound
Copy link
Author

@Mange that sounds very similar to what I would have been doing, thanks for the write up!

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

No branches or pull requests

3 participants