fzf icon indicating copy to clipboard operation
fzf copied to clipboard

[Bash, gnome terminal] Ctrl+r displaying completions but pressing "enter" does nothing

Open apirrone opened this issue 7 years ago • 7 comments

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

Hello there,

I think the title describes the problem pretty well, here is a screenshot of what I get pressing ctrl+r :

capture d ecran de 2019-01-07 17-50-47

But when I press the "enter" key with an option selected, the menu disappears and nothing happens.

Thanks for your help !

apirrone avatar Jan 07 '19 16:01 apirrone

I'm having the same issue on macOS.

dieterdemeyer avatar Feb 12 '19 14:02 dieterdemeyer

I can't reproduce the issue. I suggest that you start bash with a minimal configuration file with only one line

[ -f ~/.fzf.bash ] && source ~/.fzf.bash

and see if you still have the issue. If you don't, then you need to find the culprit in your config.

junegunn avatar Feb 14 '19 06:02 junegunn

You were right. In case it helps anyone, in my config the culprit was an alias for the history command itself that screwed with the functionality.

dieterdemeyer avatar Feb 15 '19 17:02 dieterdemeyer

@dieterdemeyer Okay, if that was the case, we can ensure that the original history command is executed like so

diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash
index be24dec..cb86e98 100644
--- a/shell/key-bindings.bash
+++ b/shell/key-bindings.bash
@@ -55,7 +55,7 @@ __fzf_history__() (
   local line
   shopt -u nocaseglob nocasematch
   line=$(
-    HISTTIMEFORMAT= history |
+    HISTTIMEFORMAT= command history |
     FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS --tac --sync -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m" $(__fzfcmd) |
     command grep '^ *[0-9]') &&
     if [[ $- =~ H ]]; then

junegunn avatar Feb 17 '19 08:02 junegunn

OS: MacOS catalina Shell: Bash Terminal Emulator: both iterm, terminal Feature: history fuzzy search

I'm having a similar related issue concerning Ctrl+r for history, except I'm using aliases. (I prefer not remembering too many keyboard shortcuts.)

The issue thats occurring is: using ctr-r for history works fine and copies the selection back to the prompt

However, if I decide to use a keyboard alias to call the history function __fzf_history__:

alias fzfhistory="__fzf_history__"

the interactive fuzzy finder works, however selecting the result from fzf no longer returns back the text, instead I get back to stdout the line number from history.

fzfhistory

cliffordfajardo avatar Dec 08 '19 06:12 cliffordfajardo

I had the same issues on MacOs using zsh. It worked with a simple .zshrc file so I was able to identify that settings:

setopt SHARE_HISTORY

prevents somehow fzf from returning to the prompt the selected command when pressing Enter.

Edit: just saw this discussion here.

philippemiron avatar Nov 14 '24 14:11 philippemiron

prevents somehow fzf from returning to the prompt the selected command when pressing Enter.

The specific issue you mentioned for zsh should be fixed in the latest release, 0.56.3.

LangLangBart avatar Nov 15 '24 12:11 LangLangBart