Skip to content

Instantly share code, notes, and snippets.

@epatel
Last active July 14, 2023 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epatel/01188eac6eef265a0d409f24240cec26 to your computer and use it in GitHub Desktop.
Save epatel/01188eac6eef265a0d409f24240cec26 to your computer and use it in GitHub Desktop.
Output box around text bash
#!/bin/bash
function box() {
LEN=`expr "$1" : '.*'`
LINE=`printf "%${LEN}s" | tr " " "━"`
printf "┏━%s━┓\n" "$LINE"
printf "┃ %s ┃\n" "$1"
printf "┗━%s━┛\n" "$LINE"
}
function cbox() {
LEN=`expr "$1" : '.*'`
WIDTH=`tput cols`
PLEN=$((($WIDTH-$LEN-4)/2))
PAD=`printf "%${PLEN}s" | tr " " " "`
LINE=`printf "%${LEN}s" | tr " " "━"`
printf "%s┏━%s━┓\n" "$PAD" "$LINE"
printf "%s┃ %s ┃\n" "$PAD" "$1"
printf "%s┗━%s━┛\n" "$PAD" "$LINE"
}
box "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment