From fd746a7dc9d24974bd54798e58046e75b10e9610 Mon Sep 17 00:00:00 2001 From: Morgan Wattiez Date: Sun, 13 Oct 2019 12:00:14 +0200 Subject: [PATCH] detect titles in page and prepare them for bookmarks --- dot_zsh_functions | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dot_zsh_functions b/dot_zsh_functions index 06a41d5..b86605a 100644 --- a/dot_zsh_functions +++ b/dot_zsh_functions @@ -84,16 +84,24 @@ function aboutpage() { year=$(curl -sSL "$*" | tr '<' '\r' | \egrep -i "date|datetime" -A 1 | \grep -Eo '\b[[:digit:]]{4}\b' | head -n1) fi author=$(curl -sSL "$*" | tr '<' '\r' | \egrep -i "author" -A 1 | \grep -Eo '([A-Z][A-Za-z]+\s([A-Za-z ]+)*)' | head -n1) + title=$(curl -sSL "$*" | tr '<' '<\n' | \grep title -A 1 | head -n1 | sed -E 's/.*(.*)<\/title>.*/\1/' | sed "s/ [^[:alnum:]]*$author//") yearint=$(($year + 0)) currentyear=$(echo `date +"%Y"`) if [ ! -z "$author" ] then echo "by $author" fi + if [ ! -z "$title" ] + then + echo "-> $title" + fi if [[ $yearint -ge 1970 && $yearint -le $currentyear ]] then echo "$yearint" fi + if [ ! -z "$title" ] && [ ! -z "$author" ] && [[ $yearint -ge 1970 && $yearint -le $currentyear ]]; then + echo "[$author]($*) - ($yearint) $title" + fi } # Extract a column from a tabular output