An Interactive Terminal-Agnostic Theme Selection Script

I don’t know about you, but I think that the default look of the terminal is not always the best. And that’s valid if you’re running Linux or macOS.
Sure, some Linux distros apply themes out of the box to the terminal and might switch the shell from bash to zsh, but you always look to rice it up and make it your own.

Now, that might be time consuming if you don’t know exactly what you’re looking for. But there are workarounds that allow you to easily search and apply themes to your terminal.

For example, if you’re using Alacritty you can easily search and apply themes with alacritty-themes. But what if you’re using st, or gnome-terminal, or Terminal.app on macOS? There’s a script for that: themes.sh

The script comes with more than 400 themes, an interactive theme picker, and it’s terminal agnostic.

NOTE: just like it’s not advised to blindly copy-paste terminal commands you find on the internet, the same way it’s not advised to run a random script. Click on the theme.sh link above to go to the GitHub page and check the script before using it.

Supported Terminals

  • kitty (not KiTTY)
  • gnome-terminal
  • terminator
  • st
  • Terminal.app (osx)
  • iTerm2
  • alacritty
  • urxvt (non interactively unless the truecolor patch is applied)
  • any libvte based terminal

Installation

  • If you’re using Arch ( or an Arch based distro ) you can find theme.sh and theme.sh-git in the AUR
  • If you’re using any other distro use:
    sudo curl -Lo /usr/bin/theme.sh 'https://git.io/JM70M' && sudo chmod +x /usr/bin/theme.sh
  • If you’re using macOS use: sudo curl -Lo /usr/local/bin/theme.sh 'https://git.io/JM70M' && sudo chmod +x /usr/local/bin/theme.sh


Usage

Once theme.sh is installed you have a few options through which you can search and apply a theme to your terminal:

  • if you know the exact theme you want to apply you can do that with theme.sh theme. Example: theme.sh dracula
  • you can display a list of available dark or light themes with theme.sh --dark --list or theme.sh --lght --list. You can also search for a specific theme. Example theme.sh --dark --list | grep dracula
  • use the interactive theme selection by running theme.sh -i. NOTE: this requires fzf to be installed.


Configuration

If you use the script as is, you will apply the theme only to the current session or tab/window. If you restart your Terminal or open a new tab/window your Terminal will use the previous theme.

To apply the last selected theme to all new seassions you’ll have to edit your shell config file. To do that, edit ~/.bashrc or ~/.zshrc ( depending on what shell you’re using ) and add the following code to the end of the file:

if command -v theme.sh > /dev/null; then
	[ -e ~/.theme_history ] && theme.sh "$(theme.sh -l|tail -n1)"

	# Optional

	# Bind C-o to the last theme.
	last_theme() {
		theme.sh "$(theme.sh -l|tail -n2|head -n1)"
	}

	zle -N last_theme
	bindkey '^O' last_theme

	alias th='theme.sh -i'

	# Interactively load a light theme
	alias thl='theme.sh --light -i'

	# Interactively load a dark theme
	alias thd='theme.sh --dark -i'
fi

If you’re using Fish, add the following code to the end of ~/.config/fish/config.fish:

if type -q theme.sh
	if test -e ~/.theme_history
	theme.sh (theme.sh -l|tail -n1)
	end

	# Optional
	# Bind C-o to the last theme.
	function last_theme
		theme.sh (theme.sh -l|tail -n2|head -n1)
	end

	bind \co last_theme

	alias th='theme.sh -i'

	# Interactively load a light theme
	alias thl='theme.sh --light -i'

	# Interactively load a dark theme
	alias thd='theme.sh --dark -i'
end

For more info and troubleshooting, check out the project’s page on GitHub.



LATEST ARTICLES



SUPPORT

We don't think that using an adblocker = piracy. That's simply not true. We use and recommend uBlock Origin.

However, as a small non-corporate website, we would appreciate it if you'd consider whitelisting FSM in your adblock of choice.

Alternatively, consider donating using the options below....

PayPal  
Monero (XMR) 43GnqUNJrTi9QyL7kEH8vM8pgWGCE6bjv1FSRipeNMM4TTeNnUVsRBb6MfMpQYxtLE7ReonxVVSXz2rFCEdW5H11LC3x73b
Bitcoin (BTC) 1Hfuq77gKKFJeNcq4EP4dQK3yDRWrFEwJR
Bitcoin Cash (BCH) qzmdm6e6q5wf2p6sxz2mst7cenz60newwc5m4e9js8
Ether (ETH) 0x5f02869278C24A6579d3820f52AD15936D6F9d69
Stellar (XLM) GDWT2QU2CI3GZ5XH5DTSU3IUAHZMTB6VQKKRHBYWS5YCCQOAG6OKG2OB
More content?  
Ads Blocker Image Powered by Code Help Pro

Congrats on using an adblocker. We mean it.

Please support us by disabling your AdBlocker or whitelist us.

Thank you! ❤️