help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guix completion in zsh


From: Brice Waegeneire
Subject: Re: guix completion in zsh
Date: Tue, 02 Jun 2020 13:59:01 +0000
User-agent: Roundcube Webmail/1.3.8

Hello Reza,

On 2020-05-30 06:21, Reza Alizadeh Majd wrote:
On Tue, 26 May 2020 23:14:01 +0200
Ludovic Courtès <ludo@gnu.org> wrote:

I think you need to make sure the Zsh completion file for Guix is
sourced.


Thanks for you response, what is the right location to find this "Zsh
completion file"? is it installed during installation of `zsh` package?

I had the same issue since I switched to Guix but I didn't took the time to look into it before.

I just submitted a patch[0] that add
"/run/current-system/profile/share/zsh/site-functions" to $fpath, so system
packages will get completions. To get completions from user profile, I
added the following to my system configuration:

--8<---------------cut here---------------start------------->8---
(define %zshrc
  (plain-file "zshrc"
              "\
fpath+=($HOME/.guix-profile/share/zsh/site-functions)
"))

(operating-system
  …
  (services (list …
                 (simple-service 'zshrc etc-service-type
                   (list `("zshrc" ,%zshrc))))))
--8<---------------cut here---------------end--------------->8---

When $fpath is properly set, the user only have to run “autoload -Uz
compinit && compinit” or add it to it's '~/.zshrc' to enable completions.

I don't know how to add completions when using “guix environment”
especially when executed multiple times in a shell since GUIX_ENVIRONMENT
get replaced each time it's executed.

Also note that the ZSH completion for 'guix' has never been updated in 4
years so it's missing quite a few commands and options while 'guix-daemon' completion doesn't exists. So you get completions as nice as the ones from
bash.

I tried updating zsh's completions but I didn't went far because it's
tedious since it's a lot of copy pasting from “guix --help”. So to get
proper completion support for zsh a better solution would be to use the
bash completions as they are parsed from “guix --help” directly instead of being copy-pasted and that zsh provide a bash compatible completion system
trough 'bashcompinit'. But unfortunately our bash completions have some
bashism that zsh can't understand, especially the 'compopt' built-in. You can try to use bash completion in zsh by running “autoload bashcompinit && bashcompinit && source ./etc/completion/bash/guix” but you will end up with
half broken completions.

[0]: https://issues.guix.info/issue/41662

- Brice



reply via email to

[Prev in Thread] Current Thread [Next in Thread]