From 60f637b609ec38a768e94d91678500f1fd16798c Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Sun, 19 Nov 2023 16:23:26 +1100 Subject: [PATCH 1/2] Load Direnv state before rendering instant prompt, as recommended --- dot-config/zsh/zshrc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dot-config/zsh/zshrc b/dot-config/zsh/zshrc index c374637..70ce6e4 100644 --- a/dot-config/zsh/zshrc +++ b/dot-config/zsh/zshrc @@ -1,3 +1,7 @@ +# For accurate instant prompt from Powerlevel10k, we need to load up the +# correct environment from direnv first. +(( ${+commands[direnv]} )) && emulate zsh -c "$(direnv export zsh)" + # Enable Powerlevel10k instant prompt. Should stay close to the top of zshrc. # Initialization code that may require console input (password prompts, [y/n] # confirmations, etc.) must go above this block; everything else may go below. From 1bc2b49e3f64b4d36b939e3795ed18875f604b4c Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Sun, 19 Nov 2023 16:24:19 +1100 Subject: [PATCH 2/2] Update Direnv hook to match current recommendation --- dot-config/zsh/interactive/direnv | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dot-config/zsh/interactive/direnv b/dot-config/zsh/interactive/direnv index 49e16f6..ba862dc 100644 --- a/dot-config/zsh/interactive/direnv +++ b/dot-config/zsh/interactive/direnv @@ -1,8 +1,12 @@ #! zsh _direnv_hook() { - eval "$(direnv export zsh)" + trap -- '' SIGINT + emulate zsh -c "$(direnv export zsh)" + trap - SIGINT } -typeset -ag precmd_functions -if (( $+commands[direnv] )) && [[ -z ${precmd_functions[(r)_direnv_hook]} ]]; then - precmd_functions+=(_direnv_hook) + +typeset -ag precmd_functions chpwd_functions +if (( $+commands[direnv] )); then + [[ -z ${precmd_functions[(r)_direnv_hook]} ]] && precmd_functions+=(_direnv_hook) + [[ -z ${chpwd_functions[(r)_direnv_hook]} ]] && chpwd_functions+=(_direnv_hook) fi