diff --git a/scripts/pattern.fish b/scripts/pattern.fish new file mode 100755 index 0000000..3aea622 --- /dev/null +++ b/scripts/pattern.fish @@ -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