From 5a0c6cdefb9d39df3d0b4d88c01b8e2c528d67a8 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 17 Jan 2023 16:42:34 +0100 Subject: [PATCH] git: Fix completion for aliases to shell functions When only linking the completion function, the completion works for the shell functions, but not when using a git alias to those functions. Fix that by defining own completion functions for each that call the existing/copied ones. --- .config/zsh/zshrc.d/20-completion.zsh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.config/zsh/zshrc.d/20-completion.zsh b/.config/zsh/zshrc.d/20-completion.zsh index c4068c3..2a3b9fc 100644 --- a/.config/zsh/zshrc.d/20-completion.zsh +++ b/.config/zsh/zshrc.d/20-completion.zsh @@ -44,11 +44,18 @@ compdef nvim-man=man # Generate completion debug trace: # ? -# git +# Define completion functions instead of directly linking (e.g. `compdef +# _git-rebase git-signoff`) so that the completion works for the shell functions +# **as well** as git aliases (i.e. `git-signoff` and `git signoff`). +_git-checkout-worktree() { _git-checkout } +_git-commit-last-msg() { _git-commit } +_git-signoff() { _git-rebase } + compdef _git-log glog -compdef _git-checkout git-checkout-worktree -compdef _git-commit git-commit-last-msg -compdef _git-rebase git-signoff +compdef _git-checkout-worktree git-checkout-worktree +compdef _git-commit-last-msg git-commit-last-msg +compdef _git-signoff git-signoff + # Run git's completion once to avoid a `command not found` error when using the # completion functions on other programs without having completed something for # git before in the same session.