Style

Apply slow blink ANSI formatting to text. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (string): Optional: file path or string to format

Exit codes

  • 0: Always

Output on stdout

  • Blink-formatted text

text_bold

Apply bold ANSI formatting to text. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (string): Optional: file path or string to format

Exit codes

  • 0: Always

Output on stdout

  • Bold-formatted text

str_c2n

Convert a comma-separated list to newline-separated format. See also str_n2c() and str_n2s() for the inverse.

Arguments

  • $1 (string): Optional: file path (default: stdin)

Exit codes

  • 0: Always

Output on stdout

  • One item per line

text_center

Center each line of input within the terminal width. Lines longer than the terminal width are folded and each segment centered. Accepts input via stdin or a file path.

Arguments

  • $1 (string): Optional: file path (default: stdin)

Exit codes

  • 0: Always

Output on stdout

  • Each line centered within the terminal width

text_faint

Apply faint/dim ANSI formatting to text. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (string): Optional: file path or string to format

Exit codes

  • 0: Always

Output on stdout

  • Faint-formatted text

text_invert

Swap foreground and background colors using ANSI invert formatting. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (string): Optional: file path or string to format

Exit codes

  • 0: Always

Output on stdout

  • Inverted-color text

text_italic

Apply italic ANSI formatting to text. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (string): Optional: file path or string to format

Exit codes

  • 0: Always

Output on stdout

  • Italic-formatted text

str_n2c

Convert newline-separated input to a single comma-separated line. See also str_c2n() for the inverse.

Arguments

  • $1 (string): Optional: file path (default: stdin)

Exit codes

  • 0: Always

Output on stdout

  • Comma-separated values on a single line

str_n2s

Convert newline-separated input to a single space-separated line.

Arguments

  • $1 (string): Optional: file path (default: stdin)

Exit codes

  • 0: Always

Output on stdout

  • Space-separated values on a single line

text_printline

Print a specific line number from a file or stdin.

Arguments

  • $1 (int): Line number to print (required)
  • $2 (string): Optional: file path (default: stdin)

Exit codes

  • 0: Success
  • 1: Invalid line number or unreadable file

Output on stdout

  • The specified line

text_strike

Apply strikethrough ANSI formatting to text. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (string): Optional: file path or string to format

Exit codes

  • 0: Always

Output on stdout

  • Strikethrough-formatted text

text_underline

Apply underline ANSI formatting to text. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (string): Optional: file path or string to format

Exit codes

  • 0: Always

Output on stdout

  • Underlined text

text_wordwrap

Wrap input to n words per line using xargs. Reads from stdin or a file.

Arguments

  • $1 (int): Optional: number of words per line (default: 1)
  • $2 (string): Optional: file path (default: stdin)

Exit codes

  • 0: Always

Output on stdout

  • Input rewrapped to the specified word count per line

text_fg

Apply a foreground (text) color to input using ANSI 256-color codes. Named colors, numeric codes, and random ('rand') are supported. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (string): Color name or code: b, r, g, y, bl, m, c, w, o, rand, or a number 0-255
  • ... (string): Optional: text to color (default: stdin)

Exit codes

  • 0: Always

Output on stdout

  • Color-formatted text

text_bg

Apply a background color to input using ANSI 256-color codes. Named colors, numeric codes, and random ('rand') are supported. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (string): Color name or code: b, r, g, y, bl, m, c, w, o, rand, or a number 0-255
  • ... (string): Optional: text to color (default: stdin)

Exit codes

  • 0: Always

Output on stdout

  • Background-color-formatted text

text_rgb.fg

Apply a truecolor foreground color using RGB values (0-255 each). Random values are used for any omitted or non-numeric component. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (int): Red component (0-255, or omit for random)
  • $2 (int): Green component (0-255, or omit for random)
  • $3 (int): Blue component (0-255, or omit for random)
  • ... (string): Optional: text to color (default: stdin)

Exit codes

  • 0: Always

Output on stdout

  • Truecolor foreground-formatted text

text_rgb.bg

Apply a truecolor background color using RGB values (0-255 each). Random values are used for any omitted or non-numeric component. Accepts input as an argument or via stdin/file.

Arguments

  • $1 (int): Red component (0-255, or omit for random)
  • $2 (int): Green component (0-255, or omit for random)
  • $3 (int): Blue component (0-255, or omit for random)
  • ... (string): Optional: text to color (default: stdin)

Exit codes

  • 0: Always

Output on stdout

  • Truecolor background-formatted text

str_tolower

Convert text to lowercase. Accepts a string argument, file path, or stdin. Tries Bash 4 parameter expansion, then awk, then tr as fallbacks.

Arguments

  • $1 (string): Optional: string to lowercase (default: stdin/file)

Exit codes

  • 0: Success
  • 1: No available conversion method found

Output on stdout

  • Lowercased text

str_toupper

Convert text to uppercase. Accepts a string argument, file path, or stdin. Tries Bash 4 parameter expansion, then awk, then tr as fallbacks.

Arguments

  • $1 (string): Optional: string to uppercase (default: stdin/file)

Exit codes

  • 0: Success
  • 1: No available conversion method found

Output on stdout

  • Uppercased text

str_strip_ansi

Remove ANSI/VT100 color and formatting escape codes from a string. Useful for measuring true display length or logging colored output to plain text.

Example

str_strip_ansi $'\033[32mhello\033[0m'   # => "hello"
printf '%s' "${colored_var}" | str_strip_ansi

Arguments

  • $1 (string): String to strip (reads from stdin if omitted)

Exit codes

  • 0: Always

Output on stdout

  • String with all ANSI escape sequences removed