Want to upgrade your Linux command-line tutorials by using GIFs instead of images? VHS is the terminal GIF creator you need.
The Linux terminal is a wonderful tool that helps you get the best out of your machine. Most people learn to use it by following tutorials with line-by-line instructions. But a better way may be to see it in action.
Unless you know what you're looking at, terminals aren't particularly interesting. There are lines of text, inputs and outputs, statuses, and the occasional piece of ASCII art. For a Linux newcomer, it can be difficult to link cause to effect.
Videos and GIFs can often help, which is possibly why there are tens of thousands of Linux tutorials on YouTube. These are typically created via screen recording, or by holding a phone camera, one-handedly, in front of a monitor.
But videos are large and awkward files, typically running up to many hundreds of MB, and require extensive resources if they're going to serve more than a few people. They're wasteful, and not ideal if you don't want to rely on YouTube to control access to your content.
While it is possible to convert video files to GIFs on your Linux PC, the solutions are often inelegant, and the files are bulky.
VHS is a command line utility that helps you create GIFs from a set of commands contained in a text file.
The commands are executed in sequence one after another, and the output is recorded in a file. You can also specify the font size for readability, as well as the dimensions of your terminal window.
VHS requires ttyd and ffmpeg to run. If your system supports snap, install ttyd with:
Packages for ffmpeg are available in the default repositories.
Now you're ready to install VHS.
Add the repo key to your keyring:
Update the package sources with APT, then install VHS:
You can install VHS from the Arch User Repository using yay:
Copy and paste the entire command snippet below in the terminal, then press Enter:
Then, install VHS by typing:
VHS uses a custom ".tape" extension. To begin, create a new one by typing:
Now use nano to open and edit the tape:
In the file, you will find useful configuration options as comments. These include output formats: yes, you can save the output as MP4 or WebM, although in our opinion, this kind of defeats the point. You will also see options for finetuning your font and setting the delay between characters appearing on the screen.
Two commands you may find especially useful are Hide and Show. As their names suggest, these will either hide subsequent commands from appearing in the terminal or show them.
After setting the output file name and the terminal dimensions, commands will be executed in order.
To simulate words being typed into the terminal, prefix your desired string with the command Type, followed by the string in quotes. For instance, if you want the string "MUO is Ace!" to appear as if they're being tapped out by a user behind a keyboard, enter:
Type the command Enter after your string to simulate hitting Return, and you will see:
The Linux echo command will execute, and you will see the terminal output:
To simulate a 200ms gap break after a line of text, use the command Sleep. For instance:
…will result in a pause of 200ms before the next line starts to type out.
The Type command causes actual commands to be executed, with their output captured in the GIF.
To simulate running a customized Neofetch command, as above, our tape file contains the following:
Once you are satisfied with the commands, save the file with Ctrl + O then Ctrl + X, and then feed the file into VHS.
VHS will render the tape as a GIF.
The GIF shown above is low quality because we used a third party for GIF hosting. You'll have to trust us that the actual GIF produced will be of high quality and suitable for embedding in any web page and most content management systems.
If you want your command to run without having the actual command shown on the screen, use the Hide and Show commands before and after the command you want to run:
Lists of commands can be as long as you like, and provided the output can be shown in a terminal without launching a GUI-driven app, VHS will faithfully record your actions.
VHS is packed full of useful features which help you customize the way your output appears. Here are some of our favorites:
Simulates pressing the Backspace key by deleting characters. Append an integer for how many characters you want to delete.
Often, Linux commands have shortcut equivalents that use the Ctrl key. Entering "Ctrl+l" into your VHS tape file will clear the screen on most Linux distros.
Results flashing by too quickly? Use "PlaybackSpeed" to alter the playback speed of the final render.
…will halve the playback speed of the output.
A full list of commands is available on the VHS GitHub page.
Making GIFs of terminal input and output with VHS is easy and seriously cool, and it's an excellent way of demonstrating commands and their results. It has excellent potential as a visual resource when writing tutorials or as an alternative to YouTube.
Before you run off and create your own Linux tutorial site, make sure that you're an expert and up-to-date with the most useful modern Linux commands.
David is a freelance writer with a background in print journalism. He has written for newspapers in the United Kingdom and the Middle East. He is a terrible guitar player, and he spends his free time touring the British Isles, off-grid, with his caravan and dogs. Occasionally, he writes books. No-one likes them. See what he’s up to at davidrutland.com
Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!
How to Create Better Linux Terminal GIFs With VHS – MUO – MakeUseOf
Leave a comment