[zsh] get rid of tput dependency in zplg.zsh

This commit is contained in:
Dmytro Meleshko 2019-07-20 09:59:29 +03:00
parent b8e2081839
commit 1f39fc8cff

View file

@ -43,19 +43,13 @@ _ZPLG_PLUGINS_DIR="$ZPLG_HOME/plugins"
# basic logging {{{ # basic logging {{{
_ZPLG_ANSI_BOLD="$(tput bold)"
_ZPLG_ANSI_RED="$(tput setaf 1)"
_ZPLG_ANSI_GREEN="$(tput setaf 2)"
_ZPLG_ANSI_BLUE="$(tput setaf 4)"
_ZPLG_ANSI_RESET="$(tput sgr0)"
_zplg_log() { _zplg_log() {
print >&2 "${_ZPLG_ANSI_BLUE}${_ZPLG_ANSI_BOLD}[zplg]${_ZPLG_ANSI_RESET} $@" print >&2 "${fg_bold[blue]}[zplg]${reset_color} $@"
} }
_zplg_debug() { _zplg_debug() {
if [[ -n "$ZPLG_DEBUG" ]]; then if [[ -n "$ZPLG_DEBUG" ]]; then
_zplg_log "${_ZPLG_ANSI_GREEN}debug:${_ZPLG_ANSI_RESET} $@" _zplg_log "${fg[green]}debug:${reset_color} $@"
fi fi
} }
@ -69,14 +63,14 @@ _ZPLG_PLUGINS_DIR="$ZPLG_HOME/plugins"
# relative to the beginning of a function/file here. I use it here # relative to the beginning of a function/file here. I use it here
# only for consistency with the shell, TODO might change this in the # only for consistency with the shell, TODO might change this in the
# future. # future.
_zplg_log "${_ZPLG_ANSI_RED}error:${_ZPLG_ANSI_RESET} ${functrace[$i]}: $@" _zplg_log "${fg[red]}error:${reset_color} ${functrace[$i]}: $@"
return 1 return 1
fi fi
done done
# if for whatever reason we couldn't find the caller, simply print the # if for whatever reason we couldn't find the caller, simply print the
# error without it # error without it
_zplg_log "${_ZPLG_ANSI_RED}error:${_ZPLG_ANSI_RESET} $@" _zplg_log "${fg[red]}error:${reset_color} $@"
return 1 return 1
} }