From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3598 invoked from network); 23 Oct 2020 08:50:02 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 23 Oct 2020 08:50:02 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Message-ID:Date:Content-ID: Content-Type:MIME-Version:Subject:To:References:From:In-reply-to:cc:Reply-To: Content-Transfer-Encoding:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=1wWekhXnPDyQ+YZ76lrQEc72D4THqAZwaM0DZtgpN2Q=; b=k5Vdpqc7PYT/LqA0ba1ZwjmZrm NWMs1bvSaovxRHyqS1utusFp+5GOAluIdtYE2qyI1pAplh1vZJkuQKjyM3ukFzuvOUFdLwWsGlqKO Ow2lrV1lsJ1mzC5E1e0iNTJb9f4/8FARbcH6MlGhh9XKxLeeBzHrpVQF889SZUXmIitfoM3gsSSyU hSWyO3NglvZ0gCpY5hxGsIMchWNgoHMqqvo+eUzn3kl7CeQCGL++yhwj1vJrNHrM+jJyzATHOnrxD 2TKfK+29nH3qKlG1GXOJKALUlEzQEsF5sE5L+7tudM4h9YjfxefjQzTSofz2vzFaajJ0BzD7kf9IG wdGTRPHQ==; Received: from authenticated user by zero.zsh.org with local id 1kVslt-000LPU-MJ; Fri, 23 Oct 2020 08:50:01 +0000 Received: from authenticated user by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1kVslW-000L2x-CX; Fri, 23 Oct 2020 08:49:38 +0000 Received: from [192.168.178.21] (helo=hydra) by mail.kiddle.eu with esmtp(Exim 4.93.0.4) (envelope-from ) id 1kVslU-0003VP-IG; Fri, 23 Oct 2020 10:49:37 +0200 cc: zsh-users@zsh.org In-reply-to: From: Oliver Kiddle References: To: jost.schulte@tutanota.com Subject: Re: Update git completion on macOS MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <13477.1603442976.1@hydra> Date: Fri, 23 Oct 2020 10:49:36 +0200 Message-ID: <13478-1603442976.562996@mTtw.97It.xjXz> X-Seq: 26125 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: 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