Aapeli Vuorinen

Using computers efficiently

In this post I’ll share some thoughts on computing as a tool, and give some tips and tricks on how to get the most out of your computer. It serves a dual purpose: on one hand I want to point my friends, coworkers, and other people to the post so that they might improve their computing skills, but also it helps me keep track of the tricks I’ve come up with and keep improving.

I’ve tried to write things in a form that the most high-value things are at the top, and the further you go, the smaller marginal gains there are, as I envision this will basically end up being a long list of tips and tricks.

Note: although the title is very general, this is largely aimed at people who do software-related stuff on a computer and live in the terminal, with an interest in becoming more dexterous at that particular task.

Why this all matters

A computer is a tool. It’s one of the most efficient tools we’ve come up with, and it’s one of the most used tools we have. It’s such a ubiqutuous and powerful tool that sometimes people lose sight of that fact, and stop sharpening and maintaining their tool. One might become complacent with what it does since it’s already so good, and just use its basic functions.

When I started writing this I actually launched into a bunch of abstract fluff about information retrieval in which I explain why I prefer the command line to graphical user interfaces. Feel free to read that.

The killer things you need to be doing

Learn to type fast and without errors

You spend \(n\) hours per day on your computer, \(n\) is pretty huge. The way you interface with your computer is mostly by typing things, so you should be good at it. Spend some time learning to type quickly and without making errors all the time.

The way I did this was to have two types of practise: the first was to type very slowly with 100% accuracy, not only making sure I was typing without errors, but also that I was hitting the right keys with the right fingers each time. The second stage is to type as quickly as you can, and not worry too much about errors. You then alternate between the two while doing your normal work. It took me a few weeks of concentrating this for half an hour a day, and my error-adjusted typing rate went up by a factor of two or something. It makes a huge difference to not have to stop and correct errors continuously.

I learnt this trick of alternating between working on accuracy and speed from a very good friend who is a professional flautist (and was also my saxophone teacher for a long time).

Use the terminal, learn the basic commands and how to use pipes

Use the terminal, it’s much faster than a graphical app, and it (Bash or equivalent) is everywhere (even Windows). You can basically do anything in a few keystrokes, it’s insanely powerful.

Learn the basics of using a grep implementation. You can pipe stuff into grep to search for things as well as a bunch of other stuff like displaying the lines immediately preceding or following the matched expression. Have a look at ripgrep.

Learn find, and some basic options for it.

Command completion and reverse search (Ctrl+R)

Most terminal emulators come with very powerful command completion feature, use this. When typing something, you can normally hit Tab once and it’ll complete as much as it can, and once it’s stuck (e.g. there’s two commands that start with the current prefix), hit Tab twice and you’ll get a list of all completions that start with the current prefix.

You know what’s even better than auto-completing commands and arguments? Not typing them at all. Hit Ctrl+R and start typing something, and the terminal will find the last occurence of that combination of characters in your history, then hit either left or right to modify that command, or just Enter to execute it again. Press Ctrl+R twice without typing anything to redo a search. Have a look at the history command.

Pick an editor and get very good at it

You need to be solid at text editing. I preferred VS Code and in the terminal I use Vim. I like the fact that in VS Code I can issue commands after hitting Shift+Cmd+P, and it’s got a nice autocomplete.

Learn how to use multiple cursors, how to search and replace (bonus: learn regular expressions, they’re hard but are very useful in a lot of repetitive tasks that are otherwise hard to automate). Again, learn how to navigate in code with shortcuts, how to quickly cut and paste text.

Other useful tips if you’re still reading

Learn shortcuts that simplify your life

Some invaluable shortcuts in terminal emulators:

Figure out how to jump over words in your terminal emulator.

Learn some useful Bash tricks

Learn to do rudimentary programming in Bash. Figure out how to write a basic for loop and perform a set of commands on each file in a directory, for instance.

Learn about what brace expansions do, and how to use them. They’re really useful in moving and copying files, and otherwise doing menial tasks, for example, what does mv file{,.bak} do? How about rm report.{aux,fdb_latexmk,fls,log,syntex.gz}?

Learn Git properly

If you use Git for version control, you should really know how it works one level deeper than what you need for your daily tasks. It’s a complicated program and not necessarily intuitive or completely thought out but this will really pay off.

Here’s some basic questions:

Make the caps-lock key a control key

It’s so much faster (especially on a Mac) to hit the above shortcuts than using the normal Ctrl key.

Use tmux

This is starting to get more to personal preference, but tmux (the terminal multiplexer) allows you to run multiple terminal panes on the same screen, which really helps for example if you have a development command on one pane and a “working terminal” in the other (where you use Git, etc).