astro

a POSIX shell compatible gemini client (mirror of https://github.com/blmayer/astro)
git clone https://git.clttr.info/astro.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 60c3b8af70581f4590868f82ca23715c5c90ca2a
parent de81abbf4325191c8115710cac3c19ae26124e2a
Author: blmayer <bleemayer@gmail.com>
Date:   Fri, 16 Jul 2021 21:32:04 -0300

Added colors to text formatting

Diffstat:
Mastro | 44++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/astro b/astro @@ -148,36 +148,40 @@ fetch() { while read -r line do line="$(echo "$line" | tr -d '\r')" - case "$line" in - "=>"*) - link="$(echo "$line" | sed -e 's/^=> *\(\S\+\)\(\s*.*\)/\1\t\2/g')" - echo "$i $link" >> "$cachedir/links.txt" - i=$((i + 1)) - - line="$(echo $link | cut -d' ' -f2-)" - [ -z "$line" ] && line="$(echo $link | cut -d' ' -f1)" - line="=> $line" - ;; - '```'*) - pre=$((1 - pre)) - line="" ;; - '* '*) line=" • ${line:2}";; - *) ;; - esac + echo "$line" | grep -q '```' && pre=$((1 - pre)) && line="" # Add margins and fold - if [ "$pre" ] + if [ "$pre" = 1 ] then printf "%*s%s\n" "$margin" "" "$line" else - echo "$line" | fmt -w $width | { + case "$line" in + "### "*) sty="\e[35;1m" && line="${line:4}" ;; + "## "*) sty="\e[35;4m" && line="${line:3}" ;; + "# "*) sty="\e[35;4;1m" && line="${line:2}" ;; + "> "*) sty=" \e[2;3m" && line="${line:2}" ;; + "=>"*) + link="$(echo "$line" | sed -e 's/^=> *\(\S\+\)\(\s*.*\)/\1\t\2/g')" + echo "$i $link" >> "$cachedir/links.txt" + i=$((i + 1)) + + line="$(echo $link | cut -d' ' -f2-)" + [ -z "$line" ] && line="$(echo $link | cut -d' ' -f1)" + sty="\e[36;3m" + line="\e[35m=>\e[36;3m $line" + ;; + '* '*) sty="" && line=" \e[35;1m•\e[0m ${line:2}";; + *) sty="";; + esac + echo "$line" | fold -w $width -s | { while IFS='' read -r txt do - printf "%*s%s\n" "$margin" "" "$txt" + printf "%*s" "$margin" "" + echo -e "$sty$txt" done } fi - done | LESSCHARSET="$charset" less -k "$LESSKEY" +k + done | LESSCHARSET="$charset" less -k "$LESSKEY" +k -R code="$?" # Choose what to do next