I wanted my MacOS terminal to have a different color for outputs from the color on the command line. Like this, but not only for ls but for essentially every single output.
So I put this in my .zshrc:
preexec() {
tput setaf 15
:
}
preexec_invoke_exec() {
[ -n "$COMP_LINE" ] && return
local this_command=`HISTTIMEFORMATE= history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//"`;
preexec "$this_command"
}
trap 'preexec_invoke_exec' DEBUG
And it's worked beautifully (other than the annoying command line lag) for over a year, until just recently whenever I start Terminal I get this error:
preexec_invoke_exec:fc:3: no such event: 1
preexec_invoke_exec:fc:3: no such event: 1
preexec_invoke_exec:fc:3: no such event: 1
preexec_invoke_exec:fc:3: no such event: 1
preexec_invoke_exec:fc:3: no such event: 1
preexec_invoke_exec:fc:3: no such event: 1
(eval):1: bad pattern: ^[[97m#
Not really sure what's wrong. According to some other posts, it may have something to do with $HISTORY not having a length, but nothing has been able to fix it so far and I there's not many similar posts. Anyone know what's going on here? Or maybe someone knows a more intuitive way to change the output color? Thanks in advance!