Skip to content

fix(zsh): init zoxide after Oh My Posh to keep its hook#31

Merged
fnayou merged 1 commit into
mainfrom
fix/zsh-zoxide-init-order
Jun 24, 2026
Merged

fix(zsh): init zoxide after Oh My Posh to keep its hook#31
fnayou merged 1 commit into
mainfrom
fix/zsh-zoxide-init-order

Conversation

@fnayou

@fnayou fnayou commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Problem

zoxide doctor warned on every new shell:

Please ensure that zoxide is initialized right at the end of your shell configuration file.

Root cause

index.zsh owns source order. zoxide was initialised in tools.zsh (step 8), before Oh My Posh in prompt.zsh (step 10). Oh My Posh rewrites the zsh hook array on init, displacing zoxide's precmd/chpwd hook — which is exactly what the doctor check detects.

Fix

Reorder index.zsh so tools.zsh (fzf, zoxide) sources after prompt.zsh. zoxide now registers its hook last and survives. Rationale documented inline at the new step 10.

  • No package added/removed/first-stowed → status blocks unchanged (status-sync rule satisfied).
  • zoxide init --cmd cd mode preserved.

Verification

Fresh interactive zsh after the change:

  • zoxide doctor warning: gone
  • chpwd_functions contains __zoxide_hook
  • precmd_functions contains _omp_precmd (Oh My Posh inits before zoxide)

Oh My Posh rewrites the zsh hook array on init. With zoxide sourced
before the prompt (tools.zsh at step 8, prompt.zsh at step 10), Oh My
Posh displaced zoxide's precmd/chpwd hook, tripping `zoxide doctor`
("initialize zoxide at the end").

Reorder index.zsh so tools.zsh (fzf, zoxide) sources after prompt.zsh,
keeping zoxide's hook intact. No package added/removed - status blocks
unchanged. Rationale documented inline at step 10.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@fnayou fnayou merged commit 6482a2f into main Jun 24, 2026
2 checks passed
@fnayou fnayou deleted the fix/zsh-zoxide-init-order branch June 24, 2026 01:48
fnayou added a commit that referenced this pull request Jun 24, 2026
PR #31 moved fzf init into tools.zsh (sourced last, after the prompt) so
zoxide could initialise at end. But fzf's `fzf --zsh` registers
completions via compdef and must run before completions.zsh, so sourcing
it last produced a silent completion error.

Split fzf into its own fzf.zsh, sourced after compinit (plugins.zsh) and
before completions.zsh (step 5b). zoxide stays in tools.zsh at the end
where Oh My Posh's hook rewrite no longer displaces it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant