git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] completion: add new zsh completion

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jan 30, 2012, 11:28 UTC
Message-ID
<CAMP44s2MmqEeyvztk8_3q9Ms_-su0D12GYD_LLWCKPAmb2ZKXg@mail.gmail.com>
In-Reply-To
<CAMP44s3QeZuXrR=UE4qvDadu66Cmi-txmSps8Ow24om27URxOg@mail.gmail.com>

On Mon, Jan 30, 2012 at 12:59 PM, Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 24 quoted lines
> On Mon, Jan 30, 2012 at 10:39 AM, Matthieu Moy
> <Matthieu.Moy@grenoble-inp.fr> wrote:
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>> +ZSH_VERSION='' . /usr/share/git/completion/git-completion.bash
>>
>> Probably stating the obvious, but this path shouldn't be hardcoded.
>>
>> Something along the lines of
>>
>> ZSH_VERSION='' . $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
>>
>> should do it (mostly untested, and written by a non-ZSH expert).
>
> Yes, it's hard-coded, because there's no way to know where is this
> file. In my case, it's on ~/.git-completion.sh, and this one that I am
> proposing sits in ~/.zsh/completion/_zsh, so your proposal breaks
> things completely for me.
>
> I will think about it, but I think for now, users of this script
> should set that manually--if for some reason they don't want to use
> the default.
>
> Maybe we should use zstyle so they can configure it on their .zshrc?
This seems to do the trick:

zstyle -s ":completion:$curcontext:" script script test -z "$script" && script="$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash ZSH_VERSION='' . "$script"

.zshrc: zstyle ':completion:*:*:git:*' script ~/.git-completion.sh

-- 
Felipe Contreras
Previous: Felipe ContrerasNext: Johannes Sixt
Message 4 of 7 in “completion: add new zsh completion”
  1. completion: add new zsh completionFelipe Contreras, Jan 30, 2012
  2. Matthieu MoyJan 30, 2012
  3. Felipe ContrerasJan 30, 2012
  4. Felipe ContrerasJan 30, 2012
  5. Johannes SixtJan 30, 2012
  6. Felipe ContrerasJan 30, 2012
  7. Junio C HamanoJan 30, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.