Skip to content

Console Tools

⬅ Parent


Usage

isTTYAvailable [ --help ]

Returns 0 if a tty is available, 1 if not. Caches the saved value in __BUILD_HAS_TTY to avoid running the test each call.ZL

Arguments

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

Return codes

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

Environment

    • __BUILD_HAS_TTY - Cached value of false or true. Any other value forces computation during this call.

Usage

consoleGetColor [ --foreground ] [ --background ]

Gets the RGB console color using an xterm escape sequence supported by some terminals. (usually for background colors)

Arguments

  • --foreground - Flag. Optional. Get the console text color.
  • --background - Flag. Optional. Get the console background color.

Return codes

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

Usage

consoleConfigureColorMode [ backgroundColor ]

Print the suggested color mode for the current environment

Arguments

  • backgroundColor - String. Optional. Background color.

Return codes

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

Usage

consoleConfigureDecorate [ backgroundColor ] [ --help ]

Modify the decoration environment for light or dark. Run this at the top of your script for best results. Update the color scheme for a light or dark scheme

Arguments

  • backgroundColor - String. Optional. Background color.
  • --help - Flag. Optional. Display this help.

Return codes

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

Usage

consoleColumns [ --help ]

Output the number of columns in the terminal. Default is 80 if not able to be determined from TERM.

Writes to standard output

Integer

Arguments

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

Examples

textRepeat $(consoleColumns)

Return codes

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

Environment

    • COLUMNS - May be defined after calling this
    • LINES - May be defined after calling this

Usage

consoleRows [ --help ]

Output the number of columns in the terminal. Default is 60 if not able to be determined from TERM.

Arguments

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

Examples

tail -n $(consoleRows) "$file"

Return codes

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

Environment

    • COLUMNS - May be defined after calling this
    • LINES - May be defined after calling this

Usage

consoleBrightness [ --foreground ] [ --background ]

Fetch the brightness of the console using consoleGetColor

Arguments

  • --foreground - Flag. Optional. Get the console text color.
  • --background - Flag. Optional. Get the console background color.

Sample Output

Integer. between 0 and 100.

Return codes

  • 0 - Success
  • 1 - A problem occurred with consoleGetColor

Usage

consoleSetTitle

Set the title of the window for the console

Arguments

  • none

Return codes

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

Usage

consoleDefaultTitle [ None ]

Set the title of the window for the console to "user@hostname: pwd"

Arguments

  • None

Return codes

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

Usage

consoleLink link [ text ] [ --help ]

Output a hyperlink to the console OSC 8 standard for terminals No way to test ability, I think. Maybe tput.

Arguments

  • link - EmptyString. Required. Link to output.
  • text - String. Optional. Text to display, if none then uses link.
  • --help - Flag. Optional. Display this help.

Return codes

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

Usage

consoleFileLink [ --no-app ] fileName [ text ]

Output a local file link to the console

Arguments

  • --no-app - Flag. Optional. Do not map the application path in decoratePath
  • fileName - String. Required. File path to output.
  • text - String. Optional. Text to output linked to file.

Return codes

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

Usage

consoleLinksSupported

Are console links (likely) supported? Unfortunately there's no way to test for this feature currently

Arguments

  • none

Return codes

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