-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.sh
executable file
·52 lines (46 loc) · 2.23 KB
/
demo.sh
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
#!/bin/bash
# Define an array of commands to execute
commands=(
'curl -s https://nos.nl/weer | grep -q regen && echo "JA het regent!" || echo "NEE het regent niet!"'
'curl -s https://nos.nl/weer | grep regen'
"curl -s https://nos.nl/weer | html2text -utf8 | awk '/Weerbericht/,/Weerfoto/'"
"wget --directory-prefix /tmp/ --spider --recursive --level 1 https://linuxnijmegen.nl/"
"wget --mirror --convert-links --adjust-extension --no-parent --directory-prefix=./data https://linuxnijmegen.nl/"
"rg 'Presentatie door: ' ./data/linuxnijmegen.nl/onderwerpen/ | html2text -utf8 | grep 'Presentatie door: ' | cut -d : -f2 | sort | uniq -c | sort -h -r"
'cat ./data/linuxnijmegen.nl/onderwerpen/*.html | hxnormalize -x | hxselect -s "\n" -c "div.uk-panel:nth-child(2)"'
'cd lugn && pipenv run scrapy crawl speakers --loglevel INFO --output ../data/speakers.json && cd -'
'cat ./lugn/lugn/spiders/speakers.py'
"< ./data/speakers.json| jq -r '.[].presenters[]' | sort | uniq -c | sort -h -r"
"yarn run run"
)
index=0
# Loop through the commands
while [ $index -lt ${#commands[@]} ]; do
# Display the command
echo -e "\e[1mCommand:\e[0m ${commands[$index]}"
# Ask for user input
read -p "Run it? [Y]es, [N]o, [P]revious, [I]nformation: " choice
# Check the choice
if [ "$choice" == "Y" ] || [ "$choice" == "y" ]; then
# Execute the command
eval "${commands[$index]}"
((index++)) # Move to the next command
elif [ "$choice" == "N" ] || [ "$choice" == "n" ]; then
echo "Skipping command: ${commands[$index]}"
((index++)) # Move to the next command
elif [ "$choice" == "P" ] || [ "$choice" == "p" ]; then
if [ $index -gt 0 ]; then
((index--)) # Go back to the previous command
else
echo "Already at the beginning."
fi
elif [ "$choice" == "I" ] || [ "$choice" == "i" ]; then
# Open explainshell in Firefox with the encoded command
encoded_cmd=$(echo -n "${commands[$index]}" | jq -s -R -r @uri)
firefox "https://explainshell.com/explain?cmd=$encoded_cmd"
else
echo "Invalid choice, please enter Y, N, or P."
fi
# Add a new line and a visual separator
echo -e "\n----------------------------------------\n"
done