The topics covered in this chapter are valuable options to consider when working from either the command line or GUI—or both in many cases.
First, we talk about Markdown and LaTeX, two “languages” for describing text that allows for easier conversion to other formats. Markdown can be learned in under half an hour, while LaTeX is much more complex but also much more flexible. Generally speaking, if you are writing for EPUB or HTML for web-based publishing, I would recommend learning Markdown. If you are writing for PDF or print publishing, I’d look at LaTeX, but there is a lot of crossover between the two.
Second, we look at what are generally called “dotfiles.” I’ve mentioned repeatedly that text apps are extremely customizable, but we haven’t really delved into it. The dotfiles are where configuration information about each app is stored; and things like key mappings, color schemes, plug-ins, and most other customizations are accomplished by editing these files.
Third, I walk you through my dotfile for the Vim editor. I am by no means a master of Vim, but I have done some basic customizations that may appeal to a non-programmer. I’ll walk you through this file step by step as an example to show what kind of things can be done.
We then look at using your Raspberry Pi as an emulator of other systems. The Pi runs Linux, but inside that we can run MS-DOS apps, Nintendo games, and even old coin-op arcade games.
Finally, I have included a list of links as “additional resources” for further research as well as some ideas for what to do with the “extra” Raspberry Pi computers you’re likely to acquire as your interest grows.
Markdown and LaTeX
In the GUI world, word processors are kings of document creation. Microsoft Word, Apple Pages, even Google Docs make document creation visual and easy. On the other hand, if you’ve ever gotten lost in a tangle of indentions and missing bullet points in Word, then you know how frustrating those visual formats can be. Many writers choose to work with a text editor instead of a word processor. Working with text is a mixed blessing. You have total control over every aspect of your words and data, but it comes at the cost of a higher learning curve. That sounds familiar by now, doesn’t it?
I mentioned WordGrinder back in the “Writing Tools” section. It’s the closest thing to a “word processor” I know of for a text-only system. It allows you to do boldface, underlining, and a few other formatting things; but it’s not anywhere near as robust or powerful as any of the GUI word processors. It is reliable and easy to learn; it may be enough for you.
On the other hand, if you do a lot of writing, or require more precise formatting, there are two very popular systems of describing your text formatting: Markdown and LaTeX. Which of these you decide to learn depends on the kind of writing you do as well as what kind of output you desire.
I have included two examples in the following, one of Markdown and the other of LaTeX, and neither of them includes any explanation. As you can see from these two examples, Markdown is relatively easy to read, even for someone who doesn’t actually know that the material they are looking at is Markdown. It’s easy to follow and easy to learn; usually it’s just the addition of certain punctuation characters to plain text, like # for various headings, ** for bold and * for italic, and []() for links and graphics. It’s much easier to learn than HTML, but allows for very similar output. In fact, Markdown was originally created to easily convert a text document into HTML for posting to a blog, but it’s useful for most forms of online writing.
LaTeX, on the other hand, is scattered with a huge number of tags and brackets and generally has more “overhead.” That said, the overhead and complexity allow essentially unlimited flexibility with printed layouts—more books have been typeset with LaTeX than any other method since computers first started being used in printing.
Of course, both Markdown and LaTeX are simply “markup languages” that describe the text, much in the same way HTML does. Both text languages are simply text files that are edited using the text editor of your choice—Vim or Emacs; or even Nano could be used. Of course, since they are simply text files, they are, by definition, completely cross-platform. If you decide to go back to Windows, Mac, or Linux someday, you can take all these files with you as the same tools are available for those platforms as well. The same goes with iOS, Android, decades-old mainframes, and every computer that hasn’t been invented yet.
Text files are never going to “go away” or change significantly enough that it can’t be read by something. The same cannot be said for word processing formats—think of files saved in Apple Works, Microsoft Works, or even early versions of Apple Pages, none of which can be read in modern word processing software. Those files have essentially become unreadable.
The process of using the text languages is quite simple. You just type in the “code” as shown in the following using your favorite text editor. Remember the .md or .tex file that you write is not the final document; it will be compiled using an app like Pandoc or LaTeX to create an output file in the format that you need: .docx, .pdf, .odt, or whatever you want. There are dozens of output formats that you can use.
Markdown
Pandoc
pandoc | The main command |
---|---|
-f markdown | From the markdown format |
-t docx | To the docx format |
example.md | Source file (ends in md for markdown) |
-o | Output |
example.docx | Output file (ends in docx for Word document) |
Pandoc is an immensely powerful conversion utility, and it supports literally dozens of different input and output formats.
You can read the man page by typing man pandoc and paging through it all, or for something a little more reader-friendly, try the web site at https://pandoc.org/MANUAL.html .
LaTeX
There was a brief description of Texmaker back in Chapter 4. If you’d prefer a much more graphical option, there are completely online, cloud-based LaTeX editors. Check out Overleaf.com for what is easily the best example. It works great on the Chromium browser from the Pi as well, and you don’t need to install anything to make it work. It even stores your writing in the cloud, so you don’t have to worry about losing anything.
Customization with Dotfiles
Throughout the book, I’ve mentioned over and over just how customizable everything is, but I haven’t touched on how to do any of that customization. Some text-based apps have drop-down menus and settings that are adjusted just like the settings in a graphically based app. If that’s the case, then you probably know how to do that already.
The more powerful method is by editing “dotfiles.” These are files containing settings, variables, and fields that you can change with a text editor like Vim, Emacs, or even Nano. The files are usually named after the app itself, only they start with a period (hence “dotfiles”), and sometimes they have “rc” added at the end. Some examples might be
.vimrc
.emacs
.muttrc
.tmux.config
.config
Note
The following applies to any variety of Linux. Check the documentation for specific apps to see where the configuration files are stored and how to access them.
You may need to scroll up and down to see everything, but there are going to be a number of files that start with a period. These files can be edited, changed, and then saved to alter permanent settings for the apps. Note that dotfiles are “invisible” to the basic ls command, so you must use the -la switch to see them. They may also be hidden if you use Ranger or Midnight Commander to view the directory listing.
Every app has different rules and settings, and there’s no way I can explain them all (even if I understood them all). The best way to go about this is to use an app in its default state, and then as soon as you find yourself thinking “I wonder if there’s a better way to …” or ”I wish this worked differently,” then go online (or check the man file) and do a search for the app’s configuration options. There’s a very good chance there is a setting or a plug-in that does exactly what you need. Most apps are surprisingly flexible, but you will find that most commend-line/text-mode apps don’t have extensive built-in menus.
As an example, I use the Vim text editor a lot, and I have modified its configuration file quite a bit. In the next section, I will go over my dotfile for Vim. Most other apps work in similar ways.
My .vimrc File
If you don’t already have a .vimrc file, this will create one for you.
Line 1: Filetype tells Vim to detect what kind of file is being loaded and use syntax highlighting for that kind of file. I am not a coder, so I don’t need syntax highlighting, so I turned that off.
Line 2: UTF-8 is a standard character encoding type that is used for most print and ebooks. It’s also all I ever use. Settings like this, where you want to set it once and never mess with it again, are prime candidates for a change in the configuration file.
Lines 4 and 5: Pathogen is a “plug-in manager.” Vim allows extensions and plug-ins that do things not built in to the base Vim system. Pathogen takes care of loading and running the plug-in scripts for me.
Line 6: Airline is a replacement for the plain status line at the bottom of the screen in Vim. Mine has a nice blue color with different information than what Vim provides by default. It’s not really a necessity, but I like how it looks. Mine uses the theme “Jellybeans,” which is set here.
Line 8: Turns plug-ins and indentation on.
Line 9: Vim has a thing called a “leader key” which allows you to define keyboard combinations that do just about anything you can imagine. I have my leader key set to the comma key. That means I can hit comma-n, and something will happen. If I hit comma-m, something else can happen, and so on. It’s a lot like hitting the Ctrl or Alt key along with something else, but Vim has so much going on that most of the Ctrl and Alt combinations have already been taken. The leader key combinations are “all mine.” We’ll define these specific keys later in the file.
Lines 11–20: Vim is a programmer’s editor, but I mostly write text files. I don’t like the way Vim moves up or down an entire paragraph when I hit the up or down arrow keys. I am used to the way regular word processors use the arrow keys, so here I have “remapped” the keys to move the way I want. In line 11, I have remapped the “j” key to use the action normally associated with the keys “gj.” Line 15 does the same thing for the down arrow key. The vnoremap, nnoremap, and inoremap do the same things, but apply the changes to different modes. It’s complicated, but your takeaway here is that you can remap any key on the keyboard to do anything you want. (Vim purists are now shaking their heads at this abomination, wondering why I don’t just use the default movement keys). Vim is a really old application; it was literally designed before many keyboards had arrow keys on them; so the default movement are the H, J, K, and L keys.
Line 22: This is a comment. It doesn’t do anything.
Line 23: Here’s where things start to happen. This line maps the leader key I mentioned earlier with the “n” key. When I hit comma-n, the plug-in NERDTree runs. NERDTree is a file-browsing plug-in used to select and load files from a menu.
Line 24: Maps the comma-m combination to make the NERDTree window go away. I can use comma-n to select and load a file and then hit comma-m to make the file selector go away.
Line 26: Another comment.
Line 27: Maps COMMA-U to compile the text file on the screen to a PDF using PDFLATEX. If I’m writing a LaTeX file, this will do all the compiling for me, so I don’t have to remember or type the command line that normally is needed to compile a file.
Line 28: Maps COMMA-I to load the Evince PDF viewer and preview the file created when I hit COMMA-U.
Line 31: Maps the F6 function key to turn spell-check on or off.
Line 33: There are numerous built-in color schemes you can use, or you can install your own. I use the built-in theme called “slate.”
Line 34: Has something to do with compatibility with the much older VI program. I don’t need this compatibility, so I turn it off.
Line 35: Turns line numbering off. Again, I write prose text, not code, so I don’t especially care about line numbering. Note that the line you are currently on still shows in the status bar at the bottom of the screen.
Line 36: In GUI mode, this removes the left-hand scroll bar.
Line 37: In GUI mode, this removes the tool bar at the top of the screen.
Line 38: Set ruler allows Vim to know and display on the status line which column your cursor is in.
Line 39: Set the number of Undo levels.
Line 40: This makes it so Vim will break a line at spaces or punctuation, but not in the middle of a word. Otherwise, Vim allows a line to go on for a very long time without wrapping to the screen.
Line 42: For some reason, Vim does strange things to the lowest line of the screen. This line fixes that.
Line 43: If you’ve ever used a tool like TextExpander , you’ll like this. This line fixes it so that whenever I type the characters img, it automatically expands that text into the string ![](.jpg). That’s an empty placeholder for an image file when writing in Markdown. I never remember the specific characters involved, and because of this line, I don’t have to. When I want to insert an image, I type img, and those characters pop up. Then I go back in and fill in the description and filename. You can set up any unique string of characters to expand into anything you want this way. For space reasons, I’ve only included this one abbreviation here, but it’s not uncommon to have dozens of them.
Again, a serious Vim user will customize their .vimrc file to the point where they quite simply have thousands of lines of customizations.
How did I learn to do all this? I tried using the “vanilla” Vim program, and when I hit something I didn’t like, I Googled until I found the configuration commands. When you find a page that explains some modification you like, often it will link to related customizations that you can do, and then you’re down a rabbit hole of crazy modifications. It’s actually fun adding some powerful new function to what is otherwise such a “plain” app.
Mastering and squeezing out every last drop of power and performance out of these tools is a serious hobby for some people, and they love to write about their exploits online. At the very least, you should experiment with changing the color scheme and turning on spell-check—those are easy commands to start with. Then build things up one step at a time. My advice is also to not copy anyone else’s configuration files—not even mine. Make up your own as your needs grow.
My .tmux.conf File
Obviously, this is much shorter than the Vim configuration file; not everything is super complicated.
The first line loads a color theme for the status line that displays at the bottom of the Tmux screen. Normally, Tmux shows a plain green status line, but this one has a nice blue color and some graphic dividers. It doesn’t really do anything useful, but I like the way it looks.
The second line is a comment, explaining the next two lines.
Line 3 “binds” the | key to the command that splits the window horizontally. The | key looks to me like the vertical slice that cuts the window in half, so I think that’s easier to remember than the default key for this action.
Line 4 does the same thing, mapping the – key to the vertical split. The hyphen goes from right to left, which looks to me like the line that goes across the screen in the vertical split. I’m a bit of a visual thinker, so these two keys are just easier to remember than the default keys “ and %.
So that’s my .tmux.conf file. Just about every application you can find has something similar to this, although usually not so elaborate or complex as the Vim example.
If you don’t see a dotfile in your root directory, look inside the ~/.config subdirectory; sometimes they hide them in there. If it doesn’t exist in either ~/.config or your /home directory, check the documentation for the software—it almost certainly has some method of making permanent customizations; it’s just a matter of finding the file location. It’s also a very good idea to keep backups of all your customized dotfiles. That way, if you set up another machine, those files are easily available, and also if you mess something up, you can go back to the previous working version. I know many Linux users who keep all their dotfiles in a Github.org repository, a project outside the scope of this book.
This may seem at first to be unnecessarily complex. Surely, it would be easier to select options from a menu. Well, that’s true if the choices are limited to what the creators of the program thought to include. Apps like Vim and Tmux allow an unlimited variety of plug-ins and features that border on the ridiculous. There’s no way the Vim programmers would have thought to include everything, nor would they want to. Many plug-ins are very special purpose. By using completely open text files for configuration settings, pretty much anything goes as far as what can be created. Yes, it’s more complicated, but it’s infinitely expandable.
Other Distributions of Linux
We saw from the very beginning that there was more than one Linux distribution available for the Raspberry Pi, and we started off talking about Raspbian and Ubuntu MATE. There are others available as well, and you can try them out as you see fit by following the same process we did in the beginning: download an image file, write it to SD card (or hard drive) using Etcher, and then configure the operating system.
Raspbian is the default Raspberry Pi operating system, created and maintained by the Raspberry Pi Foundation
Ubuntu MATE is one version of Ubuntu with a complete desktop and major apps. For the most part, MATE runs slower than Raspbian, but it’s much more full featured and often friendlier to use
Kali Linux is big with white-hat hackers and security testers. It doesn’t come with the usual games and business apps, but it does focus heavily on security testing
( www.kali.org/ ).
CentOS is the community edition of the Red Hat Enterprise Linux distribution, and each new version is guaranteed to be supported for 10 years
( www.centos.org/ ).
RISC OS is very different from the others in that it’s not based on Linux in any way. It’s very fast and very small, but it does things in unusual ways compared to Linux systems
( www.riscosopen.org ).
RASPBSD is a version of FreeBSD for the Pi. FreeBSD also isn’t Linux, but a full version of Unix, the OS that Linux was based upon
( www.raspbsd.org/ ).
Windows IoT Core and Ubuntu Core are two specialized versions of the respective operating systems that are not full desktop environments, but are “core” systems, scaled down to take advantage of the Pi’s cheap hardware to create Internet-connected “Internet of Things” devices
( https://docs.microsoft.com/en-us/windows/iot-core/downloads
Pi MusicBox turns your Pi into a jukebox, loading your music from local and networked storage drives as well as many streaming sources like Spotify and Google Play Music
( www.pimusicbox.com/ ).
LibreELEC is designed to run the Kodi media center. You connect it to your TV/monitor and a hard drive full of videos and music, and it turns your TV into a very smart TV
OpenMediaVault turns your Raspberry Pi into the brains of a Network-Attached Storage (NAS). Just add one or more large hard drives, and plug the Pi into your network, and you’ve got a smart NAS
RetroPie is a “retro” video game emulation system. We’ll talk more about emulators in the next section, but this distribution includes apps that emulate dozens of older computers
DOSBox and Emulation Software
Still, there are other possibilities. With a “full power” computer, virtual computing and emulators are a major area of hobbyist interest. Can you run emulators on the Raspberry Pi? Of course you can! Emulating old video game systems is one of the most common hobby uses of the Pi.
One of the most popular and thoroughly debugged emulators is called DOSBox. It allows you to run software created for MS-DOS from the 1980s and 1990s and run it right on your Raspberry Pi. This could be once-popular software such as WordPerfect 5.1, Lotus 1-2-3, Wildcat! BBS, or other powerful software. On the other hand, it could also be some of the thousands of great games written before Windows 95 took over the PC world: Wing Commander, M.U.L.E., Zork, Tetris, and a bunch more. These games don’t have to be lost to time; you can run them on your Raspberry Pi right now.
Run it with dosbox.
If you are familiar with MS-DOS, most all commands will work. Copy files, delete files, directory listings—it’s all here. The first step in running a game or app is to “map” a directory in your home folder to the C: drive in “DOS.” This makes it appear to DOS that you have these apps installed on your main DOS hard drive.
and the game will not only start, but it will work surprisingly well. Figure 7-2 shows a screenshot.
- 1)You can set it to automatically mount the C: drive as we did earlier. Just type in the “mount” command in the configuration filemount c ~/Downloads/DOS
or whatever location you use for your DOS apps.
- 2)
Near the top of the file is a line fullscreen=false. If you change this to fullscreen=true and then save the file, DOSBox will start opening in full-screen mode, which looks much better than the tiny window you’ll get otherwise.
This section isn’t meant to be a DOS emulator tutorial so much as it is an example of one type of emulator that is available to you. There are similar emulators available for Nintendo, Game Boy, Genesis, and most other older arcade and console games.
RetroPie
3do Amiga Amstrad CPC Apple II Atari 2600 Atari 5200 and 8-bit series Atari 7800 Atari Jaguar Atari Lynx Atari ST/STE/TT/Falcon CoCo Colecovision Commodore 64 Daphne Dragon 32 Dreamcast FinalBurn Alpha GameCube Game & Watch Game Gear Game Boy Game Boy Color Game Boy Advance Intellivision Macintosh MAME Master System Mega Drive/Genesis MESS MSX Nintendo 64 | Neo Geo Neo Geo Pocket Neo Geo Pocket Color Oric-1/Atmos PC PC Engine/TurboGrafx-16 PC-FX PSP Nintendo DS Nintendo NES PlayStation 1 PlayStation 2 ResidualVM SAM Coupé Saturn ScummVM Sega 32X Sega CD Sega SG-1000 Super Nintendo TI-99/4A TRS-80 Vectrex Videopac/Odyssey2 Virtual Boy Wii WonderSwan WonderSwan Color Zmachine ZX Spectrum |
Additional Resources
Using the Linux command line (pdf book)
Plaintext Productivity
Inconsolation: Adventures with lightweight and minimalist software for Linux
Awesome Shell: A curated list of awesome command-line apps
Pro Git book by Scott Chacon and Ben Straub and published by Apress available for free
Most Useful Command-Line Tools: 50 Cool Tools to Improve Your Workflow, Boost Productivity, and More
Dedicated Pi Projects
Pi-Hole: A “black hole” for Internet advertisements at https://pi-hole.net .
Pi-VPN: A Virtual Private Network server for the Pi at www.pivpn.io .
Firewall and Intrusion Detection:
www.instructables.com/id/Raspberry-Pi-Firewall-and-Intrusion-Detection-Syst/ .
Volumio Audiophile Music Player: Lets you set up the Pi as a dedicated jukebox and music player
OwnCloud: Create your own cloud server accessible from computers, phones, or anywhere. It’s like owning your own Dropbox
LAMP Server: LAMP is short for Linux, Apache, Mysql, PHP server. It’s essentially an entire web server that’s ready to use. There’s not one massive LAMP installer, as it’s made up of four very complex parts, but a simple online search should deliver several good tutorial sites for getting the system set up.
RetroPie Arcade: We discussed RetroPie in the section on emulation, but it’s a common hobby for creative people to design and build physical hardware to go with this software. There are everything from handheld Game Boy clones up to large wooden arcade-style cabinets. I’m not going to recommend any vendors here, but a quick Google search for “RetroPie consoles” will show you quite a selection.
All of these projects require a Pi dedicated to the task, so you wouldn’t want to use your “computer Pi” for these, but they may interest you if you’re interested in finding a job for a second or third Raspberry Pi, which is a lot more common than you might think—new models of the Pi seem to come out awfully fast, leaving many with spare “old” Pi systems to find a use for.
Conclusion
And there you have it.
We’ve bought, built, and assembled our little Raspberry Pi computer, we’ve installed the operating system onto the SD card or hard drive, and we set up a user account.
Then we learned the Raspbian desktop interface and installed a bunch of fun and powerful apps.
We then switched over to the command line and installed a selection of even more powerful and customizable tools.
Lastly, we looked at text markup languages and dot-config files, which allow an endless array of customization options.
What have we discovered in all this? That the Raspberry Pi is essentially a regular computer, just smaller, less expensive, and perhaps not quite as expandable as some others. Still, it runs Linux and has all the necessary input and output options, so there is very little that it cannot accomplish. Granted, many of the same apps are slower than those on a new MacBook, but at one-fiftieth of the price, maybe that’s a fair trade-off. Only you can say for sure.
Now it’s time to get to work!