Decoration Functions
Typically used to output text to the console using pretty colors and ANSI art.
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 outputoffset- Integer. Optional. an integer offset to increase or decrease the size of the bar (default is0)
Examples
decorate success $(consoleLine =-)
decorate success $(consoleLine "- Success ")
decorate magenta $(consoleLine +-)
Return codes
0- Success1- Environment error2- Argument error
Usage
bigText text [ --bigger ]
Display large text in the console for banners and important messages
BUILD_TEXT_BINARY can be figlet or toilet
standard (figlet)
_ _ _ _
| | () __ | |____ | |
| ' | |/ || |/ _ \ \/ / __|
| |_) | | (_| || | __/> <| |_
|_.__/|_|\__, ||_|\___/_/\_\\__|
|___/
--bigger (figlet)
_ _ _______ _
| | (_) |__ __| | |
| |__ _ __ _| | _____ _| |_
| '_ \| |/ _ | |/ _ \ \/ / __|
| |) | | (| | | __/> <| |
|.__/||_, ||_//_\|
/ |
|/
smblock (regular) toilet
▌ ▗ ▀▛▘ ▐
▛▀▖▄ ▞▀▌▌▞▀▖▚▗▘▜▀
▌ ▌▐ ▚▄▌▌▛▀ ▗▚ ▐ ▖
▀▀ ▀▘▗▄▘▘▝▀▘▘ ▘ ▀
smmono12 (--bigger) toilet
▗▖ █ ▗▄▄▄▖
▐▌ ▀ ▝▀█▀▘ ▐▌
▐▙█▙ ██ ▟█▟▌ █ ▟█▙ ▝█ █▘▐███
▐▛ ▜▌ █ ▐▛ ▜▌ █ ▐▙▄▟▌ ▐█▌ ▐▌
▐▌ ▐▌ █ ▐▌ ▐▌ █ ▐▛▀▀▘ ▗█▖ ▐▌
▐█▄█▘▗▄█▄▖▝█▄█▌ █ ▝█▄▄▌ ▟▀▙ ▐▙▄
▝▘▀▘ ▝▀▀▀▘ ▞▀▐▌ ▀ ▝▀▀ ▝▀ ▀▘ ▀▀
▜█▛▘
Arguments
text- String. Required. Text to output--bigger- Flag. Optional. Text font size is bigger.
Return codes
0- Success1- Environment error2- Argument error
Environment
- BUILD_TEXT_BINARY - Callable. Binary used to generate
bigText
Usage
labeledBigText [ --top ] [ --bottom ] [ --prefix prefixText ] [ --tween tweenText ] [ --suffix suffixText ] label text
Outputs a label before a bigText 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 beforebigTexton 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 forbigText.
Examples
> bin/build/tools.sh labeledBigText --top "Neat: " Done
Neat: ▛▀▖
▌ ▌▞▀▖▛▀▖▞▀▖
▌ ▌▌ ▌▌ ▌▛▀
▀▀ ▝▀ ▘ ▘▝▀▘
> bin/build/tools.sh labeledBigText --bottom "Neat: " Done
▛▀▖
▌ ▌▞▀▖▛▀▖▞▀▖
▌ ▌▌ ▌▌ ▌▛▀
Neat: ▀▀ ▝▀ ▘ ▘▝▀▘
Return codes
0- Success1- Environment error2- Argument error
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- Success1- Environment error2- Argument error
Usage
consoleHeadingBoxed [ --outside outsideStyle ] [ --inside insideStyle ] [ --shrink characterCount ] [ --size lineCount ] [ text ... ] [ --help ]
Heading for section output
Arguments
--outside outsideStyle- String. Optional. Style to apply to the outside border. (Defaultdecoration)--inside insideStyle- String. Optional. Style to apply to the inside spacing. (Default blank)--shrink characterCount- UnsignedInteger. Optional. Reduce the box by this many characters wide. (Default 0)--size lineCount- UnsignedInteger. Optional. Print this many blank lines between the header and title. (Default 1)text ...- Text to put in the box--help- Flag. Optional. Display this help.
Examples
consoleHeadingBoxed Moving ...
Sample Output
+==========================================================================+ | | | Moving ... | | | +==========================================================================+
Return codes
0- Success1- Environment error2- Argument error
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 mapBUILD_HOME.--skip-app- Flag. Optional. Synonym for--no-app.path- String. Path to display and replace matching paths with icons.
Return codes
0- Success1- Environment error2- Argument error
Environment
- TMPDIR
-
BUILD_HOME - Directory.
BUILD_HOMEis.when this code is installed - at./bin/build. Usually an absolute path and does NOT end with a trailing slash. This is computed from the current source file using${BASH_SOURCE[0]}. -
HOME - Directory. Centralizing access to environment variables in code has the added benefit we can add debugging here if needed
decorateThemed
Applies the current theme to text rendered using
decorateThemelessMode
Usage
decorateThemed [ --help ]
Applies the current theme to text rendered using decorateThemelessMode
Reads standard input
Text to apply current theme to
Writes to standard output
Console-ready text
Arguments
--help- Flag. Optional. Display this help.
Return codes
0- Success1- Environment error2- 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- Success1- Environment error2- Argument error
Environment
- __BUILD_DECORATE
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- Success1- Environment error2- Argument error
Usage
textAlignRight [ characterWidth ] [ text ... ] [ --help ]
Format text and align it right using spaces.
Arguments
characterWidth- Characters to align righttext ...- 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- Success1- Environment error2- Argument error
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 lefttext ...- 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- Success1- Environment error2- Argument error