# tinty

*Category: CLI Tools | Website: https://github.com/tinted-theming/tinty*

switch your color scheme globally with one command

I recently stumbled upon tinty while looking for a good way to globally switch themes for CLI and TUI applications. I had seen [linkarzu](https://www.youtube.com/@linkarzu) show something like this in one of his videos based on bash scripts. [DHH](https://world.hey.com/dhh) also prominently included a theme switching feature into his flavors of Ubuntu ([omakub](https://omakub.org/)) and more recently, Arch ([omarchy](https://omarchy.org/)). Since I'm using a macbook as my laptop and have Arch Linux running on my desktop, I was trying to find a good solution that worked cross platform. I was originally planning to go the bash route myself but I first went looking for existing solutions. And this is when I discovered [tinty](https://github.com/tinted-theming/tinty)!

## Color me surprised

tinty is a nifty little cli application based around the concept of base16 and base24 color schemes. As the name implies, these are color schemes with 16 or 24 colors respectively. And even though I've been a [catppuccin](https://catppuccin.com/) man like [typecraft](https://www.youtube.com/@typecraft_dev) for a while, I was longing for a fresh coat of paint. And tinty was scratching this itch perfectly! It's fairly young but there is already a growing community contributing to the repos on github.

There is some setup required to get it up and running for all the apps that you're using but once that's done, switching to another theme is just a single command away. What I find most compelling is that tinty ships with over 250 themes, which means you'll never run out of new things to try out. The themes are provided as simple yaml files that just list the hex color codes for each theme. In theory, any application with custom theme support can be adapted to work with tinty. I for one have decided to include tinty support in any graphical application that I'm building.

The way tinty works is simple in principle. When you change to a new theme, all configured applications will automatically change their theme as well. The specific implementation depends on how an application is using themes. For most application, this just means that the theme config file gets automatically updated with the new colors. Tinty knows what to replace in a specific config file  based on mustache template files that have the necessary structure with placeholders for the individual colors. Tinty already supports many terminals and terminal applications like ghostty, alacritty, tmux, vim/neovim and many others. [Here's](https://github.com/tinted-theming/home) a list of all applications that are already supported.

## Setting it up

After installing tinty via a supported package manager or alternative, via cargo install, you need to take care of a few things before you can start theme-hopping. First, you need to edit your configuration, which sits at `~/.config/tinted-theming/tinty/config.toml`. Here is my current config with comments to explain what every entry is doing. Don't worry, it might look like a lot of work but most entries can be copied/installed from the tinty repos:

```toml
# Global settings
shell = "zsh -c '{}'"           # Depending on what shell you use, various examples can be found in the tinty repo
default-scheme = "base16-nord"  # My current default scheme 
preferred-schemes = [           # You can specify a small selection of themes that you can cycle through with 'tinty cycle'
  "base16-nord",
  "base16-catppuccin-frappe",
  "base16-catppuccin-mocha",
  "base16-tokyo-night-dark",
]
# --- Global hook: switch Yazi flavor to the just-applied scheme ---
# A hook in tinty is trigered whenever you switch a theme.
hooks = [
  "echo \"The current scheme is: $(tinty current)\"", # You don't need this but I have kept it for debugging
  # Change sketchybar color
  "BAR_OPACITY=80 UPDATE_RC=1 sketchycolor", # I use sketchybar on Mac and this just triggers a tiny script that changes the color in the skeychybar config
  # Apply theme to lst gui
  "lst themes apply $(tinty current)", # One of my own apps that I have added base16-support to
  # For yazi, I use dasel to replace the theme name in the theme.toml. Make sure you copy/symlink all themes to the yazi config directory
  "dasel put -f ${XDG_CONFIG_HOME:-$HOME/.config}yazi/theme.toml -r toml -t string -v $(tinty current) -s flavor.dark",
  "dasel put -f ${XDG_CONFIG_HOME:-$HOME/.config}yazi/theme.toml -r toml -t string -v $(tinty current) -s flavor.light",
  # I use ppr to generate a new background from svg templates, also an app that I have created
  "ppr switch-current $(tinty current) -w 2>&1 > /dev/null",

]
# From here on, every item is the config for a specific app that has its own tinty-theme repo. Exept for the tmux bottom bar part, everything is just copied from the tinty documentation
# Item configurations
[[items]]
path = "https://github.com/tinted-theming/tinted-terminal"
name = "tinted-terminal"
themes-dir = "themes/ghostty"
hook = "command cp -f %f ~/.config/ghostty/themes/tinted-theming"
supported-systems = ["base16", "base24"]

[[items]]
name = "tinted-shell"
path = "https://github.com/tinted-theming/tinted-shell"
themes-dir = "scripts"
hook = "source %f"
supported-systems = ["base16", "base24"]

[[items]]
path = "https://github.com/tinted-theming/base16-vim" # Important: You need to install the tinty-nvim plugin
name = "base16-vim"
themes-dir = "colors"

[[items]]
name = "tmux"
path = "https://github.com/tinted-theming/tinted-tmux"
themes-dir = "colors"
supported-systems = ["base16", "base24"]

# This hook changes my tmux bottom bar to the right color
hook = '''
setopt NO_NOMATCH

accent="#${TINTY_SCHEME_PALETTE_BASE0D_HEX_R}${TINTY_SCHEME_PALETTE_BASE0D_HEX_G}${TINTY_SCHEME_PALETTE_BASE0D_HEX_B}"
accent_alt="#${TINTY_SCHEME_PALETTE_BASE0A_HEX_R}${TINTY_SCHEME_PALETTE_BASE0A_HEX_G}${TINTY_SCHEME_PALETTE_BASE0A_HEX_B}"
bar_bg="#${TINTY_SCHEME_PALETTE_BASE00_HEX_R}${TINTY_SCHEME_PALETTE_BASE00_HEX_G}${TINTY_SCHEME_PALETTE_BASE00_HEX_B}"

[[ -z "$accent" ]]     && accent="#5e81ac"
[[ -z "$accent_alt" ]] && accent_alt="#a3be8c"
[[ -z "$bar_bg" ]]     && bar_bg="#1e1e1e"

# zsh substring math for luminance
local h=${accent#\#}
local r=$((16#${h[1,2]})) g=$((16#${h[3,4]})) b=$((16#${h[5,6]}))
local lum=$(( (299*r + 587*g + 114*b) / 1000 ))
local pill_fg=$([ $lum -gt 150 ] && echo "#000000" || echo "#ffffff")

if tmux run 2>/dev/null; then
  tmux set -gq @accent "$accent"
  tmux set -gq @accent_alt "$accent_alt"
  tmux set -gq @bar_bg "$bar_bg"
  tmux set -gq @pill_fg "$pill_fg"
  [[ -n "$TINTY_THEME_FILE_PATH" ]] && tmux source-file "$TINTY_THEME_FILE_PATH"
  tmux refresh-client -S
fi
'''
```

After setting up your config, you can run `tinty sync`and tinty will clone all application-specific theme repos and set everything up for you. Now you can run `tinty cycle` to cycle through your preferred schemes, or e.g. `tinty apply base16-nord`for applying a specific theme. If you combine this with fzf you also can fuzzy find a theme and switch to it: `tinty apply $(tinty list | fzf)`


---

*Tags: cli, themes*
*Supported OS: linux, macos*
