-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recommendation regarding zsh compinit #3965
Comments
I currently came up with the following workaround: In # zsh
programs.zsh.enable = true;
programs.zsh.interactiveShellInit = ''
# Enable the below for profiling zsh's startup speed.
# Once enabled, get numbers using:
# zsh -i -l -c 'zprof'
#zmodload zsh/zprof
# Disable `compaudit` being invoked from GRML cominit call.
# See: https://grml.org/zsh/grmlzshrc.html
# This speeds up shell loading.
zstyle ':grml:completion:compinit' arguments -C
# Load grml's zshrc.
# Note that loading grml's zshrc here will override NixOS settings such as
# `programs.zsh.histSize`, so they will have to be set again below.
source ${pkgs.grml-zsh-config}/etc/zsh/zshrc
# From https://htr3n.github.io/2018/07/faster-zsh/
# Theoretically it should not be needed (as described on https://dev.to/djmoch/zsh-compinit--rtfm-47kg)
# but I couldn't figure out how to make the GRML zshrc do only a single compinit
# without compaudit but generating .zcompdump (I use `-C` for
# `:grml:completion:compinit` above to avoid compaudit but that also skips
# generating `.zcompdump` apparently).
# Snippet based on https://gist.github.com/ctechols/ca1035271ad134841284
autoload -Uz compinit
if [[ -n ${ZDOTDIR:-$HOME}/.zcompdump(#qN.mh+24) ]]; then
compinit
else
# We don't do `compinit -C` here because the GRML zshrc already did it above.
fi
'';
programs.zsh.promptInit = ""; # otherwise it'll override the grml prompt
# Speed up zsh start by running compinit manually (see config above).
programs.zsh.enableGlobalCompInit = false; In zsh = {
enable = true;
# Using GRML zshrc in /etc/nixos/configuration.nix currently
# instead of `oh-my-zsh` because so far it cannot properly show
# git rebases in the prompt, which I care a lot about.
# My global NixOS config does `compinit` already.
# Disabling it in my user's `.zshrc` because calling it multiple
# times causes startup delay, see:
# https://github.com/nix-community/home-manager/blob/990b82ecd31f6372bc4c3f39a9171961bc370a22/modules/programs/zsh.nix#L518-L524
enableCompletion = false;
}; So in summary, I
This works, but I am not sure if it is optimal, and it also means that if |
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting. If you are the original author of the issue
If you are not the original author of the issue
Memorandum on closing issuesDon't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort. |
thanks, you saved my day indeed EDIT. I found that when I use zplug, it compinit on behalf of me so I could get rid of compinit things from my nixes |
Thank you for your contribution! I marked this issue as stale due to inactivity. Please be considerate of people watching this issue and receiving notifications before commenting 'I have this issue too'. We welcome additional information that will help resolve this issue. Please read the relevant sections below before commenting. If you are the original author of the issue
If you are not the original author of the issue
Memorandum on closing issuesDon't be afraid to manually close an issue, even if it holds valuable information. Closed issues stay in the system for people to search, read, cross-reference, or even reopen – nothing is lost! Closing obsolete issues is an important way to help maintainers focus their time and effort. |
Hi, a hit an issue with
zsh
that starting a new shell (by opening a new terminal, typingzsh
, or benchmarking withcommand time zsh -i -l -c ':'
) took ~300 ms, causing a noticeable, annoying delay.Using
zprof
(e.g. as described here) showed thatcompinit
andcompaudit
took > 85% of that time, and that they were called repeatedly (3 times for me). Both are related tozsh
's completion system.After a bit of reasearch, e.g. mainly https://dev.to/djmoch/zsh-compinit--rtfm-47kg, I learned that during
zsh
startup:zsh
completion system once by callingcompinit
-C
), it also creates a cache file.zcompdump
; this takes extra longhome-manager
's plugins for other shell-integrating software likeatuin
,fzf
, orskim
) which modifies thefpath
(if I understood it right), zsh automatitically has to re-runcompinit
.Here is my concrete setup:
/etc/nixos/configuration.nix
(where I load thegrml
zsh config)home.nix
Because of that, I get
compinit
calls in:zsh
config (NixOS module setting, code that does the call)zsh
module (module setting, code that does the call)In the latter, it seems
home-manager
already knows about the problem, because there's a comment:home-manager/modules/programs/zsh.nix
Lines 519 to 524 in 78ceec6
My issue request:
home-manager
should give some advice what to do in such situations, to minimisecompinit
/startup time e.g. when mixed NixOS/home-manager
zsh configs are in use.The text was updated successfully, but these errors were encountered: