The current fpath comparison uses `grep -Fx` against `$fpath` joined as
a single string. This fails whenever fpath duplicate counts drift
between sessions, which happens on any setup where `.zprofile` or
`.zshenv` modifies fpath via `brew shellenv`, `pyenv init`, `conda init`,
mise, nvm, direnv, or similar — these tools commonly re-prepend a
site-functions directory that another init file already added.
When the comparison fails, OMZ deletes the dump and runs a full
compinit rebuild on every startup, adding 500-1500 ms to shell init
despite the cache being functionally valid.
Deduplicate fpath (preserving first-occurrence order) before comparing
so sessions that differ only in duplicate counts produce identical
metadata. Order is preserved because `compinit` resolves colliding
completion files by first-occurrence in fpath, so sorting would risk
masking legitimate invalidation when two fpath orderings register
different compdef functions.
Existing dumps are invalidated once on upgrade, then work normally.
Fixes#13720
Double quotes within the subscript test are interpreted literally, making the
test never match. On subsequent runs, the `$ZSH_CACHE_DIR/completions` directory
is always prepended to `$fpath`, even if it is already there. This commit fixes
that.
Fixes#12551
Co-authored-by: Adem Simsek <adem@simsek.dev>
Fix regression introduced in #11550. If an existing alias was present in
the moment of sourcing, and oh-my-zsh aliases were disabled for that
file, it'd be overwritten aswell. See #11658.
Digit modifiers were introduced in zsh 5.7.1 [1]. This commit uses readily available
alternatives for backwards compatibility.
[1] b8dc5a7f6dFixes#11598
BREAKING CHANGE: the previous zstyle setting to disable `lib/directories.zsh` aliases has
been changed to the new syntax: `zstyle ':omz:lib:directories' aliases no`. See
https://github.com/ohmyzsh/ohmyzsh#skip-aliases to see other ways you can use this setting.
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
This fixes an edge case where the user actually sets
zstyle ':completion:*' list-colors
in their zshrc, but the previous code used a precmd hook, which would
override the user changes. With this change our modifications will be
set in the init script, after the theme loads, so that later changes
can affect our defaults.
Note that this will not be run for users on plugin managers, as these
don't generally run our init script.
If `$SHORT_HOST` contains invalid filename characters, the compinit call doesn't
error, but the zcompdump metadata write does. Use `tee` instead so we can silence
the error.
See dd1a72696f (commitcomment-38984764)
The statements for selecting a random theme in oh-my-zsh.sh and the themes
plugin are duplicate. Most people eventually settle on a theme, making those
lines in oh-my-zsh.sh superfluous. To address those, it may makes sense to put
the random theme functionality into a theme of its own (since themes are just
zsh scripts.