Skip to content

Decoration Functions

Typically used to output text to the console using pretty colors and ANSI art.

⬅ Parent


consoleLine

Output a bar as wide as the console

Usage

consoleLine [ alternateChar ] [ offset ]

Output a bar as wide as the console using the = symbol.

Arguments

  • alternateChar - String. Optional. Use an alternate character or string output
  • offset - Integer. Optional. an integer offset to increase or decrease the size of the bar (default is 0)

Examples

decorate success $(consoleLine =-)
decorate success $(consoleLine "- Success ")
decorate magenta $(consoleLine +-)

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

labeledBigText

Outputs a label before a decorate big for output.

Usage

labeledBigText [ --top ] [ --bottom ] [ --prefix prefixText ] [ --tween tweenText ] [ --suffix suffixText ] label text

Outputs a label before a decorate big for output. This function will strip any ANSI from the label to calculate correct string sizes.

Arguments

  • --top - Flag. Optional. Place label at the top.
  • --bottom - Flag. Optional. Place label at the bottom.
  • --prefix prefixText - String. Optional. Optional prefix on each line.
  • --tween tweenText - String. Optional. Optional between text after label and before decorate big on each line (allows coloring or other decorations).
  • --suffix suffixText - String. Optional. Optional suffix on each line.
  • label - String. Required. Label to place on the left of big text.
  • text - String. Required. Text for decorate big.

Examples

> bin/build/tools.sh labeledBigText --top "Neat: " Done
Neat: ▛▀▖
      ▌ ▌▞▀▖▛▀▖▞▀▖
      ▌ ▌▌ ▌▌ ▌▛▀
      ▀▀ ▝▀ ▘ ▘▝▀▘
> bin/build/tools.sh labeledBigText --bottom "Neat: " Done
      ▛▀▖
      ▌ ▌▞▀▖▛▀▖▞▀▖
      ▌ ▌▌ ▌▌ ▌▛▀
Neat: ▀▀ ▝▀ ▘ ▘▝▀▘

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

consoleHeadingLine

Output a line and fill columns with a character

Usage

consoleHeadingLine barText [ displayText ]

Output a line and fill columns with a character

Arguments

  • barText - String. Required. Text to fill line with, repeated. If not specified uses -
  • displayText - String. Optional. Text to display on the line before the fill bar.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

decoratePath

Display file paths and replace prefixes with icons

Usage

decoratePath [ --help ] [ --path pathName=icon ] [ --no-app ] [ --skip-app ] [ path ]

Replace an absolute path prefix with an icon if it matches HOME, BUILD_HOME or TMPDIR Icons used: - 💣 - TMPDIR - 🍎 - BUILD_HOME - 🏠 - HOME

Arguments

  • --help - Flag. Optional. Display this help. --path pathName=- icon - Flag. Optional. Add an additional path mapping to icon.
  • --no-app - Flag. Optional. Do not map BUILD_HOME.
  • --skip-app - Flag. Optional. Synonym for --no-app.
  • path - String. Path to display and replace matching paths with icons.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Environment

  • TMPDIR
  • {SEE:BUILD_HOME.sh}
  • {SEE:HOME.sh}

decorateThemed

Applies the current theme to text rendered using decorateThemelessMode

Usage

decorateThemed [ --help ]

Applies the current theme to text rendered using decorateThemelessMode

Arguments

  • --help - Flag. Optional. Display this help.

Reads standard input

Text to apply current theme to

Writes to standard output

Console-ready text

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

decorateThemelessMode

Converts decoration style to a mode where the theme can

Usage

decorateThemelessMode [ --end ] [ --help ]

Converts decoration style to a mode where the theme can be applied later to text which is formatted. All decorate calls made after this call will output with special codes not to be displayed to the user.

Arguments

  • --end - Flag. Optional. End themeless mode.
  • --help - Flag. Optional. Display this help.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Environment

  • __BUILD_DECORATE

textRepeat

Repeat a string

Usage

textRepeat `count` `text` .. [ --help ]

Repeat a string

Arguments

  • count - UnsignedInteger. Required. Count of times to repeat.
  • `text ..` - String. Required. A sequence of characters to repeat.
  • --help - Flag. Optional. Display this help.

Examples

textRepeat 80 =
decorate info Hello world
textRepeat 80 -

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

textAlignRight

align text right

Usage

textAlignRight [ characterWidth ] [ text ... ] [ --help ]

Format text and align it right using spaces.

Arguments

  • characterWidth - Characters to align right
  • text ... - Text to align right
  • --help - Flag. Optional. Display this help.

Examples

printf "%s: %s\n" "$(textAlignRight 20 Name)" "$name"
printf "%s: %s\n" "$(textAlignRight 20 Profession)" "$occupation"
            Name: Juanita
      Profession: Engineer

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

textAlignLeft

align text left

Usage

textAlignLeft [ --help ] characterWidth [ text ... ]

Format text and align it left using spaces.

Arguments

  • --help - Flag. Optional. Display this help.
  • characterWidth - UnsignedInteger. Required. Number of characters to align left
  • text ... - Text to align left.

Examples

printf "%s: %s\n" "$(textAlignLeft 14 Name)" "$name"
printf "%s: %s\n" "$(textAlignLeft 14 Profession)" "$occupation"
Name          : Tyrone
Profession    : Engineer

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

🛠️ Tools · ⬅ Top