Created
May 3, 2021 06:49
-
-
Save tmatilai/27fe47385ce6817cea48454f5c9615ac to your computer and use it in GitHub Desktop.
Make direnv error messages red
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
#!/usr/bin/env bash | |
# | |
# Color all stderr output from .envrc evaluation. | |
# Copy this file to ~/.config/direnv/lib/red_stderr.sh | |
# Override the direnv stdlib function to print with "normal" color | |
log_status() { | |
if [[ -n $DIRENV_LOG_FORMAT ]]; then | |
local msg=$* | |
local color_normal | |
color_normal=$(tput sgr0) | |
# shellcheck disable=SC2059,SC1117 | |
printf "${color_normal}${DIRENV_LOG_FORMAT}\n" "$msg" >&2 | |
fi | |
} | |
# Print everything in stderr in red | |
exec 2> >( sed $'s,.*,\e[31m&\e[m,' >&2 ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment