summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues.hiegel@qosmos.com>2013-09-27 17:00:51 +0200
committerHugues Hiegel <hugues.hiegel@qosmos.com>2013-09-27 17:07:45 +0200
commitda9ec47882b091c0d95f2ef57b83f2f3889aa8ab (patch)
tree8b5b9ee9773d17d0256c200d50b59e2542fc931e
parente65d78f271e3d15bebb32384e996224b1c01d64b (diff)
[Internal] Uses Zsh’s power to construct fixed-length strings
-rw-r--r--01_Internal.zsh19
-rw-r--r--12_Prompts.zsh2
2 files changed, 7 insertions, 14 deletions
diff --git a/01_Internal.zsh b/01_Internal.zsh
index 96ca330..8624ede 100644
--- a/01_Internal.zsh
+++ b/01_Internal.zsh
@@ -92,18 +92,16 @@ __preprint()
my_color=${2-"$_prompt_colors[generic]"}
- hbar=$T_
- for i in {1..$((74 - ${#1} - 5))}
- do
- hbar=${hbar}$_tq_
- done
- hbar=${hbar}$_T
+ local _width=74
+ local _space=5
+
+ hbar=$T_${(l:$(( $_width - ${#1} - $_space ))::q:)}$_T
if [ "$1" != "" ]
then
print -P$newline "${C_}$my_color;1${_C}${hbar}$T_$_tj_$_T${C_}0;$my_color${_C} $1 ${C_}0;$my_color;1${_C}$T_$_tm_$_tq_$_T\r${C_}0${_C}"
else
- print -P$newline "${C_}$my_color;1${_C}${hbar}$T_$_tq_$_tq_$_tq_$_tq_$_tq_$_T${C_}0${_C}"
+ print -P$newline "${C_}$my_color;1${_C}${hbar}$T_${(l:${_space}::q:)}$_T${C_}0${_C}"
fi
}
@@ -560,12 +558,7 @@ __hbar()
__debug -n " Horizontal bar..."
_COLUMNS_OLD=$COLUMNS
HBAR_COLOR=$C_$_prompt_colors[bar]$_C$T_
- HBAR=$T_
- for h in {1..$COLUMNS}
- do
- HBAR=${HBAR}$_tq_
- done
- HBAR=$HBAR$_T
+ HBAR=$T_${(l:${COLUMNS}::q:)}$_T
__debug
fi
}
diff --git a/12_Prompts.zsh b/12_Prompts.zsh
index ebf6e39..0800ad2 100644
--- a/12_Prompts.zsh
+++ b/12_Prompts.zsh
@@ -317,7 +317,7 @@ then
echo -n $c_$_prompt_colors[warning]$_c
#toilet -f bigmono9 "D1rTY Zsh.."
- HBAR=$(for i in {1..13} ; echo -n - "$_tq_")
+ HBAR=${(l:13::q:)}
VBAR=$T_$_tx_$_T
echo