Created
February 19, 2021 02:22
-
-
Save pinealan/fbc0da8562140b39a5604aa2cead73ba to your computer and use it in GitHub Desktop.
Direnv hook with summary on exported env variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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