It’s also fun to learn useful Bash skills through these command-line games.

Studying is hard work, but nobody likes working. This means that no matter how easy it is to learn Bash, it still feels like work to you. Unless, of course, you learn through games.

You wouldn’t think there would be many games to teach you how to use the Bash terminal, and that’s true. Serious PC gamers know that Fallout has a terminal-based computer in the vault to help you understand what it’s like to interact with a computer via text, but while it’s more or less functional like Alpine or Emacs, But playing Fallout doesn’t teach you commands or apps that you can use in real life. The Fallout series has never been ported directly to Linux (although it can be played through Steam’s open-source Proton). The latest installment in the Wasteland series, which was fallout’s predecessor, is linux-ready, so if you want to play the terminal, you can play Wasteland 2 and Wasteland 3 on your Linux gaming computer. The Shadowrun series is also available for Linux and has many terminal-based interactions, although admittedly it is often overshadowed by the Hot Sim sequence.

While these games have interesting ways of operating computer terminals and can run on open source systems, none of them are open source themselves. However, at least two games take a serious and very interesting approach to teaching people how to interact with the system through text commands. Best of all, they are open source.

Bashcrawl

You’ve probably heard of Colossal Cave Adventure, an ancient text-based interactive game with a “free Adventure” style. Early computer hobbyists played these games obsessively on the DOS or ProDOS command line, struggling to find the right combination of valid syntax and (as one sarcastic hacker explained) zany fantasy logic to beat the games. Imagine how productive a challenge would be if, in addition to exploring a virtual medieval dungeon, the challenge was to recall a valid Bash command. That’s the tone of Bash Crawl, a Bas-based dungeon exploration game that you can play by learning and using Bash commands.

In Bashcrawl, “dungeons” are created on your computer as directories and files. You can explore it by entering each room of the dungeon using the CD command to change the directory. As you walk through directories, you can view files with ls -f, read files with CAT, set variables to collect treasure, and run scripts to fight monsters. Everything you do in the game is a valid Bash command that you can use later in real life, and playing the game provides a Bash experience because the “game” is made up of actual directories and files on the computer.

$ cd entrance/
$ ls
cellar  scroll
$ cat scroll

It is pitch black in these catacombs.
You have a magical spell that lists all items in a room.

To see in the dark, type:     ls
To move around, type:         cd< directory> Try looking around this room. Then move into one of the next rooms. EXAMPLE: $ ls $cd cellar

Remember to cast ``ls`` when you get into the next room!
$
Copy the code

Install Bashcrawl

You must have Bash or Zsh on your system before you can play Bashcrawl. Bash comes with Linux, BSD, and MacOS. Windows users can download and install Cygwin or WSL or try Linux.

To install the Bashcrawl, navigate to the GitLab repository in Firefox or your Web browser of choice. On the right side of the page, click the Download icon (to the right of the Find File button). On the Download pop-up menu, click the Zip button to download the latest version of the game.

Download a zip from Gitlab

When the download is complete, unzip the archive.

Alternatively, if you want to start the installation from a terminal, you can use Git:

$ git clone https://gitlab.com/slackermedia/bashcrawl.git bashcrawl
Copy the code

Introduction to the game

As with almost any new software package you download, the first thing you must do is read the README file. You can read it by double-clicking on the readme.md file in the bashcrawl directory. On a Mac, your computer might not know which application to use to open the file; You can also open it using any text editor or LibreOffice. The readme. md file will tell you exactly how to start the game, including how to enter the game on the terminal and the first command you must issue to start the game. If you can’t read the README file, the game just won (though it won’t tell you since you haven’t played it).

Bashcrawl is not meant to be played by clever or advanced users. Instead, it is kept as simple as possible in order to be transparent to new users. Ideally, new Bash users would learn some of the basics of Bash from the game, then stumble upon some game mechanics, including simple scripts to make the game work, and learn more about Bash. In addition, new Bash users can design their own dungeons following examples of existing content from Bashcrawl, and there’s no better way to learn to code than by writing games.

Command-line hero: BASH

Bashcrawl is for absolute beginners. If you use Bash a lot, chances are you’ll try to find a secret path to beat it by looking at the Bashcrawl file in a way that beginners don’t yet understand. If you are an advanced Bash user, you should try the command-line hero: Bash.

The game is simple: type as many valid commands as you can in a given amount of time. Sounds simple enough. As a Bash user, you use many commands every day. For Linux users, you know where to find the command list. The util-Linux package alone contains over a hundred commands! The question is, are your fingertips busy typing those commands under the pressure of a countdown?

Command Line Heroes: BASH

This game sounds simple, and it is! In principle, it is similar to the Flashcard, but the other way around. In practice, it’s a fun way to test your knowledge and recall. It’s Open source, of course, and was developed by the developers of Open Jam.

The installation

You can play command Line Hero: BASH online, or you can download the source code from GitHub.

The game is written in Node.js, so unless you want to help develop the game, play it online.

Minesweeper in Bash

If you are an advanced Bash user and have written multiple Bash scripts, you may want to learn more than Bash. You can try writing games instead of playing them, and that’s the real challenge. With a little thought, you can implement the popular game Minesweeper in Bash in an afternoon or a few hours. Try writing the game yourself, then read Abhishek Tamrakar’s article to see how he did it.

Sometimes programming serves no purpose but education. Writing a game in Bash may not be the kind of project that will earn you a reputation online, but the process can be fun and enlightening. It’s a great way to learn new skills when faced with a problem you never thought of.

Learn Bash and have fun

No matter how you learn it, Bash is a powerful interface because it enables you to instruct the computer to do what it needs to do without going through the “man in the middle” interface of a graphical application. Sometimes the graphical interface is helpful, but sometimes you want to move away from something you already know a lot about and move on to something that can be done quickly or through automation. Because Bash is text-based, it is easy to script, making it an ideal starting point for automated jobs.

Learn Bash to start on your way to being an advanced user, but make sure you enjoy it.


Via: opensource.com/article/19/…

By Seth Kenlon (lujun9972

This article is originally compiled by LCTT and released in Linux China