https://github.com/nnbnh/hr
π Portable horizontal ruler for terminal
https://github.com/nnbnh/hr
basher bpkg cli hr posix terminal
Last synced: 6 months ago
JSON representation
π Portable horizontal ruler for terminal
- Host: GitHub
- URL: https://github.com/nnbnh/hr
- Owner: NNBnh
- License: gpl-3.0
- Created: 2021-02-27T12:17:14.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-02T04:17:48.000Z (over 3 years ago)
- Last Synced: 2025-03-26T04:34:22.097Z (7 months ago)
- Topics: basher, bpkg, cli, hr, posix, terminal
- Language: Shell
- Homepage:
- Size: 63.5 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Portable horizontal ruler for terminal
## π‘ About
 (SuperB HR) is a CLI tool written in [`portable sh`](https://github.com/dylanaraps/pure-sh-bible) to render horizontal ruler/line in the terminal.
### π Story
Recently, i'm obsessed with [`hr`](https://github.com/LuRsT/hr) and i want a portable shell `hr`, the best i found is *"`POSIX`-ish Way"* from the blog [Alternatives to the `hr` library](https://grayson.sh/blogs/some-alternatives-to-hr):
```sh
printf '%*s' "$(tput cols)" | tr ' ' "${*:-#}"
```but it lacks [Gil GonΓ§alves's `hr`](https://github.com/LuRsT/hr) key features like output multiple line, custom text or even treats multi-byte symbols properly. So i decided to create  based on the blog's method with only **6 lines** of [`portable sh`](https://github.com/dylanaraps/pure-sh-bible):
```sh
#!/bin/sh
COLUMNS="${COLUMNS:-$(tput cols)}"
for text in "${@:-${HR_DEFAULT_TEXT:-β}}"; do
printf '\033[?7l%*s\033[?7h' "$COLUMNS" | sed -e "s/ /$text/g"
done
exit 0
```### β¨ Features
- Extremely **minimum** *"only **6 lines** of [`portable sh`](https://github.com/dylanaraps/pure-sh-bible)"*
- Can output **multiple lines** at once
- Can define **custom text**
- Treats **multi-byte symbols** properly
- 's default text can be change through [environment variable](#%EF%B8%8F-configuration)> **Note** * can not be `source` or invoke from [Bash](https://www.gnu.org/software/bash), for that use [Gil GonΓ§alves's `hr`](https://github.com/LuRsT/hr)*
## π Setup
### π§Ύ Dependencies
- [Unix commands](https://en.wikipedia.org/wiki/List_of_Unix_commands) to process
### π₯ Installation
#### π§ Manually
- Option 1: using `curl`
```sh
curl https://raw.githubusercontent.com/NNBnh/hr/main/bin/hr > ~/.local/bin/hr
chmod +x ~/.local/bin/hr
```- Option 2: using `git`
```sh
git clone https://github.com/NNBnh/hr.git ~/.local/share/hr
ln -s ~/.local/share/hr/bin/hr ~/.local/bin/hr
```#### π¦ Package manager
For [Bpkg](https://github.com/bpkg/bpkg) user:
```sh
bpkg install NNBnh/hr
```For [Basher](https://github.com/basherpm/basher) user:
```sh
basher install NNBnh/hr
```> **Note** *If you can and want to port SuperB HR to other package managers, feel free to do so.*
## β¨οΈ Usage
Run  in the terminal:
```sh
hr [TEXTS]
```Examples:
```sh
hr
```this will output:
```console
ββββββββββββββββββββββββββββββββββββββββ
```You can make multiple  at the same time and with any `TEXT`:
```sh
hr '#' 'hr' 'Hello world! '
```this will output:
```console
########################################
hrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhr
Hello world! Hello world! Hello world! H
```## βοΈ Configuration
 is configured through environment variables:
```sh
export HR_DEFAULT_TEXT=""
```## π Credits
Special thanks to:
- [**hr**](https://github.com/LuRsT/hr) by [Gil GonΓ§alves](https://github.com/LuRsT)
- [**Alternatives to the 'hr' library**](https://grayson.sh/blogs/some-alternatives-to-hr) by [Grayson Kent](https://grayson.sh)
---
>
Made with β€οΈ by NNB
>
>