commit 0353966ad10d6f7f9427e3d5a6c5a0ad717f135c parent de3513eca97749c8678a7f533a3b66dfcf082b6d Author: Jan Pobrislo <ccx@webprojekty.cz> Date: Thu, 19 Jun 2014 18:50:45 +0200 use colors function instead of prompt expansion Diffstat:
| M | bin/confz | | | 17 | +++++++---------- |
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/bin/confz b/bin/confz @@ -1,6 +1,8 @@ #!/bin/zsh # vim: ft=zsh noet ts=4 sts=4 sw=4 +autoload -Uz colors; colors + setopt extended_glob warn_create_global typeset -gA vars vars_prev @@ -11,33 +13,28 @@ check_only=0 # helper that prints out error message and exits die() { - print -r - ${(p)confz_err_mark} "$@" >&2 + print -r - "$fg[red]*$fg[default] $@" >&2 exit 1 } -confz_err_mark="%F{red}*%f" # trace-printing helpers -confz_exe_mark="%F{yellow}*%f" - confz_check_start() { - print -Pn "${confz_indent}checking %B$1%b " - print -rn - ${(@q)argv[2,-1]} - print -P " [" + print -r - "${confz_indent}checking $fg_bold$1$fg_no_bold ${(@q)argv[2,-1]} $fg[black][$reset_color" confz_indent+=" " } confz_check_ok() { confz_indent=${confz_indent% } - print -P "$confz_indent] %F{green}$1%f OK" + print -r - "$confz_indent] $fg[green]$1$reset_color OK" } confz_check_fail() { confz_indent=${confz_indent% } - print -P "$indent] %F{yellow}$1%f FAIL" + print -P "$confz_indent] $fg[yellow]$1$reset_color FAIL" } confz_do() { - print -r - $confz_indent${(p)confz_exe_mark} "${(q)@}" + print -r - "$confz_indent$fg[yellow]*$fg[default] ${(q)@}" "$@" || die "command failed with error $?: ${(q)@}" }