Created
April 12, 2023 04:14
-
-
Save radgeRayden/50797b8ccc32e5493cfab80752e0e28b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env fish | |
set ORIGIN_DIR (dirname (readlink -m (status --current-filename))) | |
pushd $ORIGIN_DIR | |
set LINE_COUNT (cat unvisited-links.txt | wc -l) | |
set RANDOM_INDEX 0 | |
function get-line | |
set RANDOM_INDEX (random 1 $LINE_COUNT) | |
head -n $RANDOM_INDEX unvisited-links.txt | tail -n 1 | |
end | |
while true; | |
set LINE_CONTENT (get-line) | |
if [ $LINE_CONTENT != "" ]; | |
echo $RANDOM_INDEX $LINE_CONTENT | |
echo $LINE_CONTENT >> visited-links.txt | |
head -n (math $RANDOM_INDEX - 1) unvisited-links.txt > unvisited-temp.txt | |
tail -n (math $LINE_COUNT - $RANDOM_INDEX) unvisited-links.txt >> unvisited-temp.txt | |
mv -f unvisited-temp.txt unvisited-links.txt | |
break | |
end | |
end | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment