feat: use dynamic ascii text

This commit is contained in:
Chen Asraf
2023-01-30 23:46:29 +02:00
parent 3503d9bc8b
commit b01df81bc2
8 changed files with 1255 additions and 18 deletions

View File

@@ -22,6 +22,8 @@ brew "blueutil"
brew "openldap"
# Get a file from an HTTP, HTTPS or FTP server
brew "curl"
# Banner-like program prints strings as ASCII art
brew "figlet"
# Fast Lexical Analyzer, generates Scanners (tokenizers)
brew "flex"
# Libraries to talk to Microsoft SQL Server and Sybase databases

View File

@@ -59,6 +59,7 @@ alias hl="home pull"
alias spider="ssh root@spider.casraf.dev"
alias sf="search-file"
alias fnu="find-up"
alias ascii-text=". $DOTFILES/scripts/ascii_font/ascii_font.sh"
if is_linux; then
alias md5="md5sum"

View File

@@ -139,7 +139,7 @@ rand() {
}
# need to source because VS Code raises error on the function
source $DOTFILES/scripts/randrag.sh
source $DOTFILES/scripts/randarg.sh
# select random element from list
randline() {

View File

@@ -0,0 +1,81 @@
# ascii-font() {
dir="$DOTFILES/scripts/ascii_font"
font="$dir/fonts/Big-Money-ne"
size=1
color=""
bg=""
bold=""
reset="$(tput sgr0)"
while [ $# -gt 0 ]; do
case "$1" in
-f | --font)
font="$2"
shift 2
;;
-s | --size)
size="$2"
shift 2
;;
-c | --color)
if [[ $2 == "rainbow" ]]; then
color="rainbow"
else
color="$(tput setaf $2)"
fi
shift 2
;;
-b | --bg)
bg="$(tput setab $2)"
shift 2
;;
-B | --bold)
bold="$(tput bold)"
shift
;;
# -l | --list)
# # figlet -l
# return 0
# ;;
-v | --version)
echo "ascii-font 1.0.0"
echo "Written by Chen Asraf <casraf@pm.me>"
return 0
;;
-h | --help)
echo "Usage: ascii-font [OPTION]... [TEXT]..."
echo "Convert text to ASCII art."
echo
echo " -h, --help display this help and exit"
echo " -f, --font specify font (default: standard)"
echo " -s, --size specify font size (default: 1)"
echo " -c, --color specify font color (default: 0)"
echo " -b, --bg specify background color (default: 0)"
echo " -B, --bold set font bold"
echo " -C, --no-center Disable centering the text"
# echo " -l, --list list available fonts"
echo " -v, --version display version information and exit"
echo
echo "See color options at:"
echo " $(tput smul)https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit"
echo
echo "Report bugs to Chen Asraf <casraf@pm.me>"
return 0
;;
*)
break
;;
esac
done
if [[ ! -f $(which figlet) ]]; then
brew install figlet
fi
if [[ $color != "rainbow" ]]; then
echo "$bold$color$bg$(figlet -f $font -w $(tput cols) -c "$@")$reset"
else
echo "$bold$bg$(figlet -f $font -w $(tput cols) -c "$@")$reset" | lolcat
fi
# }

File diff suppressed because it is too large Load Diff

View File

@@ -57,14 +57,14 @@ home() {
sub="$1"
case $sub in
restore)
r | restore)
echo_cyan "Restoring Dropzone backup..."
src="$dz_bak"
target="$dz"
mkdir -p $target
cp -r $src/* $target
;;
dump)
d | dump)
echo_cyan "Creating Dropzone backup..."
target="$dz_bak"
src="$dz"
@@ -93,12 +93,12 @@ home() {
shift
sub="$1"
case $sub in
dump)
d | dump)
__home_prepare_dir
brew bundle dump -f --describe
__home_revert_dir
;;
restore)
r | restore)
__home_prepare_dir
brew bundle
__home_revert_dir

0
scripts/randarg.sh Normal file → Executable file
View File

View File

@@ -1,16 +1,22 @@
#!/usr/bin/env zsh
logo='
/$$$$$$
/$$__ $$
/$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ | $$ \__/
/$$_____/ |____ $$ /$$_____/ /$$__ $$|____ $$| $$$$
| $$ /$$$$$$$| $$$$$$ | $$ \__/ /$$$$$$$| $$_/
| $$ /$$__ $$ \____ $$| $$ /$$__ $$| $$
| $$$$$$$| $$$$$$$ /$$$$$$$/| $$ | $$$$$$$| $$
\_______/ \_______/|_______/ |__/ \_______/|__/
'
source $DOTFILES/aliases.sh
echo "$(tput bold)$(echo $logo)$(tput sgr0)" | lolcat -f
echo
echo
# logo='
# /$$$$$$
# /$$__ $$
# /$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ | $$ \__/
# /$$_____/ |____ $$ /$$_____/ /$$__ $$|____ $$| $$$$
# | $$ /$$$$$$$| $$$$$$ | $$ \__/ /$$$$$$$| $$_/
# | $$ /$$__ $$ \____ $$| $$ /$$__ $$| $$
# | $$$$$$$| $$$$$$$ /$$$$$$$/| $$ | $$$$$$$| $$
# \_______/ \_______/|_______/ |__/ \_______/|__/
# '
# echo "$(tput bold)$(echo $logo)$(tput sgr0)" | lolcat -f
# echo
# echo
text=$([[ hostname == 'spider.casraf.dev' ]] && echo '@spider' || echo 'casraf')
ascii-text -B -c rainbow $text