Created
May 31, 2020 00:27
-
-
Save MunifTanjim/01a72f6286740e5e59a55b633fa994fe to your computer and use it in GitHub Desktop.
Shell Helpers
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
function str_repeat() { | |
local -r str="$1" | |
local -r n="$2" | |
echo "$(printf '%*s' "${n}" | tr ' ' "${str}")" | |
} | |
function str_box() { | |
local -r str="$1" | |
local -r str_len=$(( 4 + ${#str} )) | |
local -r char="${2:-"*"}" | |
str_repeat $char $str_len | |
echo "$char $str $char" | |
str_repeat $char $str_len | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment