Skip to content

Instantly share code, notes, and snippets.

@tmatilai
Created May 3, 2021 06:49
Show Gist options
  • Save tmatilai/27fe47385ce6817cea48454f5c9615ac to your computer and use it in GitHub Desktop.
Save tmatilai/27fe47385ce6817cea48454f5c9615ac to your computer and use it in GitHub Desktop.
Make direnv error messages red
#!/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