From da9ec47882b091c0d95f2ef57b83f2f3889aa8ab Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Fri, 27 Sep 2013 17:00:51 +0200 Subject: [Internal] Uses Zsh’s power to construct fixed-length strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 01_Internal.zsh | 19 ++++++------------- 12_Prompts.zsh | 2 +- 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 -- cgit v1.2.3