How to Create Better Linux Terminal GIFs With VHS

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.

VHS Is an Easier Way to Create GIFs of Your Linux Terminal

wikit mockup

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.

How to Install VHS on Linux

VHS requires ttyd and ffmpeg to run. If your system supports snap, install ttyd with:

sudo snap install ttyd 

Packages for ffmpeg are available in the default repositories.

Now you’re ready to install VHS.

On Debian-Based Distros

Add the repo key to your keyring:

curl -fsSL https:
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https:

Update the package sources with APT, then install VHS:

sudo apt update && sudo apt install vhs

On Arch Linux

You can install VHS from the Arch User Repository using yay:

yay -S vhs-bin

On Fedora and Red Hat Enterprise Linux

Copy and paste the entire command snippet below in the terminal, then press Enter:

echo '[charm]

Then, install VHS by typing:

sudo yum install vhs

Using VHS to Create GIFs of Your Terminal

VHS uses a custom “.tape” extension. To begin, create a new one by typing:

vhs new demo.tape

Now use nano to open and edit the tape:

nano demo.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 echo "MUO is Ace!"

Type the command Enter after your string to simulate hitting Return, and you will see:

echo MUO is Ace!

The Linux echo command will execute, and you will see the terminal output:

MUO is Ace!

To simulate a 200ms gap break after a line of text, use the command Sleep. For instance:

Sleep 200ms

…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:

Output demo.gif
Set FontSize 14
Set Width 1200
Set Height 600
Type "neofetch --ascii muo_ascii.txt"
Sleep 500ms
Sleep 5s

Once you are satisfied with the commands, save the file with Ctrl + O then Ctrl + X, and then feed the file into VHS.

vhs < demo.tape

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:

Type "neofetch --ascii muo_ascii.txt" Sleep 500ms Enter

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.

Other Useful VHS Features

VHS is packed full of useful features which help you customize the way your output appears. Here are some of our favorites:

1. Backspace

Simulates pressing the Backspace key by deleting characters. Append an integer for how many characters you want to delete.

2. Ctrl

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.

3. Set the Playback Speed

Results flashing by too quickly? Use “PlaybackSpeed” to alter the playback speed of the final render.

PlaybackSpeed 0.5

…will halve the playback speed of the output.

A full list of commands is available on the VHS GitHub page.

Creating Terminal GIFs for Fun and Profit!

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.

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *