-
Notifications
You must be signed in to change notification settings - Fork 0
/
dim-wishlist
executable file
·65 lines (48 loc) · 1.14 KB
/
dim-wishlist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# vim:sts=2:sw=2:et:
#
# dim-wishlist
#
# Creates a unified DIM wishlist file.
#
set -e
if readlink `which dim-wishlist` &>/dev/null; then
cd $(dirname $(readlink `which dim-wishlist`))
fi
if [ ! -d "generated" ]; then
mkdir generated
fi
filename="dim-wishlist-$(date +"%s")"
parentdir="$(dirname "$(pwd)")"
wishlist="$(pwd)/generated/${filename}"
declare -A sources
while read line; do
if echo $line | grep -F = &>/dev/null; then
key=$(echo "$line" | cut -d '=' -f 1)
value=$(echo "$line" | cut -d '=' -f 2-)
sources[$key]=$value
fi
done < sources.conf
cat <<EOF > $wishlist
title:$(whoami)'s wishlist
description: Generated with https://github.com/geetarista/dim-wishlist-generator
EOF
for key in "${!sources[@]}"; do
printf "processing $key"
repo="${sources[$key]}"
source_path="${parentdir}/$key"
if [ ! -d "$source_path" ]; then
git clone $repo $source_path &>/dev/null
fi
pushd $source_path &>/dev/null
git pull &>/dev/null
for f in *.txt; do
printf "."
cat $f >> $wishlist
printf "\n" >> $wishlist
done
printf "\n"
popd &>/dev/null
done
echo "done!"
open ./generated/