Skip to content

Commit

Permalink
misc: cool script
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeromos Kovacs committed Oct 4, 2024
1 parent 091945c commit 787aa58
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions scripts/pattern.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env fish

set cmd $argv[1]
if test "$cmd" = all; or test "$cmd" = any; or test "$cmd" = ""
for line in "$(curl https://conwaylife.com/patterns/ | rg .cells)"
echo $line | string split '"' -f 2
end
return 0
end
set pattern "$(string replace '.cells' '' $cmd)"
echo "pattern: '$pattern'"
set url "https://conwaylife.com/patterns/$pattern.cells"
echo "url: '$url'"
if test "$argv[2]" = --download; or test "$argv[2]" = -d
set p "/tmp/$pattern.cells"
if test -e $p
echo "already saved to '$p'"
else
echo "saving to '$p'"
curl $url -o $p
end
else
curl $url | cgol-tui -
end

0 comments on commit 787aa58

Please sign in to comment.