mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-30 06:56:06 +02:00
docs: add plugin-manager bootstrap hook guidance
Co-authored-by: mcornella <1441704+mcornella@users.noreply.github.com>
This commit is contained in:
co-authored by
mcornella
parent
ffd4c95a4f
commit
c15b32baa4
@@ -361,7 +361,8 @@ source "$ZSH/lib/bootstrap.zsh"
|
|||||||
|
|
||||||
#### Bootstrap compatibility contract
|
#### Bootstrap compatibility contract
|
||||||
|
|
||||||
`lib/bootstrap.zsh` is idempotent and guarantees:
|
`lib/bootstrap.zsh` is idempotent and is the only required pre-load step for plugin-manager setups.
|
||||||
|
It guarantees:
|
||||||
|
|
||||||
- `ZSH`, `ZSH_CUSTOM`, and `ZSH_CACHE_DIR` defaults
|
- `ZSH`, `ZSH_CUSTOM`, and `ZSH_CACHE_DIR` defaults
|
||||||
- writable cache fallback to `${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh`
|
- writable cache fallback to `${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh`
|
||||||
@@ -372,7 +373,7 @@ source "$ZSH/lib/bootstrap.zsh"
|
|||||||
- `$ZSH_CUSTOM/functions`
|
- `$ZSH_CUSTOM/functions`
|
||||||
- `$ZSH_CUSTOM/completions`
|
- `$ZSH_CUSTOM/completions`
|
||||||
- `$ZSH_CACHE_DIR/completions`
|
- `$ZSH_CACHE_DIR/completions`
|
||||||
- public signal: `OMZ_IS_BOOTSTRAPPED=true`
|
- public signal: `OMZ_IS_BOOTSTRAPPED=true` (for one-time hook guards)
|
||||||
|
|
||||||
What still requires `oh-my-zsh.sh`:
|
What still requires `oh-my-zsh.sh`:
|
||||||
|
|
||||||
@@ -386,10 +387,61 @@ What still requires `oh-my-zsh.sh`:
|
|||||||
|
|
||||||
Run bootstrap once, before any OMZ plugin/theme load:
|
Run bootstrap once, before any OMZ plugin/theme load:
|
||||||
|
|
||||||
- **Antigen:** add a one-time pre-bundle hook to source `lib/bootstrap.zsh`.
|
```zsh
|
||||||
- **Zinit:** use a pre-load/`atinit` hook for OMZ snippets/plugins.
|
[[ -n "${OMZ_IS_BOOTSTRAPPED:-}" ]] || source "$ZSH/lib/bootstrap.zsh"
|
||||||
- **zplug:** use a load hook (`hook-load`) before OMZ plugin/theme sourcing.
|
```
|
||||||
- **zgen / zulu:** source `lib/bootstrap.zsh` immediately before OMZ plugin/theme load lines.
|
|
||||||
|
- **Antigen** (pre-bundle hook pattern):
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
omz_preload() { [[ -n "${OMZ_IS_BOOTSTRAPPED:-}" ]] || source "$ZSH/lib/bootstrap.zsh"; }
|
||||||
|
omz_preload
|
||||||
|
antigen bundle OMZ::plugins/git
|
||||||
|
antigen apply
|
||||||
|
```
|
||||||
|
|
||||||
|
- **Zinit** (`atinit` pre-load hook):
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
zinit ice atinit'[[ -n "${OMZ_IS_BOOTSTRAPPED:-}" ]] || source "$ZSH/lib/bootstrap.zsh"'
|
||||||
|
zinit snippet OMZ::plugins/git/git.plugin.zsh
|
||||||
|
```
|
||||||
|
|
||||||
|
- **zgen** (pre-load hook function called before OMZ loads):
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
omz_preload() { [[ -n "${OMZ_IS_BOOTSTRAPPED:-}" ]] || source "$ZSH/lib/bootstrap.zsh"; }
|
||||||
|
omz_preload
|
||||||
|
zgen load ohmyzsh/ohmyzsh plugins/git
|
||||||
|
```
|
||||||
|
|
||||||
|
- **zplug** (run pre-load hook immediately before OMZ entries):
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
omz_preload() { [[ -n "${OMZ_IS_BOOTSTRAPPED:-}" ]] || source "$ZSH/lib/bootstrap.zsh"; }
|
||||||
|
omz_preload
|
||||||
|
zplug "plugins/git", from:oh-my-zsh
|
||||||
|
zplug load
|
||||||
|
```
|
||||||
|
|
||||||
|
- **antibody** (run pre-load hook before `antibody bundle`/`source` output):
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
omz_preload() { [[ -n "${OMZ_IS_BOOTSTRAPPED:-}" ]] || source "$ZSH/lib/bootstrap.zsh"; }
|
||||||
|
omz_preload
|
||||||
|
source <(antibody bundle <<'EOF'
|
||||||
|
ohmyzsh/ohmyzsh path:plugins/git
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
- **zulu** (run pre-load hook before OMZ module loads):
|
||||||
|
|
||||||
|
```zsh
|
||||||
|
omz_preload() { [[ -n "${OMZ_IS_BOOTSTRAPPED:-}" ]] || source "$ZSH/lib/bootstrap.zsh"; }
|
||||||
|
omz_preload
|
||||||
|
zulu install oh-my-zsh
|
||||||
|
```
|
||||||
|
|
||||||
Compatibility matrix:
|
Compatibility matrix:
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,6 @@ fi
|
|||||||
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
0="${${ZERO:-${0:#$ZSH_ARGZERO}}:-${(%):-%N}}"
|
||||||
0="${${(M)0:#/*}:-$PWD/$0}"
|
0="${${(M)0:#/*}:-$PWD/$0}"
|
||||||
|
|
||||||
# Ensure cache completions dir exists when the plugin is loaded directly
|
|
||||||
# (e.g. antigen, where oh-my-zsh.sh might not run).
|
|
||||||
command mkdir -p "$ZSH_CACHE_DIR/completions"
|
|
||||||
|
|
||||||
# If the completion file doesn't exist yet, we need to autoload it and
|
# If the completion file doesn't exist yet, we need to autoload it and
|
||||||
# bind it to `docker`. Otherwise, compinit will have already done that.
|
# bind it to `docker`. Otherwise, compinit will have already done that.
|
||||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
|
if [[ ! -f "$ZSH_CACHE_DIR/completions/_docker" ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user