feat(direnv-p10k): Add a new plugin for direnv which specifically disables the precmd_functions hook for powerlevel10k theme users to avoid the instant prompt warning when starting a shell in a directory where a .envrc is both located and direnv allowed

Signed-off-by: Thomas D. Spear <thomas.spear@wcgclinical.com>
This commit is contained in:
Thomas D. Spear 2025-01-27 13:42:19 -06:00
commit ce485f155c
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,15 @@
# If direnv is not found, don't continue and print a warning
if (( ! $+commands[direnv] )); then
echo "Warning: direnv not found. Please install direnv and ensure it's in your PATH before using this plugin."
return
fi
_direnv_hook() {
trap -- '' SIGINT;
eval "$(direnv export zsh)";
trap - SIGINT;
}
typeset -ag chpwd_functions;
if [[ -z "${chpwd_functions[(r)_direnv_hook]+1}" ]]; then
chpwd_functions=( _direnv_hook ${chpwd_functions[@]} )
fi