Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: The elements of enlightenment




On 2022-12-05 13:49, Bart Schaefer wrote:
So
     typeset -a list
     printf -v list "%s ${red}%s${nrm}" ${(kv)options}
should do what you want.

This seems to nail it:


   local k v
    local list=()
    local line=
    local -A color=(off ${red} on '')
    for k v in ${(kv)options}; do
        printf -v line '%-20s %s%s\e[0m' $k ${color[$v]} $v
        list+=$line
    done

... save a few miliseconds!   Very educational thanks gentlemen.







Messages sorted by: Reverse Date, Date, Thread, Author