2022-12-11 19:00:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-12-14 19:30:05 +00:00
|
|
|
# This script returns a random topic for me to revise
|
|
|
|
|
2023-01-21 12:18:17 +00:00
|
|
|
# It is aliased to cs-revise in .zshrc
|
|
|
|
|
2022-12-14 19:30:05 +00:00
|
|
|
# Choose source directories...
|
2023-01-01 13:00:05 +00:00
|
|
|
DIRS_TO_PARSE="../Computer_Architecture ../Databases ../Electronics_and_Hardware ../Operating_Systems ../Programming_Languages/Shell ../Logic"
|
2022-12-12 19:00:06 +00:00
|
|
|
|
2022-12-14 19:30:05 +00:00
|
|
|
# Return array of all files belonging to source dirs...
|
2022-12-12 19:00:06 +00:00
|
|
|
for ele in $DIRS_TO_PARSE; do
|
2022-12-14 19:00:05 +00:00
|
|
|
FILE_MATCHES+=( $(find $ele -name "*.md" -type f) )
|
2022-12-12 19:00:06 +00:00
|
|
|
done
|
|
|
|
|
2022-12-14 19:30:05 +00:00
|
|
|
# Generate a random integer between 0 and the match array length...
|
2022-12-14 19:00:05 +00:00
|
|
|
RANDOM_FILE_INDEX=$(( $RANDOM % ${#FILE_MATCHES[@]} + 0 ))
|
2022-12-12 19:00:06 +00:00
|
|
|
|
2022-12-14 19:30:05 +00:00
|
|
|
# Return file matching that index...
|
2022-12-26 11:00:04 +00:00
|
|
|
echo "Revise this topic: ${FILE_MATCHES[$RANDOM_FILE_INDEX]}"
|