From: Oliver Kiddle <opk@zsh.org>
To: jost.schulte@tutanota.com
Cc: zsh-users@zsh.org
Subject: Re: Update git completion on macOS
Date: Fri, 23 Oct 2020 10:49:36 +0200 [thread overview]
Message-ID: <13478-1603442976.562996@mTtw.97It.xjXz> (raw)
In-Reply-To: <sympa.1603440549.76406.154@zsh.org>
jost.schulte@tutanota.com wrote:
> Here's my problem: Running on macOS 10.15, I've set up zsh with completion of
> git commands. It must be the complete function that comes with the os
> installation of zsh, because I didn't add it and I don't use oh-my-zsh. In
> this complete function the newer git commands like "switch" or "restore" are
> not included, so I want to update it.
The best way to do this would be to install a newer zsh on your system.
A common way to do this on macOS is to use something like macports,
homebrew or fink. These install an additional zsh in somewhere like
/opt/local/bin/zsh and leave the system one alone. You could also
take the more manual approach of downloading the source code tarball,
unpacking it and running ./configure followed by make and make install.
> I've researched a while and found the function in /usr/share/zsh/5.7.1/
> functions/ in the file _git. What I couldn't find is a current complete
> function and also I wasn't able to modify the contents of the file. Even using
> "sudo" I get the error that I don't have permissions to edit it.
>
> Can anyone help me out please?
Overwriting system installed files is not a good idea in general. If you
want to use a modified completion function, the best approach is to put
it in a dedicated directory and point zsh to look in that directory
before the system directories.
So you might do:
mkdir ~/.zfunc
Install your custom _git in there. Then in your .zshrc file you would
need to add ~/.zfunc to the beginning of the $fpath array. So you might
have a line like:
fpath=( ~/.zfunc $fpath )
But note that this needs to come before you run compinit to enable the
completions.
To get a current completion function, the best approach is to checkout
the zsh sources from git and look below the Completion directory. Mostly
that will work but in this particular case, I happen to know that it
won't. The latest _git function makes use of new zsh features that were
only added after zsh 5.7. You might be able to manually patch together
an _git that does what you want. The patch for git switch and restore is
here:
https://www.zsh.org/mla/workers/2019/msg00815.html
If it doesn't apply cleanly to the file you have for 5.7.1, grabbing
just the _git-restore and _git-switch functions should be sufficient.
Oliver
next prev parent reply other threads:[~2020-10-23 8:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-23 8:16 jost.schulte
2020-10-23 8:42 ` Lawrence Velázquez
2020-10-23 8:48 ` Roman Perepelitsa
2020-10-23 8:49 ` Oliver Kiddle [this message]
2020-10-23 20:38 ` Daniel Shahaf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13478-1603442976.562996@mTtw.97It.xjXz \
--to=opk@zsh.org \
--cc=jost.schulte@tutanota.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).