Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Direnv hook with summary on exported env variables
direnv_hook() {
local previous_exit_status=$?;
# eval "$(direnv export bash)";
eval "$(direnv export bash 2> >( \
awk '
$0 !~ /^direnv: export/
$0 ~ /^direnv: export/ {
plus = gsub("\\+", "");
minus = gsub("-", "");
change = gsub("~", "");
msg = "direnv: export";
if (0 < plus)
msg = msg " " plus "(+)"
if (0 < minus)
msg = msg " " minus "(-)"
if (0 < change)
msg = msg " " change "(~)"
if (0 < plus || 0 < minus || 0 < change)
print msg
}
' 1>&2 \
))";
return $previous_exit_status;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment