astro

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.clttr.info/astro.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit ec71a1b32edea0c32119de77a6180c2772ae702c
parent 493c500bd3293efffd37cf245760119e19ba33e4
Author: Brian Mayer <bleemayer@gmail.com>
Date:   Thu, 22 Jul 2021 20:49:53 -0300

Update astro
Diffstat:
Mastro | 30+++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/astro b/astro @@ -38,11 +38,20 @@ version() { # Parameters: url parseurl() { # Credits: https://stackoverflow.com/a/6174447/7618649 - proto="$(echo "$1" | grep // | sed -e's,^\(.*:\?//\).*,\1,g')" # extract the protocol - url="${1/$proto/}" # remove the protocol + [ "$debug" ] && echo "Parsing: $1" >&2 && sleep 2 + proto="$(echo "$1" | grep // | sed -e 's,^\(.*:\?//\).*,\1,g')" # extract the protocol + [ "$debug" ] && echo "Proto: $proto" >&2 && sleep 2 + + if [ "$proto" ] + then + url="$(echo "$url" | sed -e "s/$proto//g")" # remove the protocol + else + url=" $1" + fi + [ "$debug" ] && echo "url: $url" >&2 && sleep 2 proto="$(echo "$proto" | sed -e 's,:\?//,,g')" user="$(echo "$url" | grep @ | cut -d@ -f1)" # extract the user (if any) - hostport="$(echo "${url/$user@/}" | cut -d/ -f1)" # extract the host and port + hostport="$(echo "$url" | sed -e "s/$user@//g" | cut -d/ -f1)" # extract the host and port host="$(echo "$hostport" | sed -e 's,:.*,,g')" # by request host without port # by request - try to extract the port @@ -136,7 +145,7 @@ fetch() { [ -f "$cachedir/links.txt" ] && rm "$cachedir/links.txt" # Set charset - charset="$(echo "$meta" | grep -i "charset=" | sed 's/.*charset=\([^;]\+\).*/\1/Ig')" + charset="$(echo "$meta" | grep -i "charset=" | sed -e 's/.*charset=\([^;]\+\).*/\1/Ig')" case "$charset" in "iso-8859-1" | "ISO-8859-1") charset="iso8859" ;; "utf-8" | "UTF-8" | "") charset="utf8" ;; @@ -156,10 +165,10 @@ fetch() { printf "%*s%s\n" "$margin" "" "$line" else 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}" ;; + "### "*) sty="\e[35;1m" && line="$(echo "$line" | cut -c 5- )" ;; + "## "*) sty="\e[35;4m" && line="$(echo "$line" | cut -c 4-)" ;; + "# "*) sty="\e[35;4;1m" && line="$(echo "$line" | cut -c 3-)" ;; + "> "*) sty=" \e[2;3m" && line="$(echo "$line" | cut -c 3-)" ;; "=>"*) link="$(echo "$line" | sed -e 's/^=> *\(\S\+\)\(\s*.*\)/\1\t\2/g')" echo "$i $link" >> "$cachedir/links.txt" @@ -170,14 +179,14 @@ fetch() { sty="\e[36;3m" line="\e[35m=>\e[36;3m $line" ;; - '* '*) sty="" && line=" \e[35;1m•\e[0m ${line:2}";; + '* '*) sty="" && line="\e[35;1m •\e[0m$(echo "$line" | cut -c 2-)";; *) sty="";; esac echo "$line" | fold -w $width -s | { while IFS='' read -r txt do printf "%*s" "$margin" "" - echo -e "$sty$txt" + echo "$sty$txt" done } fi @@ -282,4 +291,3 @@ fi # First request fetch $(parseurl "${args:-$homepage}") -