fzf zsh integration isn't working on Debian

Created on 1 May 2019  ·  7Comments  ·  Source: junegunn/fzf

  • 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

    • [ ] bash

    • [x] zsh

    • [ ] fish


Sorry, I probably just need to have my hand held, but it looks like the fzf completions aren't loaded at all in zsh?

~ swim@scuba
❯ autoload -U compinit

~ swim@scuba
❯ compinit

~ swim@scuba
❯ which _fzf
_fzf not found

~ swim@scuba
❯ which fzf-completion
fzf-completion not found

Most helpful comment

After installing via apt install fzf, read the docs for installing into ZSH:

cat /usr/share/doc/fzf/README.Debian

Relevant section:

===

Append this line to ~/.zshrc to enable fzf keybindings for Zsh:

   source /usr/share/doc/fzf/examples/key-bindings.zsh

All 7 comments

After installing via apt install fzf, read the docs for installing into ZSH:

cat /usr/share/doc/fzf/README.Debian

Relevant section:

===

Append this line to ~/.zshrc to enable fzf keybindings for Zsh:

   source /usr/share/doc/fzf/examples/key-bindings.zsh

I'm not familiar with the Debian package as I'm not the maintainer of it.

But note that there is separate completion.zsh file that sets up **<tab> completion. I don't know how it's handled by the Debian package.

https://github.com/junegunn/fzf/tree/master/shell

Thanks @junegunn. When I source the following file, **<tab> completion starts working:

/usr/share/zsh/vendor-completions/_fzf

However, I suspect that this is a hack/workaround. I'll see if I can find a better solution.

If I follow the installation instructions for Arch and translate them to the file locations for the Debian package, then it does appear that we need to source the _fzf file above. I suspect that the Debian package has put the files in the wrong location.

These are the Arch instructions:

Source the desired files from your .zshrc:

/usr/share/fzf/key-bindings.zsh
/usr/share/fzf/completion.zsh

The Debian package copies the files from the original source (i.e. this repository) as below:

  • shell/key-bindings.zsh => /usr/share/doc/fzf/examples/key-bindings.zsh
  • shell/completion.zsh => /usr/share/zsh/vendor-completions/_fzf

I'm no expert in Debian packaging, but I don't think these locations are correct. In lieu of changes to the Debian package, we could update the Zsh section in README.Debian to the following:

===

Append these lines to ~/.zshrc to enable fzf keybindings and completion for Zsh:

   source /usr/share/doc/fzf/examples/key-bindings.zsh
   source /usr/share/zsh/vendor-completions/_fzf

Would you like me to submit a PR?

Thanks for looking into it. Like I mentioned above, I'm not the maintainer of the package and not an expert in Debian systems at all, so please go ahead.

FWIW, here's the response from the package maintainer when I tried reaching out back in May:

An official Debian package cannot edit your .zshrc file. A quick instruction for
zsh integration can be found here:

/usr/share/doc/fzf/README.Debian

which is a standard location for notes. And the it is already pointed
out in fzf's description.
$ apt show fzf

Package: fzf
Version: 0.18.0-1
Built-Using: golang-1.11 (= 1.11.6-1), golang-github-mattn-go-isatty
(= 0.0.4-1), golang-github-mattn-go-runewidth (= 0.0.4-1),
golang-github-mattn-go-shellwords (= 1.0.3-1), golang-go.crypto (=
1:0.0~git20181203.505ab14-1), golang-golang-x-sys (=
0.0~git20181228.9a3f9b0-1)
Priority: optional
Section: utils
Maintainer: Mo Zhou cdluminate@gmail.com
Installed-Size: 3,031 kB
Depends: libc6 (>= 2.3.2)
Homepage: https://github.com/junegunn/fzf
Download-Size: 928 kB
APT-Manual-Installed: yes
APT-Sources: https://mirrors.ustc.edu.cn/debian experimental/main amd64 Packages
Description: general-purpose command-line fuzzy finder
It's an interactive Unix filter for command-line that can be used with
any list; files, command history, processes, hostnames, bookmarks, git
commits, etc.
.
Refer /usr/share/doc/fzf/README.Debian for quick instructions on how to
add keybindings for Bash, Zsh, Fish to call fzf.

I agree that something is amiss here. I think _fzf may actually not be formatted correctly to be picked up in zsh's vendor-completions, but my memory is fuzzy since looking at this a few months ago.

Other files in zsh's vendor-completions don't have to be sourced manually, so why does _fzf?

I also think that key-bindings.zsh may properly belong in zsh's vendor-functions, but that's just a guess.

I continued with @furrycatherder's bug report to the Debian package maintainer, Mo Zhou, and added the information I found above. I got this response, which I believe should resolve the issue:

Thanks for the report, I've fixed the issue in git:
https://salsa.debian.org/debian/fzf/commit/4a2c7dae658d91256bcb1ae7077dc7989532dbbe

/usr/share/doc/fzf/examples is a conventional path for Debian to install
things that should not be enabled by default. I think it's fine to not align
installation path with Archlinux, as I have updated the instructions
in README.Debian accordingly.

The change made updates the documentation and location of the files. 0.18.0-3 is the version with the fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

erusev picture erusev  ·  3Comments

ahmedelgabri picture ahmedelgabri  ·  3Comments

ghost picture ghost  ·  3Comments

aleclarson picture aleclarson  ·  3Comments

alistaircolling picture alistaircolling  ·  3Comments