Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

A Terminal, tmux, Vim and FZF Theme Switching Script written in Python

a-terminal-tmux-vim-and-fzf-theme-switching-script-written-in-python.jpg

We'll go over a zero dependency Python 3 script to quickly change themes and toggle dark / light mode for various command line tools.

Quick Jump:

After 2 years of using Gruvbox and 1 year of using One I decided it was time to switch back to using Gruvbox for now. I realized it was kind of a pain to update a bunch of color values in a few config files so I spent a few hours whipping up a script to switch themes.

Back in mid-2020 I created a toggle-dark-mode script but it only supported one theme. This new set-theme script is a successor to this script.

In this video we’ll go over how it works, how to customize it for other themes and also go over a bit of the Python code along the way.

# Going Over the Script

Timestamps

  • 0:07 – Quickly change your theme with this script
  • 0:58 – I’m going back to Gruvbox and it was tedious to change everything manually
  • 1:58 – Installing this set-theme script with or without my dotfiles
  • 3:11 – Adding a custom theme to the script
  • 8:36 – Modifying the script to use a different terminal instead of the Microsoft Terminal
  • 11:42 – Adding the Gruvbox theme to the Microsoft Terminal
  • 12:40 – Why there’s a 1 second sleep in the set-theme script
  • 15:17 – Did you add a custom theme? Please open a pull request

Commands Run

set-theme gruvbox
set-theme gruvbox --toggle-bg

set-theme one
set-theme one --toggle-bg

Important Updates

There’s been at least 1 update to the script since I recorded this video.

January 25th 2021

The set-theme script was updated to avoid needing the 1 second sleep. This ended up being a pretty big refactor of the script thanks to an amazing pull request from someone who watched the above video.

The instructions mentioned at 11:42 in the video no longer match the script if you want to use a different terminal.

The documentation has been updated to reflect the new changes. I’m sure you’ll have no problem applying it based on this video + the updated docs.

Reference Links

Are you going to use this script to manage your terminal themes? Let us know below.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments