From df81942de868abdc7f680d7ea21954628469b519 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 7 Oct 2024 11:18:57 +0100 Subject: wip: bash script to add url to taskwarrior --- get_web_title.bash | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 get_web_title.bash diff --git a/get_web_title.bash b/get_web_title.bash new file mode 100755 index 0000000..6bdb089 --- /dev/null +++ b/get_web_title.bash @@ -0,0 +1,20 @@ +#!/usr/local/bin/bash + +url=$1 +echo "Searching URL: $1" + +webpage_title (){ + curl -s "$url" |grep ""|sed -e 's/title//g' | sed -e 's/<>//g' | sed -e 's/<\/>//g'| sed -e 's/^[[:space:]]*//g' +} + +url_title="$(webpage_title)" + +# ref: https://stackoverflow.com/questions/18544359/how-do-i-read-user-input-into-a-variable-in-bash +if [[ -z $url_title ]]; then + read -p "There is no title tag. Do you want to add one? (y/n)" confirm && \ + [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 + read -p "Enter a nice title: " title + descr="\"Read and review: $title\"" + id=$(task add pro:h.reading "$descr" | sed -n 's/Created task \(.*\)./\1/p') + task "$id" annotate "$url" +fi -- cgit v1.2.3