diff --git a/configure-stormux.sh b/configure-stormux.sh index f1a7db4..20d9606 100755 --- a/configure-stormux.sh +++ b/configure-stormux.sh @@ -28,6 +28,29 @@ if [[ "$(whoami)" == "root" ]]; then exit 0 fi +# Set up logging +logFile="/tmp/configure-stormux.log" +filter_ansi() { + sed -r -e 's/\x1B\[[0-9;]*[A-Za-z]//g' \ + -e 's/\x1B[()#][0-9A-Za-z]//g' \ + -e 's/\x1B[><=]//g' \ + -e 's/\x0F//g' \ + -e 's/\x1B\[?[0-9;]*[A-Za-z]//g' \ + -e 's/\x1B\][0-9]*;[^\x07]*\x07//g' \ + -e 's/\x1B\][0-9]*;[^\x1B]*\x1B\\//g' \ + -e 's/\x08//g' \ + -e 's/\r//g' \ + -e 's/\x1B\[\?1049[hl]//g' \ + -e 's/\x1B\[\?1[hl]//g' \ + -e 's/\x1B\[\?1000[hl]//g' \ + -e '/^[[:space:]]*$/d' \ + -e ':a;N;$!ba;s/\n{2,}/\n/g' +} + + +exec > >(stdbuf -oL tee >(filter_ansi >> "$logFile")) 2> >(stdbuf -oL tee >(filter_ansi >> "$logFile") >&2) + + # For audible sudo prompts: unset sudoFlags if [[ -x /etc/audibleprompt.sh ]]; then