Shell frontend for Simon Tatham’s Portable Puzzle Collection

Simon Tatham wrote an excellent set of puzzle games. There’s actually quite a lot of them and the executables are all named without prefix, so it’s hard to remember them all. I think Debian/Ubuntu add .desktop-entries for the application menu. Anyway, I’m more comfortable in a terminal, plus I wanted to try using zsh’s arrays, so here goes:

#!/bin/zsh
# local puzzles=()
local menu=()
local title
puzzles=( blackbox bridges cube dominosa fifteen filling flip galaxies guess
        inertia lightup loopy map mines netgame netslide pattern
        pegs rect samegame sixteen slant solo tents twiddle
        unequal untangle
        )
for (( i=1 ; $i <= ${#puzzles} ; i++ )); do
    menu=($menu "$i. $puzzles[$i]")
done

print ' .+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+. '
print '(                                                             )'
print " )        Simon Tatham's Portable Puzzle Collection           ( "
print '(                                                             )'
print ' )   http://www.chiark.greenend.org.uk/~sgtatham/puzzles/    ( '
print '(                                                             )'
print ' "+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+"+.+" '
print
print -C 4 $menu
print -n "Enter a number to start> "
read choice
exec $puzzles[$choice]&
Tagged with: , ,
Posted in Code

Leave a comment