19 December 2022

Host Your GIFs with VHS

By Maas Lalani

VHS now ships with automatic GIF hosting making it easy to share your VHS creations with your friends, foes, coworkers, and the internet. To publish your GIFs just add the --publish flag.

vhs --publish demo.tape

But first things first.

VHS? What’s that?

In case you missed it, VHS is a tool that generates GIFs and videos of terminal GIFs from code. To generate a GIF with VHS, you write a simple .tape file, which instructs VHS how to interact with the terminal, and pass it into the vhs binary.

Here’s what a .tape file could look like:

# Where should we write the GIF?
Output demo.gif

# Set up a 1200x600 terminal with 46px font.
Set FontSize 46
Set Width 1200
Set Height 600

# Type a command in the terminal.
Type "echo 'Welcome to VHS!'"

# Pause for dramatic effect...
Sleep 500ms

# Run the command by pressing enter.

# Admire the output for a bit.
Sleep 5s

Once you have written your .tape file, just pass it to VHS:

vhs < demo.tape

Voilà! VHS will output a shiny terminal GIF entirely generated from the code you wrote!

Render of demo.gif

Publishing GIFs

We wanted to make sharing terminal GIFs with VHS as easy as creating them, so we’re pleased to introduce vhs --publish.

When you add the --publish flag, VHS will host your GIF on vhs.charm.sh and provide you with a URL that you can share with your fellow command-line dwellers.

So this…

vhs --publish demo.tape

Will output this…


…which will then be available at a URL like https://vhs.charm.sh/vhs-6bx5XJGgNmJLVmvicnXJ9i.gif.

And if you forgot to pass the --publish flag while creating your GIF, worry not. You can use vhs publish to host the GIF even after it’s already been generated:

vhs publish demo.gif

Bonus: Home Video Recording

Want to play around with vhs --publish right now but don’t have any .tape files laying around? Say hello to vhs record.

vhs record, a relatively new feature, will record your terminal activity and write the output into a tape file, almost like magic.

vhs record > file.tape
# perform actions, do stuff...
vhs file.tape --publish

We hope that VHS makes it easy for you to record and share your terminal applications with others. We love seeing your terminal GIFs and you’re always welcome to share them with us.

And, as always, let us know if you have any feedback.


Read this post in your terminal with Glow:

glow -p https://charm.sh/blog/vhs-publish.md Copied!

By Maas Lalani

19 December 2022

Maas is a software developer at Charm who helped build VHS. He hacks on command line tools for work and also for fun.

Lets chat!

Have a question about a command line thing you’re building? Got an idea for a new feature? Just wanna hang out? You’re always welcome in the Charm Discord.