Skip to content

Instantly share code, notes, and snippets.

@cGuille
Created September 26, 2018 08:30
Show Gist options
  • Save cGuille/cc3be6604a99330fdf7d096e32e4293f to your computer and use it in GitHub Desktop.
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
#!/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