zsh-users
 help / color / mirror / code / Atom feed
* Update git completion on macOS
@ 2020-10-23  8:16 jost.schulte
  2020-10-23  8:42 ` Lawrence Velázquez
  2020-10-23  8:49 ` Oliver Kiddle
  0 siblings, 2 replies; 5+ messages in thread
From: jost.schulte @ 2020-10-23  8:16 UTC (permalink / raw)
  To: zsh-users

Hi everyone,

I wanted to search the archive before posting, following the documentation,
but I don't see an archive link in the list menu.

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.

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?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update git completion on macOS
  2020-10-23  8:16 Update git completion on macOS jost.schulte
@ 2020-10-23  8:42 ` Lawrence Velázquez
  2020-10-23  8:48   ` Roman Perepelitsa
  2020-10-23  8:49 ` Oliver Kiddle
  1 sibling, 1 reply; 5+ messages in thread
From: Lawrence Velázquez @ 2020-10-23  8:42 UTC (permalink / raw)
  To: jost.schulte; +Cc: zsh-users

> On Oct 23, 2020, at 4:16 AM, 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.
> 
> 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?

Assuming that installing 5.8 isn't an option, I think your best bet
is to extract _git from 5.8 (http://zsh.sourceforge.net/Arc/source.html)
and modify your fpath so the completion system finds it before the
system's outdated copy. It's fine to keep it somewhere in your home
directory.

(Hopefully the 5.8 _git works with 5.7.1, but if it doesn't you can
always edit it.)

vq

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update git completion on macOS
  2020-10-23  8:42 ` Lawrence Velázquez
@ 2020-10-23  8:48   ` Roman Perepelitsa
  0 siblings, 0 replies; 5+ messages in thread
From: Roman Perepelitsa @ 2020-10-23  8:48 UTC (permalink / raw)
  To: Lawrence Velázquez; +Cc: jost.schulte, Zsh Users

On Fri, Oct 23, 2020 at 10:42 AM Lawrence Velázquez <vq@larryv.me> wrote:
>
> Assuming that installing 5.8 isn't an option [...]

To expand on this: The best solution would be to upgrade to zsh 5.8.
Apart from adding support for `git switch` and `git restore` commands,
it has many other improvements compared to 5.7.1. The most common and
perhaps the easiest way to install zsh 5.8 on macOS is via Homebrew:

    brew install zsh

If you don't have the `brew` command, you'll need to install it first.
See https://brew.sh/.

Roman.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update git completion on macOS
  2020-10-23  8:16 Update git completion on macOS jost.schulte
  2020-10-23  8:42 ` Lawrence Velázquez
@ 2020-10-23  8:49 ` Oliver Kiddle
  2020-10-23 20:38   ` Daniel Shahaf
  1 sibling, 1 reply; 5+ messages in thread
From: Oliver Kiddle @ 2020-10-23  8:49 UTC (permalink / raw)
  To: jost.schulte; +Cc: zsh-users

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update git completion on macOS
  2020-10-23  8:49 ` Oliver Kiddle
@ 2020-10-23 20:38   ` Daniel Shahaf
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Shahaf @ 2020-10-23 20:38 UTC (permalink / raw)
  To: jost.schulte; +Cc: zsh-users

Oliver Kiddle wrote on Fri, 23 Oct 2020 08:49 +00:00:
> 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.

If you do, feel free to publish the patch.  The idea of a "backport
branch" of the Completion/ tree has been raised before; it simply lacks
a volunteer to drive it.

Cheers,

Daniel

P.S.  I always treated that underscore as silent...


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-23 20:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23  8:16 Update git completion on macOS jost.schulte
2020-10-23  8:42 ` Lawrence Velázquez
2020-10-23  8:48   ` Roman Perepelitsa
2020-10-23  8:49 ` Oliver Kiddle
2020-10-23 20:38   ` Daniel Shahaf

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).