added rainbow

master
parent 3d007ab8c5
commit ebc7e8adfe

@ -0,0 +1,34 @@
#!/bin/bash
# ASCII blocks: █▓▒░
block="░"
[ -z "$1" ] && c="$block" || c="$1"
[ -z "$2" ] && prompt="pi@blueberrypielol" || prompt="$2"
[[ "$@" == *"--raw"* ]] && praw=1
colors=18
chars=${#prompt}
let short=$chars/$colors # min length
let full="chars%colors"
let part="$colors-($chars%$colors)" # short color count
let nmax="$chars%$colors" # Long color count
[ $nmax -eq 0 ] && max=$short || let max=$short+1 # max length
pos=0
p=0
[[ "$c" == "b" ]] && c="$block"
for i in 196 202 214 220 226 190 154 118 85 87 39 33 27 63 99 135 171 207; do
if [[ "$c" == "n" ]]; then
pretty="${pretty}\e[38;5;${i}m${i}\e[0m "
elif [[ "$c" == "p" ]]; then
[ ${pos} -lt ${full} ] && len=$max || len=$short
#${parameter:offset:length}
pretty="${pretty}\e[38;5;${i}m${prompt:${p}:${len}}\e[0m"
let p=p+len
let pos=pos+1
else
pretty="${pretty}\e[38;5;${i}m${c}\e[0m"
fi
done
echo
[ -z "$pretty" ] || echo -e $pretty
[ -z "$praw" ] || echo
[ -z "$praw" ] || echo $pretty
echo
Loading…
Cancel
Save