aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <lemon@x201.local>2024-10-07 11:18:57 +0100
committerMatthew Lemon <lemon@x201.local>2024-10-07 11:18:57 +0100
commitdf81942de868abdc7f680d7ea21954628469b519 (patch)
tree6cab89d8277a8e701363ad7619697eb7c1771d6f
parent65d58a056cdc348f2beb85a350c66c182cb10643 (diff)
wip: bash script to add url to taskwarrior
-rwxr-xr-xget_web_title.bash20
1 files changed, 20 insertions, 0 deletions
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 "<title>"|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