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

Re: Justifying text output



On Mar 12,  3:01am, Thorsten Kampe wrote:
}
} there any way to make the "[ ok ]"/"[ failed ]" messages on the right
} justified?

Change each "echo" from e.g. this:

  echo "${ltgreen}* ${white}compiling $file  [ ${ltgreen}ok ${white}]"

To this:

  echo ${(r:70:):-"${ltgreen}* ${white}compiling $file"}"[ ${ltgreen}ok ${white}]"

Note the placement of the quotes and closing curly-brace.

The (r:70:) parameter flag counts all characters -- it doesn't know that
${green} and ${white} expand to zero-width color changes -- so you have
to increase the padding to compensate.  You could do e.g.:

  ((PAD = COLUMNS - 12 + ${#ltgreen} + ${#white}))

and then

  echo ${(r:PAD:):-"${ltgreen}* ${white}compiling $file"} ...



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