ohmyzsh: Tab completion for second filename not working for `diff`
Describe the bug
The diff command does not have any tab file completion for second filename (hypothetical file_b.txt in diff file_a.txt file_b.txt) though the first filename is completed fine. When I add unalias diff to my .zshrc file and reload the terminal, or when I start to run command diff file_a.txt file_b.txt, tab completion works as expected for file_b.txt. Though I am using the powerlevel10k theme, the problem persists even with it commented out of my .zshrc file.
Steps to reproduce
- Open a fresh terminal window in a directory with some random files that can be
diff’d - Type
diff <FIRST_FILE>then try to tab complete the second file (doesn’t work) - Type
command diff <FIRST_FILE>then try to tab complete the second file (DOES work)
Expected behavior
diff Tab completion should work for the second filename
Screenshots and recordings
https://asciinema.org/a/QsK4uShDROZODeFWYJjmgV3vR
OS / Linux distribution
macOS 13.1
Zsh version
5.9 and 5.8.1
Oh My Zsh version
master (7de5584)
Terminal emulator
iTerm2 3.4.19
If using WSL on Windows, which version of WSL
None
Additional context
My .zshrc file is as follows:
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
if type brew &>/dev/null; then
FPATH=/opt/homebrew/share/zsh/site-functions:$FPATH
autoload -Uz compinit
compinit
fi
# rbenv setup
eval "$(rbenv init - zsh)"
source /opt/homebrew/opt/powerlevel10k/powerlevel10k.zsh-theme
# ruby-build installs a non-Homebrew OpenSSL for each Ruby version installed and these are never upgraded.
# To link Rubies to Homebrew's OpenSSL 1.1 (which is upgraded) add the following to your ~/.zshrc:
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Uncomment the following line if pasting URLs and other text is messed up.
DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
COMPLETION_WAITING_DOTS="true"
plugins=()
source $ZSH/oh-my-zsh.sh
## Misc
setopt globdots
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
unsetopt nomatch # If a pattern for filename generation has no matches, print an error, instead of leaving it unchanged in the argument list. This also applies to file expansion of an initial ‘~’ or ‘=’.
unsetopt SHARE_HISTORY # prevent shared history between tabs
zstyle ':completion:*' special-dirs false
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 19 (10 by maintainers)
Commits related to this issue
- fix(theme-and-appearance): fix `diff` completion in macOS Closes #11416 Closes #11454 — committed to carlosala/ohmyzsh by carlosala a year ago
- fix(theme-and-appearance): fix `diff` completion in macOS Closes #11416 Closes #11454 — committed to nbaronov/oh-my-zsh by carlosala a year ago
- fix(theme-and-appearance): fix `diff` completion in macOS Closes #11416 Closes #11454 — committed to ranft/oh-my-zsh by carlosala a year ago
Could we please re-open this, as the patch only works for the simple case:
diff file1 file2Tab completion is still broken when passing other arguments:diff -u file1 [tab completion fails]