Skip to content

Instantly share code, notes, and snippets.

@meleu
Created July 23, 2021 18:32
Show Gist options
  • Save meleu/4e53cc403eb7be6f549a6e8037860c53 to your computer and use it in GitHub Desktop.
Save meleu/4e53cc403eb7be6f549a6e8037860c53 to your computer and use it in GitHub Desktop.
shell script "banner"
#!/usr/bin/env bash
# banner():
# Imprime uma mensagem no seguinte formato:
# ============
# olá mundo!
# ============
banner() {
local string="$@"
local length="${#string}"
local barLength=75 # largura máxima da barra = 75
local frame
[[ "$barLength" -gt "$length" ]] && barLength="$length"
# macete do printf abaixo: https://stackoverflow.com/a/5349842/6354514
frame="$(printf '=%.0s' $(seq 1 ${barLength}))"
echo "${frame}"
echo -e "${string}"
echo "${frame}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment