In bash, if I type dnf install java<tab>, I get a bunch of suggestions of packages to install. However, if I do this in zsh, nothing happens. I've played around with /etc/bashrc and discovered that bash_completion allows this to work in bash, but I can't figure out how to make this work in zsh.

  • What version of ZSH do you have? print $fpath[-1]/_dnf shows a dnf completion script on ZSH 5.3.1.
    – thrig
    Jun 8, 2017 at 23:49
  • Looks like updating zsh did it. If you post this as an answer, I'll gladly accept it.
    – ollien
    Jun 9, 2017 at 2:13
  • FWIW, dnf does NOT have a completion script in 5.2
    – ollien
    Jun 9, 2017 at 2:15

1 Answer 1


ZSH ships with completions in $fpath; these change over time especially for new and exciting programs that old and decrepit ZSH installs may know nothing about. The usual steps should be:

  1. update your ZSH to the latest version and see if a completion script now exists—print $fpath[-1]/_dnf though for some commands the completion may exist in some other file under a compdef line.
  2. check if the software ships with a ZSH completion script that has not be contributed to the e.g. zsh-workers mailing list (rare, but if so, perhaps submit that completion code to the ZSH folks so they can include it.
  3. check whether some other ZSH completion repository contains completion code e.g. https://github.com/zsh-users/zsh-completions/
  4. write your own completion script for the program. This typically requires studying the existing completion scripts, the zshall(1) docs on e.g. _arguments and so forth, and the usual fiddling and testing of things.

A handy command to glob the files in $fpath is

% print -l ${^fpath}/_pgrep(N)

which shows that on my Mac I have a custom completion for pgrep in addition to the upstream one.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .