hr
Draw horizontal rule in the terminal
TLDR
Print a horizontal rule
Print a horizontal rule with a custom string
Print a multiline horizontal rule
SYNOPSIS
hr [-c character] [-n length] [-s string]
PARAMETERS
-c character
Specifies the character to use for drawing the horizontal rule. Defaults to '-', '*' or '#'.
-n length
Specifies the length of the horizontal rule. Defaults to the terminal width or a predefined value.
-s string
Inserts the given string centered within the horizontal rule.
DESCRIPTION
The `hr` command, often found as a shell script or alias, is a simple utility for printing horizontal rules (lines) to the terminal. These rules are typically used to visually separate sections of output, making it easier to read and understand. It's not a standard core utility, meaning it's not part of the POSIX specification and therefore not guaranteed to be present on every Linux system. Implementations vary, but most `hr` commands allow for customization of the character used to draw the line, the length of the line, and whether to center text within the line. Because it's often implemented as a script or alias, its behavior and options can be readily tailored to suit individual preferences and scripting needs. The command's primary purpose is aesthetic; enhancing the readability and organization of terminal-based output, particularly in scripts and documentation.
CAVEATS
As `hr` is not a standard command, its availability and behavior can vary significantly between systems. It's often implemented as a shell script or alias, meaning its functionality is dependent on the user's environment and customizations.
IMPLEMENTATION DETAILS
Because `hr` is frequently a custom script, checking its source code (e.g., by using `alias hr` or `type hr` if it's an alias, or by examining the script file itself) can provide valuable insights into its exact behavior and configuration options on a given system.
Most common implementation uses `echo` or `printf` to print a given character to a defined number of times or `tput cols` to determine the width of the terminal.
EXAMPLES
Basic Usage: hr
(prints a default-length horizontal line using a default character).
Custom Character: hr -c '*'
(prints a horizontal line using asterisks).
Specific Length: hr -n 50
(prints a horizontal line that is 50 characters long).
Centered Text: hr -s "Section Title"
(prints a horizontal line with "Section Title" centered within it).
HISTORY
The `hr` command has no formal development history as it's typically a custom script or alias rather than a standalone program developed by a specific project. Its usage has evolved organically within the Unix/Linux community as a convenient way to improve the readability of terminal output, particularly in shell scripts and documentation. Different variations have been created and shared over time, leading to the current diversity of implementations.