Skip to content

Formatting

Jeff Felchner edited this page Sep 14, 2017 · 12 revisions

The format of the progress bar is extremely easy to customize. When you create the progress bar and pass the :format option, that string will be used to determine what the bar looks like.

Note: Most of this information is also exposed via to_h which is a bit more script-friendly if you need only a single piece or two of information.

The flags you can use in the format string are as follows:

  • %t: Title
  • %a: Elapsed (absolute) time
  • %e: Estimated time (will fall back to ETA: ??:??:?? when it exceeds 99:00:00)
  • %E: Estimated time (will fall back to ETA: > 4 Days when it exceeds 99:00:00)
  • %f: Force estimated time to be displayed even if it exceeds 99:00:00
  • %p: Percentage complete represented as a whole number (eg: 82)
  • %P: Percentage complete represented as a decimal number (eg: 82.33)
  • %j: Percentage complete right-justified to 3 places (eg: 82)
  • %J: Percentage complete right-justified to 6 places (eg: 82.33)
  • %c: Number of items currently completed
  • %C: Total number of items to be completed
  • %u: Total number of items to be completed (falls back to ?? if total is unknown)
  • %B: The full progress bar including 'incomplete' space (eg: ========== )
  • %b: Progress bar only (eg: ==========)
  • %w: Bar With Integrated Percentage (eg: ==== 75 ====)
  • %r: Rate of Progress as a whole number (eg: 13)
  • %R: Rate of Progress as a decimal number (eg: 13.67)
  • %i: Display the incomplete space of the bar (this string will only contain whitespace eg: )
  • %%: A literal percent sign %

All values have an absolute length with the exception of the bar flags (eg %B, %b, etc) which will occupy any leftover space. You can use as many bar flags as you'd like, but if you do weird things, weird things will happen; so be wary.

Clone this wiki locally