Zuletzt aktiv 8 hours ago

capitalex's Avatar capitalex hat die Gist bearbeitet 8 hours ago. Zu Änderung gehen

1 file changed, 11 insertions, 4 deletions

andpile

@@ -1,5 +1,5 @@
1 1 #!/usr/bin/env bash
2 - # A sketch, I would probably use this for nothing, lol
2 +
3 3 if [[ ! -d "$HOME/.andpile" ]]; then
4 4 mkdir "$HOME/.andpile" ;
5 5 mkdir "$HOME/.andpile/data" ;
@@ -25,11 +25,18 @@ add_feed () {
25 25
26 26 feeds () {
27 27 readarray -t lines < "$HOME/.andpile/feeds.txt" ;
28 + echo "";
28 29 for index in "${!lines[@]}" ; do
29 30 line=${lines[$index]}
30 - read url id <<< $line ;
31 - read title < "$HOME/.andpile/data/$id.txt" ;
32 - printf "%s: %s\n" "$index" "$title" ;
31 + read feed_url id <<< $line ;
32 + readarray -t contents < "$HOME/.andpile/data/$id.txt" ;
33 + echo "$index: ${contents[0]} (${contents[1]})" ;
34 + i=2 ;
35 + while [ -n "${contents[$i]}" ]; do
36 + echo " ${contents[$i]}"
37 + ((i++))
38 + done
39 + echo "";
33 40 done
34 41 }
35 42

capitalex's Avatar capitalex hat die Gist bearbeitet 9 hours ago. Zu Änderung gehen

1 file changed, 50 insertions

andpile(Datei erstellt)

@@ -0,0 +1,50 @@
1 + #!/usr/bin/env bash
2 + # A sketch, I would probably use this for nothing, lol
3 + if [[ ! -d "$HOME/.andpile" ]]; then
4 + mkdir "$HOME/.andpile" ;
5 + mkdir "$HOME/.andpile/data" ;
6 + touch "$HOME/.andpile/feeds.txt" ;
7 + fi
8 +
9 + remove_feed() {
10 + sed -i.back "$(($1 + 1))d" "$HOME/.andpile/feeds.txt" ;
11 + }
12 +
13 + add_feed () {
14 + if grep -q "^$1" "$HOME/.andpile/feeds.txt" ; then
15 + echo "Already subscribed to feed" ;
16 + else
17 + id="$(uuidgen)" ;
18 + echo "Subscribing to feed..." ;
19 + echo "$1 $id" >> "$HOME/.andpile/feeds.txt" ;
20 + echo "Downloading listing..."
21 + curl "$1" >> "$HOME/.andpile/data/$id.txt" ;
22 + fi
23 + }
24 +
25 +
26 + feeds () {
27 + readarray -t lines < "$HOME/.andpile/feeds.txt" ;
28 + for index in "${!lines[@]}" ; do
29 + line=${lines[$index]}
30 + read url id <<< $line ;
31 + read title < "$HOME/.andpile/data/$id.txt" ;
32 + printf "%s: %s\n" "$index" "$title" ;
33 + done
34 + }
35 +
36 + list_feed () {
37 + readarray -t lines < "$HOME/.andpile/feeds.txt" ;
38 + read url id <<< ${lines[$1]} ;
39 + if [[ -f "$HOME/.andpile/data/$id.txt" ]]; then
40 + curl "$url" > "$HOME/.andpile/data/$id.txt" ;
41 + cat "$HOME/.andpile/data/$id.txt" | more ;
42 + fi
43 + }
44 +
45 + case "$1" in
46 + add-feed) add_feed "$2" ;;
47 + remove-feed) remove_feed "$2" ;;
48 + feeds) feeds ;;
49 + list) list_feed "$2" ;;
50 + esac
Neuer Älter