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
ortheme.sh --lght --list
. You can also search for a specific theme. Exampletheme.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.