Skip to content

Commit 6dc990a

Browse files
timvwclaude
andcommitted
fix: check if compdef exists before registering zsh completion
Fix error "command not found: compdef" when sourcing wt shellenv in zsh before compinit has been called. The zsh completion system (compdef) is only available after compinit has been initialized. Wrap the compdef call in a check to see if the function exists before trying to use it. This allows users to safely add 'source <(wt shellenv)' anywhere in their ~/.zshrc without worrying about the order of initialization. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7c024f3 commit 6dc990a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,10 @@ if [ -n "$ZSH_VERSION" ]; then
477477
esac
478478
fi
479479
}
480-
compdef _wt_complete_zsh wt
480+
# Only set up completion if compdef is available (after compinit)
481+
if (( $+functions[compdef] )); then
482+
compdef _wt_complete_zsh wt
483+
fi
481484
fi
482485
`)
483486
},

0 commit comments

Comments
 (0)