pinwheel: Load direnv ZSH on devshell load
This commit is contained in:
@@ -22,6 +22,24 @@ in
|
|||||||
[[ "$PATH" == "${pkgs.bashInteractive}/bin:"* ]] || export PATH="${pkgs.bashInteractive}/bin:$PATH"
|
[[ "$PATH" == "${pkgs.bashInteractive}/bin:"* ]] || export PATH="${pkgs.bashInteractive}/bin:$PATH"
|
||||||
}
|
}
|
||||||
precmd_functions+=(_ensure_bash_interactive)
|
precmd_functions+=(_ensure_bash_interactive)
|
||||||
|
|
||||||
|
# Source the zsh-specific rc file that nix-direnv emits ($DIRENV_ZSH_RC)
|
||||||
|
# so devshell completions and zsh setup are picked up. direnv itself only
|
||||||
|
# exports env vars, so without this hook the zsh side of the devshell is
|
||||||
|
# never loaded. Guarded by LAST_LOADED_DIRENV_ZSH_RC so we don't re-source
|
||||||
|
# it on every precmd.
|
||||||
|
_nix_direnv_bridge_hook() {
|
||||||
|
if [[ -n "$DIRENV_ZSH_RC" && "$LAST_LOADED_DIRENV_ZSH_RC" != "$DIRENV_ZSH_RC" ]]; then
|
||||||
|
if [[ -f "$DIRENV_ZSH_RC" ]]; then
|
||||||
|
source "$DIRENV_ZSH_RC"
|
||||||
|
export LAST_LOADED_DIRENV_ZSH_RC="$DIRENV_ZSH_RC"
|
||||||
|
echo "❄️ direnv zsh loaded..."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
autoload -Uz add-zsh-hook
|
||||||
|
add-zsh-hook precmd _nix_direnv_bridge_hook
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Configure IntelliJ to exclude .direnv from indexing
|
# Configure IntelliJ to exclude .direnv from indexing
|
||||||
|
|||||||
Reference in New Issue
Block a user