Adds a needlessly over-engineerd buisness card

master
Jonathan Hodgson 5 years ago
parent 44e710a464
commit da22d12c32
  1. 49
      content/card.curl

@ -0,0 +1,49 @@
#!/usr/bin/env bash
RED='\033[0;31m'
LRED='\033[1;31m'
YELLOW='\033[1;33m'
GREEN='\033[0;32m'
LGREEN='\033[1;32m'
LBLUE='\033[1;34m'
CYAN='\033[0;36m'
LCYAN='\033[1;36m'
ORANGE='\033[0;33m'
LGREY='\033[0;37m'
WHITE='\033[1;37m'
NC='\033[0m' # No Color
stripAnsi(){
sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g"
}
drawInBox(){
innerWidth="45"
echo -en "${LBLUE}╭"
head -c $innerWidth /dev/zero | tr '\0' '-'
echo -e "╮${NC}"
while IFS= read -r line; do
# The ansi characters mess up the string length so we need to strip them to calculate the width
stripped="$(echo -n "$line" | stripAnsi)"
leftPad=$(( ( innerWidth - ${#stripped} ) / 2))
rightPad=$(( ( innerWidth - leftPad ) - ${#stripped} ))
echo -en "${LBLUE}|${NC}"
head -c $leftPad /dev/zero | tr '\0' ' '
echo -n "$line"
head -c $rightPad /dev/zero | tr '\0' ' '
echo -e "${LBLUE}|${NC}"
done
echo -en "${LBLUE}╰"
head -c $innerWidth /dev/zero | tr '\0' '-'
echo -e "╯${NC}"
}
echo -e "
${RED}Jonathan Hodgson${NC}
${ORANGE}Email: ${GREEN}jonathan@jonathanh.co.uk${NC}
${ORANGE}Website: ${GREEN}https://jonathanh.co.uk${NC}
${ORANGE}GitRepos: ${GREEN}https://git.jonathanh.co.uk${NC}
" | drawInBox
Loading…
Cancel
Save