11

I'm used to using tab completion in bash to get apt list --upgradable by typing apt ltab--utab, but I can't do the same thing with zsh: --u doesn't expand to --upgradable when I press tab.

I googled up some solutions suggesting installing zsh-completions and adding setopt completealiases to ./zshrc, but neither of these helped.

Is there any way to make it work like it did in bash?

2 Answers 2

2

Follow the steps here to get other features as well: https://github.com/abhigenie92/zsh_to_fish

  1. Install oh-my-zsh

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

  1. Clone necessary plugins.

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

  1. Add plugins to ~/.zshrc as

plugins = ( [plugins...] zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting) Note: make sure zsh-syntax-highlighting is the last one in the above list.

  1. Fix background theme issues (Not necessary depends on your theme.) Add the following line to your ~/.zshrc.

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=white'

  1. Restart zsh

source ~/.zshrc

If you like the answer, please consider starring the github repo.

2
  • 1
    Thank you for your answer. However, it only solves the problem half-way: I get completion for apt list, but not for --upgradable. It does show the suggestion when I start type --u, but pressing tab doesn't autocomplete it. Feb 25, 2018 at 8:56
  • is there an update for this issue?
    – Jamie-505
    Oct 5, 2018 at 11:23
1

It's an old question but since this has bugged me as well I took a look. I couldn't make heads of tails out of the zsh completion stuff for apt and trying to use the bash completion in zsh via bashcompinit failed also.

However, I'm happy to report that this has been fixed as of version 5.8 of zsh which was released in early 2020. That version of zsh is bundled with Ubuntu 20.04 LTS and will be in the soon to be released Debian 11.

The commit is actually here: zsh commit 44614: apt list option completion

2
  • Thanks for your answer, I'll try it once I get to my Ubuntu machine and mark it as the answer then. Feb 11, 2021 at 11:30
  • Works like a charm with zsh 5.8 on Ubuntu 20.04 LTS :) Feb 11, 2021 at 12:36

You must log in to answer this question.

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