fzf icon indicating copy to clipboard operation
fzf copied to clipboard

Key Bindings not working with Catalina

Open NoLookForcePush opened this issue 4 years ago • 13 comments

  • [x] I have read through the manual page (man fzf)
  • [x] I have the latest version of fzf
  • [x] I have searched through the existing issues

Info

  • OS
    • [ ] Linux
    • [x] Mac OS X
    • [ ] Windows
    • [ ] Etc.
  • Shell
    • [x] bash
    • [x] zsh
    • [ ] fish

Problem / Steps to reproduce

Keybindings do not seem to working on my Mac running Catalina. I have installed fzf with the following steps:

brew update
brew install fzf
/usr/local/opt/fzf/install
source ~/.bashrc

But ** yields nothing, and none of the keybings (Ex. CTRL-T) do anything either. I have tried source-ing the .bashrc from .bash_profile with no luck either. For reference, those files look like the following:

bash-3.2$ cat ~/.bashrc
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
bash-3.2$ cat ~/.bash_profile
if [ -f $HOME/.bashrc ]; then
        source $HOME/.bashrc
fi

I have tried this same process with zsh (And .zshrc respectively), but no luck.

Any ideas?

NoLookForcePush avatar May 11 '20 22:05 NoLookForcePush

why not cat ~/.fzf.bash and see what is there.

You don't need to source .bashrc in .bash_profile, it is a terrible practice. Please read the https://wiki.archlinux.org/index.php/Environment_variables 'defining variables' section (even if you're in macOS it is all the same) and learn what your shells are doing. When sourcing anything.

varagnac avatar May 16 '20 12:05 varagnac

it is a terrible practice.

I disagree. It's a very common and practical solution for macOS users.

junegunn avatar May 17 '20 02:05 junegunn

@varagnac You might be on to something, considering ~/.fzf.bash isn't even on my computer. What should it's contents be? And should it have been installed automatically by brew? I've searched through the issues and documentation and I can't find and references to the file.

NoLookForcePush avatar May 18 '20 16:05 NoLookForcePush

@NoLookForcePush AFAIK that file should be created when you run /usr/local/opt/fzf/install.

~~FWIW (after following the installation instructions) I have a similar issue with **<Tab> not working on both bash-5.0.17 (Homebrew) as well as bash-3.2.57 (system). However, <Ctrl-T> works with both (after sourcing ~/.fzf.bash). And both **<Tab> and <Ctrl-T> do work on system zsh-5.7.1. I'm on macOS Catalina, although it feels like the issue may be the shell, not the OS.~~

~~My experience seems to be similar to this comment https://github.com/junegunn/fzf/issues/716#issuecomment-587164331, however I still can't get **<Tab> working even if I place~~

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

~~as the last line of ~/.bash_profile, so the solution doesn't seem to work.~~

~~EDIT I managed to isolate the code in my .bash_profile that was causing it to not work, although truthfully I really don't understand why. It's this snippet I put in to fix tmux meddling with $PATH (https://superuser.com/a/583502):~~

if [ -f /etc/profile ]; then~~
    PATH=""
    source /etc/profile
fi

~~Commenting out those lines solved the problem. (Although it probably leads to tmux issues again.) An alternative solution that doesn't involve commenting that out is to prepend $HOME/.fzf/bin to $PATH at the end of .bash_profile, which I'm going to go with for now.~~ Now looking forward to many more fuzzy searches 😃

Sorry, please ignore my additions; I can't reproduce it anymore. Think it was too late at night. Placing [ -f ~/.fzf.bash ] && source ~/.fzf.bash at the end of .bash_profile without any other $PATH meddling now works for me, so this is norepro. My apologies again and thank you for your work!

yongrenjie avatar May 20 '20 20:05 yongrenjie

@yongrenjie Thanks so much for spending so much time looking into this! Unfortunately, it still doesn't work. My setup looks like:

~/.bash_profile

if [ -f ~/.bashrc ]; then
  . ~/.bashrc
fi

# homebrew bash completion
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"

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

~/.fzf.bash

# Setup fzf
# ---------
if [[ ! "$PATH" == */usr/local/opt/fzf/bin* ]]; then
  export PATH="${PATH:+${PATH}:}/usr/local/opt/fzf/bin"
fi

# Auto-completion
# ---------------
[[ $- == *i* ]] && source "/usr/local/opt/fzf/shell/completion.bash" 2> /dev/null

# Key bindings
# ------------
source "/usr/local/opt/fzf/shell/key-bindings.bash"

~/.bashrc

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

NoLookForcePush avatar May 22 '20 05:05 NoLookForcePush

You should be able to see the key bindings from the output of bind command like so:

$ bash --rcfile ~/.fzf.bash

bash-5.0$ bind -s
"\ec": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"

bash-5.0$ bind -X
"\C-r": "__fzf_history__"
"\C-t": "fzf-file-widget"

junegunn avatar May 25 '20 10:05 junegunn

Unfortunately, none of these have helped. But I appreciate all the suggestions!

NoLookForcePush avatar Jun 05 '20 23:06 NoLookForcePush

This worked In my case the .fzf.zsh file had the keybinding disabled, I had to enable them:

source "/home/$(whoami)/.fzf/shell/key-bindings.zsh"
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

or try this with bash Also Paste above line in vi ~/.zshrc file and don't forget to run this command afterward source ~/.zshrc

ghost avatar Jun 17 '20 06:06 ghost

I was having same issue when I installed fzf with brew, install using git it will work for sure and paste this [ -f ~/.fzf.bash ] && source ~/.fzf.bash in your .bash_profile or zsh one. First Uninstall fzf and then do this. Use: git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf then ~/.fzf/install then exit Then close and reopen terminal and the commands should would work.

aa-ryan avatar Jun 21 '20 15:06 aa-ryan

I can reproduce this 100% on Catalina Installed fzf via homebrew Manually ran /usr/local/Cellar/fzf/0.22.0/install script Successfully created the ~/.fzf.bash and ~/.fzf.zsh files. Both are sourced in ~/.bashrc and ~/.zshrc After opening and closing my terminal or manually sourcing the files, this still doesn't work.

My default bash is zsh and I have oh-my-zsh installed I wonder if this could be the root cause. Does anybody else has the same setup?

I switched to bash for troubleshooting completeness and the issue is still reproducible. Makes me think oh-my-zsh is not the culprit here.

eandrade21 avatar Aug 27 '20 00:08 eandrade21

I ran into this issue randomly yesterday after messing around in my zshrc file. I tracked it down to having set -o vi after I sourced ~/.fzf.zsh. I fixed it by sourcing ~/.fzf.zsh after setting vi mode. I also confirmed replacing both manual vi setting and manual sourcing of fzf with the vi-mode and fzf oh-my-zsh plugins work.

jhicks avatar Oct 13 '20 02:10 jhicks

Hey question those using mac os what version of bash are you running? Because its my understanding that apple uses version 3.2 because that's the last license under the gplv2

rayiik avatar Jan 10 '21 11:01 rayiik

@jhicks See #2694

junegunn avatar Feb 23 '22 06:02 junegunn