How to Add 👉   👈 Padding to the Ubuntu Gnome Terminal#

I often make screen captures of terminal outputs while documenting my work or helping colleagues and was always bothered when its contents were too close to the left border.

Adding padding to the gnome terminal on Ubuntu, and likely any distribution using Gnome, is trivial, as it suffices to edit ~/.config/gtk-3.0/gtk.css.

Seeing as I’ve been wanting to document this for awhile already; going against my “principle of addressing issues as soon as they become an annoyance” once again, I figured I’d just put this note out there.

I haven’t found much information about this particular file in the official Gnome documentation, but there’s some useful conversation surrounding it on the ArchLinux wiki. If you want to delve deeper into what tweaks might be possible, you should have a look at the GTK Supported CSS Properties or even browse the official Gnome GitLab where the GTK CSS parsing code is hosted

If the file doesn’t exist as evidenced by an empty ls ~/.config/gtk-3.0/gtk.css, create it using touch ~/.config/gtk-3.0/gtk.css and put the following into it:

 VteTerminal,
 TerminalScreen,
 vte-terminal {
     padding: 10px 10px 10px 10px;
     -VteTerminal-inner-border: 10px 10px 10px 10px;
 }

In case the contents of ~/.config/gtk-3.0/gtk.css are not valid, the GTK will complain once you try to start a gnome-terminal since it wasn’t able to load the theme file. Make sure you’ve put the content as shown above in the file and save.

../../_images/load-gtk-theme-error.png

Finally, you’ll need to terminate all gnome terminal processes. You’ll often see mention of pkill gnome-terminal online, but gnome-terminal only calls gnome-terminal-server which in turn actually spawns the desired terminal. Therefore, pkill gnome-terminal might be insufficient. If that is the case, find the process identifier of the gnome-terminal-server using ps -fea | grep term and then terminate it using kill <process identifier> as shown below.

../../_images/terminate-gnome-terminal-server-process.png

After you’ve done that, your terminal will have 10px of padding on every border:

../../_images/gnome-terminal-with-padding.png

Final Words#

I hope you enjoyed this short post! Feel free to look at this one where I compare different programming typefaces. As always, don’t hesitate to share your feedback with me via social media or email.