Last active
July 14, 2023 11:36
-
-
Save epatel/01188eac6eef265a0d409f24240cec26 to your computer and use it in GitHub Desktop.
Output box around text bash
This file contains 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
#!/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