LinuxCommandLibrary

boxes

Draw boxes around text in terminal

TLDR

Draw a box around a string

$ echo "[string]" | boxes
copy

Remove a box from a string
$ echo "[string]" | boxes [[-r|--remove]]
copy

Specify the box design
$ echo "[string]" | boxes [[-d|--design]] [parchment]
copy

Specify the box size (in columns by lines)
$ echo "[string]" | boxes [[-s|--size]] [10]x[5]
copy

Align the box text [h]orizonally (at [l]eft, [c]enter or [r]ight)
$ echo "[string]" | boxes [[-a|--align]] h[l|c|r]
copy

Align the box text [v]ertically (at [t]op, [c]enter or [b]ottom)
$ echo "[string]" | boxes [[-a|--align]] v[t|c|b]
copy

[j]ustify the box text (at [l]eft, [c]enter or [r]ight)
$ echo "[string]" | boxes [[-a|--align]] j[l|c|r][vt]
copy

SYNOPSIS

boxes [options] [file...]
boxes -s
boxes -d design [options]

PARAMETERS

-d <design>
    Selects a specific box design. Use -s to list available designs.

-a <align>
    Specifies text alignment within the box (e.g., l for left, c for center, r for right).

-p <pad>
    Sets internal padding for the box (e.g., 2 for 2 spaces, 2x1 for horizontal and vertical).

-s
    Prints a list of all available box designs to standard output.

-i
    Reads input from standard input (stdin). This is the default if no file is specified.

-o
    Writes output to standard output (stdout). This is the default behavior.

-r
    Reverses the operation, attempting to remove an existing box from the input text.

-h
    Displays a brief help message and exits.

-v
    Prints the program's version information and exits.

DESCRIPTION

The boxes command is a versatile command-line utility designed to surround text with various ASCII art boxes and patterns. It offers a rich collection of predefined box styles, ranging from simple line borders to intricate, decorative designs, making it ideal for enhancing the visual appeal of terminal outputs, scripts, or documentation. Users can pipe text directly into boxes or specify files as input, and the command will format the content within the chosen enclosure. Beyond basic framing, boxes provides extensive customization options for text alignment, padding, and dynamic box generation based on content length. Its flexibility allows for creative applications, such as framing important messages, adding comments to code snippets, or generating aesthetically pleasing headers and footers in command-line environments. It's a non-essential yet powerful tool for improving the readability and aesthetic presentation of plain text in Unix-like systems.

CAVEATS

The visual fidelity of boxes output can vary significantly across different terminal emulators and font configurations, as it relies heavily on consistent ASCII character rendering. While versatile, it is primarily intended for plain text decoration and may not handle complex structured data or binary content gracefully. Reversing a box with -r is not always perfect, especially with highly customized or unusual designs, and might lead to unintended formatting.

CUSTOM DESIGN FILES

Users can extend boxes' capabilities by creating custom design definition files. These files, typically named .boxes in the user's home directory or system-wide configuration paths, allow for the creation of unique box styles, including multi-line headers, footers, and complex framing logic using a simple, human-readable format. This feature provides immense flexibility beyond the built-in designs.

HISTORY

The boxes utility was developed by Thomas E. Dickey. It emerged as a specialized tool for ASCII text formatting, distinct from core Unix utilities, to fulfill the need for enhanced terminal output aesthetics. Its development has focused on providing a wide array of customizable box styles and flexible input/output handling, making it a popular choice for adding visual structure to command-line interfaces and text-based documents.

SEE ALSO

figlet(6), toilet(1), cat(1), fmt(1)

Copied to clipboard