Created
September 26, 2018 08:30
-
-
Save cGuille/cc3be6604a99330fdf7d096e32e4293f to your computer and use it in GitHub Desktop.
I wrote this `hr` command because sometimes having a separator in your terminal helps you find things in the output of your previous commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
usage() { echo "Usage: hr [-h] [-c <CHAR (defaults to '=')>] [<LINES (defaults to 1)>]" 1>&2; exit 1; } | |
CHAR='=' | |
while getopts "h c:" ARG; do | |
case $ARG in | |
c) | |
CHAR="$OPTARG" | |
;; | |
h | *) # Display help. | |
usage | |
exit 0 | |
;; | |
esac | |
done | |
LINES=${@:$OPTIND:1} | |
# ARG2=${@:$OPTIND+1:1} | |
LINE_CONTENT="$(printf '%*s' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "$CHAR")" | |
for i in $(seq ${LINES:-1}); do | |
echo "$LINE_CONTENT" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment