Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Setup git-stash completion for a function: $line is wrong



Bart Schaefer wrote on Thu, Mar 16, 2017 at 14:02:24 -0700:
> On Mar 15, 12:59am, Daniel Hahler wrote:
> } Bart Schaefer:
> } > There's already (compdef cmd=service) e.g.
> } > 
> } >     compdef gsta=git
> } 
> } Yes, I am aware of that, and what I mean is more or less something in this
> } regard, e.g. by making it handle command+arguments.
> 
> For other readers of this thread:  Any input here on whether this is
> actually a common use case?

As a datapoint: in my zshrc, I have 12 wrapper functions of the «foo()
{ command foo "$@" }» form, and only one function that would benefit
from the proposed compdef enhancement.

That function takes 'git rev-list' arguments and runs 'tig' (a Git
history viewer, like gitk) on them:
.
    mytig() {
      if (( $# )); then
        tig --no-walk $(git log --pretty=%H "$@")
      else
        tig --date-order --all -150
      fi
    }

Writing a completion function for this helper today is a little tricky,
since 'autoload +X _git' doesn't define _git-log().  Under the proposal,
defining completion for this helper would simply be «compdef mytig='git
log --pretty=%H'».  (Or whatever syntax is decided on)

Cheers,

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author