Giter VIP home page Giter VIP logo

hr's Introduction

Portable horizontal ruler for terminal

License: GPL-3.0 Development completed

πŸ’‘ About

hr (SuperB HR) is a CLI tool written in portable sh to render horizontal ruler/line in the terminal.

πŸ“” Story

Recently, i'm obsessed with hr and i want a portable shell hr, the best i found is "POSIX-ish Way" from the blog Alternatives to the hr library:

printf '%*s' "$(tput cols)" | tr ' ' "${*:-#}"

but it lacks Gil Gonçalves's hr key features like output multiple line, custom text or even treats multi-byte symbols properly. So i decided to create hr based on the blog's method with only 6 lines of portable 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"
  • Can output multiple lines at once
  • Can define custom text
  • Treats multi-byte symbols properly
  • hr's default text can be change through environment variable

Note hr can not be source or invoke from Bash, for that use Gil Gonçalves's hr

πŸš€ Setup

🧾 Dependencies

πŸ“₯ Installation

πŸ”§ Manually

  • Option 1: using curl
curl https://raw.githubusercontent.com/NNBnh/hr/main/bin/hr > ~/.local/bin/hr
chmod +x ~/.local/bin/hr
  • Option 2: using git
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 user:

bpkg install NNBnh/hr

For Basher user:

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 hr in the terminal:

hr [TEXTS]

Examples:

hr

this will output:

────────────────────────────────────────

You can make multiple hr at the same time and with any TEXT:

hr '#' 'hr' 'Hello world! '

this will output:

########################################
hrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhrhr
Hello world! Hello world! Hello world! H

βš™οΈ Configuration

hr is configured through environment variables:

export HR_DEFAULT_TEXT="<text>"

πŸ’Œ Credits

Special thanks to:






Made with ❀️ by NNB

Buy Me a Coffee

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.