galeb-conv (1102B)
1 #!/bin/sh 2 # vim: set ft=bash: 3 4 usage() 5 { 6 cat <<! 7 Usage: ${0##*/} [-c] [-h] [-u] 8 -c Cleanup colors (no ANSI) 9 -u Use unicode(1) for prettier output 10 ! 11 } 12 13 cleanup=0 14 use_uni=0 15 while getopts chu opt; do 16 case ${opt} in 17 c) cleanup=1;; 18 h) usage; exit 0;; 19 u) use_uni=1;; 20 ?) ;; 21 esac 22 done 23 24 unicode=$(command -v unicode 2>/dev/null) 25 unicode=${unicode:-/usr/local/plan9/bin/unicode} 26 27 sed -e 's,#,'$(if [ ${cleanup} -eq 0 ]; then echo '\x1b[0;1;32m'; fi)' ,g' \ 28 -e 's,!,'$(if [ ${cleanup} -eq 0 ]; then echo '\x1b[0;0;32m'; fi)' ,g' \ 29 -e 's,@,'$(if [ ${cleanup} -eq 0 ]; then echo '\x1b[0;1;36m'; fi)' ,g' \ 30 -e 's,%,'$(if [ ${cleanup} -eq 0 ]; then echo '\x1b[0;1;37m'; fi)' ,g' \ 31 -e 's,\$,'$(if [ ${cleanup} -eq 0 ]; then echo '\x1b[0;37m'; fi)' ,g' \ 32 -e 's,~,'$(if [ ${cleanup} -eq 0 ]; then echo '\x1b[0m'; fi)' ,g' \ 33 -e 's,D,'$(if [ ${use_uni} -eq 1 ]; then ${unicode} 2588 34 else echo D; fi)',g' \ 35 -e 's,\^,'$(if [ ${use_uni} -eq 1 ]; then ${unicode} 2580 36 else echo ^; fi)',g' \ 37 -e 's,c,'$(if [ ${use_uni} -eq 1 ]; then ${unicode} 2584 38 else echo c; fi)',g'