Skip to content

Commit

Permalink
feat(color): more reliable respect for NO_COLOR
Browse files Browse the repository at this point in the history
  • Loading branch information
olets committed Aug 2, 2021
1 parent 30b594f commit 4706cf4
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions zsh-abbr.zsh
Expand Up @@ -64,7 +64,7 @@ _abbr() {
# (( ${+DEPRECATED_VAL} )) && _abbr_warn_deprecation DEPRECATED_VAL VAL
# VAL=$DEPRECATED_VAL

if ! (( ${+NO_COLOR} )); then
if ! _abbr_no_color; then
error_color="$fg[red]"
success_color="$fg[green]"
warn_color="$fg[yellow]"
Expand Down Expand Up @@ -992,6 +992,17 @@ _abbr_bind_widgets() {
bindkey "^M" _abbr_widget_expand_and_accept
}

_abbr_no_color() {
local -a shell_vars
local -i found

shell_vars=( ${(k)parameters} )

found=$(( ! $shell_vars[(Ie)NO_COLOR] ))

return $found
}

_abbr_cmd_expansion() {
emulate -LR zsh

Expand Down Expand Up @@ -1058,12 +1069,15 @@ _abbr_init() {

job_name=$(_abbr_job_name)

if ! _abbr_no_color; then
'builtin' 'autoload' -U colors && colors
fi

_abbr_job_push $job_name initialization
_abbr_debugger

'builtin' 'autoload' -Uz add-zsh-hook
add-zsh-hook precmd _abbr_precmd
! (( ${+NO_COLOR} )) && 'builtin' 'autoload' -U colors && colors

_abbr_load_user_abbreviations
_abbr_add_widgets
Expand Down

0 comments on commit 4706cf4

Please sign in to comment.