Decoration Functions
Typically used to output text to the console using pretty colors and ANSI art.
repeat
Repeat a string
Usage
repeat count string [ ... ]
Repeat a string
Arguments
count- Required, integer count of times to repeatstring- A sequence of characters to repeat...- Additional arguments are output using shell expansion of$*
Examples
repeat 80 =
echo Hello world
repeat 80 -
Return codes
0- Success1- Environment error2- Argument error
echoBar
Output a bar as wide as the console
Usage
echoBar [ alternateChar ] [ offset ]
Output a bar as wide as the console using the = symbol.
Arguments
alternateChar- Optional. String. Use an alternate character or string outputoffset- Optional. Integer. an integer offset to increase or decrease the size of the bar (default is0)
Examples
decorate success $(echoBar =-)
decorate success $(echoBar "- Success ")
decorate magenta $(echoBar +-)
Return codes
0- Success1- Environment error2- Argument error
alignRight
align text right
Usage
alignRight characterWidth text [ ... ]
Format text and align it right using spaces.
Arguments
--help- Optional. Flag. Display this help.characterWidth- Characters to align righttext ...- Text to align right
Examples
printf "%s: %s\n" "$(alignRight 20 Name)" "$name"
printf "%s: %s\n" "$(alignRight 20 Profession)" "$occupation"
Name: Juanita
Profession: Engineer
Return codes
0- Success1- Environment error2- Argument error
alignLeft
align text left
Usage
alignLeft [ --help ] [ characterWidth ] [ text ... ]
Format text and align it left using spaces.
Arguments
--help- Optional. Flag. Display this help.characterWidth- Characters to align lefttext ...- Text to align left
Examples
printf "%s: %s\n" "$(alignLeft 14 Name)" "$name"
printf "%s: %s\n" "$(alignLeft 14 Profession)" "$occupation"
Name : Tyrone
Profession : Engineer
Return codes
0- Success1- Environment error2- Argument error
boxedHeading
Text heading decoration
Usage
boxedHeading [ --size size ] [ --outside outsideStyle ] [ --inside insideStyle ] [ --shrink characterCount ] [ --size lineCount ] [ text ... ] [ --help ]
Heading for section output
Arguments
--size size- Optional. Integer. Number of liens to output. Defaults to 1.--outside outsideStyle- Optional. String. Style to apply to the outside border.--inside insideStyle- Optional. String. Style to apply to the inside spacing.--shrink characterCount- Optional. UnsignedInteger. Reduce the box by this many characters wide.--size lineCount- Optional. UnsignedInteger. Print this many blank lines between the header and title.text ...- Text to put in the box--help- Optional. Flag. Display this help.
Examples
boxedHeading Moving ...
Sample Output
+==========================================================================+ | | | Moving ... | | | +==========================================================================+
Return codes
0- Success1- Environment error2- Argument error
bigText
Display large text in the console for banners and important
Usage
bigText [ --bigger ] Text to output
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
- none
Return codes
0- Success1- Environment error2- Argument error
Environment
- BUILD_TEXT_BINARY - Callable. Binary used to generate
bigText
labeledBigText
Outputs a label before a bigText for output.
Usage
labeledBigText [ --top | --bottom ] [ --prefix prefix ] 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- Optional. Flag. Place label at the top.--bottom- Optional. Flag. Place label at the bottom.--prefix prefixText- Optional. String. Optional prefix on each line.--tween tweenText- Optional. String. Optional between text after label and beforebigTexton each line (allows coloring or other decorations).--suffix suffixText- Optional. String. Optional suffix on each line.label- Required. String. Label to place on the left of big text.text- Required. String. 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
lineFill
Output a line and fill columns with a character
Usage
lineFill 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
decoratePath
Display file paths and replace prefixes with icons
Usage
decoratePath [ --help ] [ --skip-app | --no-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- Optional. Flag. Display this help. --skip-app |---no-app- Optional. Flag. Do not mapBUILD_HOME.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