nix-zsh-completions
nix-zsh-completions copied to clipboard
Nix completion breaks prompt
Description
I have a very strange issue. I'm not sure whether nix-zsh-completion is at fault here, I expect something else on my system is causing problems, but I have ruled out most that I have thought of and am at a loss.
The problem is, when I use completion like:
bob.vanderlinden@NVC3919:~/ > nix <tab>
It will clear the whole line, including the prompt.
When I do:
bob.vanderlinden@NVC3919:~/ > nix --<tab>
It'll again clear the line, including the prompt, but it will show:
store
When I do:
bob.vanderlinden@NVC3919:~/ > nix build <tab>
It'll clear the line and show:
--store
I am very confused by this behavior. I have tried removing my ~/.zsh{rc,env,_history}
, but to no avail.
Bash completion for nix <tab>
works fine.
Zsh completion for nix<tab>
also works fine. Same for nix-build <tab>
. It is specifically completion for the nix
cli itself that's failing it seems.
Any idea what steps I can take to further investigate this issue?
System
-
nix-zsh-completions version:
0.4.4
-
ZSH version:
5.9
-
NIX_PATH:
/home/bob.vanderlinden/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
-
system:
"x86_64-linux"
-
host os:
Linux 5.15.77, NixOS, 22.11 (Raccoon), 22.11.20221109.872fcee
-
multi-user?:
yes
-
sandbox:
yes
-
version:
nix-env (Nix) 2.11.0
-
channels(root):
"nixos-21.03pre268835.8c8731330b5"
-
channels(bob.vanderlinden):
"home-manager, nixpkgs"
-
nixpkgs:
/home/bob.vanderlinden/.nix-defexpr/channels/nixpkgs
Completion trace
I have generated the trace using:
nix <Ctrl+x ?>
https://gist.github.com/bobvanderlinden/7e7dcfac986662085f2751b942f13192
I have the same problem with nix
command completion.
I think this is caused by the fact that nix 2.4+ has ANSI escape sequences in its --help
output. The completion function parses the output and the escape sequences confuse it. As this repo seems inactive, I proposed to remove the completion function in nixpkgs (see the link above). nix offers its own zsh completion, which works well.
I've forked the repo and simply deleted _nix
. This seems to work for me. See https://github.com/bryango/nix-zsh-completions and the commit https://github.com/bryango/nix-zsh-completions/commit/c0c04022c9ac44af645ed769786d2303d0fb3ac4 therein.