Just because you prefer working in a text-mode interface doesn't mean you're not entitled to a little fun here and there.
Last December, I took some time out before the holidays to explore some of my favorite command-line diversions into a series for Opensource.com. It ended up being a bit of an advent calendar for terminal toys, and I got some great suggestions from readers.
Now summer has arrived, at least for us in the northern hemisphere, and for many of this means a time of summer breaks, vacations, and generally trying to fit in a little relaxation between committing code and closing tickets. So to that end, I thought I'd revisit five of my favorite command-line games from that series, and share them here with you on Enable Sysadmin.
All of these games were tested in Fedora, most from the default repositories, but you can likely find them for other distributions as well. Or, grab the source code to compile them yourself.
We'll start with one of my all-time favorite casual games, 2048 (which itself is a clone of another clone).
To play, you just slide blocks up, down, left, and right to combine matching pairs and increment numbers, until you've made a block that is 2048 in size. The catch (and the challenge), is that you can't just move one block; instead, you move every block on the screen, provided it has space to slide.
It's simple, fun, and easy to get lost in it for hours. This 2048 clone, 2048-cli, is by Marc Tiehuis and written in C, and made available as open source under an MIT license. You can find the source code on GitHub, where you can also get installation instructions for your platform. Since it was packaged for Fedora, for me, installing it was as simple as:
$ sudo dnf install 2048-cli
MyMan is a fun clone of the classic arcade game Pac-Man. (You didn't think this was going to be about the similarly-named Linux package manager, did you?) If you're anything like me, you spent more than your fair share of quarters trying to hit a high score Pac-Man back in the day, and still give it a go whenever you get a chance.
MyMan isn't the only Pac-Man clone for the Linux terminal, but it's the one I chose to include because 1) I like its visual style, which rings true to the original and 2) it's conveniently packaged for my Linux distribution so it was an easy install. But you should check out your other options as well. Here's another one that looks like it may be promising, but I haven't tried it.
Since MyMan was packaged for Fedora, installation was as simple as:
$ dnf install myman
MyMan is made available under an MIT license and you can check out the source code on SourceForge.
Nudoku is a simple sudoku game that, once installed, can be invoked by name (nudoku) to launch, and should be fairly self-explanatory from there. If you've never played Sudoku before, it's fairly simple: You need to make sure that each row, each column, and each of the nine 3x3 squares that make up the large square each have one of every digit, 1-9.
You can find nudoku's c source code on GitHub under a GPLv3 license.
Snake is an oldie but goodie; versions of it have been around seemingly forever. The first version I remember playing was one called Nibbles that came packaged with QBasic in the 1990s, and was probably pretty important to my understanding of what a programming language even was. Here I had the source code to a game that I could modify and just see what happens, and maybe learn something about what all of those funny little words that made up a programming language were all about.
This version of Snake is written in Go, and while it's simple, it's just as much fun as the original. Like most simple old games, there are a ton of versions to choose from. In Snake's case, there's even a version in the classic bsdgames package that's almost certainly packaged for your distribution.
But what I like about this version of Snake is that it's packaged in a container so I can easily run it in one line from my terminal without worrying about anything disto-specific. That, and it makes use of 15 randomized food emojis for the snake to eat. I'm a sucker for food emojis. Anyway, give it a try using:
$ docker run -ti dyego/snake-game
This Snake is licensed as open source under an MIT license, and you can check out the source code on GitHub.
After taking the world by storm in the 1980s., Tetris was cloned many, many times. I would suspect you could find a Tetris clone for just about any operating system in any language you looked for. Seriously, go look. There are some fun ones out there.
The version I'm bringing you for today's command-line toy is written in Haskell, and it's one of the better-done versions I've seen, with on-screen preview, score, help, and a clean look.
If you're willing to run a compiled binary from an untrusted source (I wouldn't recommend it), you can grab that directly, but for a safer approach, it's also easy to use a containerized version with dex, or to install from source with stack.
This particular Tetris clone is by Sam Tay and available under a BSD license. Check it out!