-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jeromos Kovacs
committed
Oct 4, 2024
1 parent
091945c
commit 787aa58
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |