DEV Community

Cover image for alacritty-themes not working any more!!!
HarshalRathore
HarshalRathore

Posted on

alacritty-themes not working any more!!!

Introduction to Alacritty: A Lightweight Terminal Emulator

Alacritty, known for its speed and efficiency, stands out as a lightweight and GPU-accelerated terminal emulator. Striking a balance between simplicity and performance, Alacritty has become a popular choice among users seeking a fast and responsive terminal experience.

Navigating the Transition: From alacritty.yml to alacritty.toml

As Alacritty evolves, so does its configuration. If you don't know before version 0.13.0 (78fa4d6f) alacritty.yml was used as its configuration file. The shift from using alacritty.yml to alacritty.toml brings about a need for users to adapt their customization strategies. In this article, we explore a practical workaround to ensure a seamless transition, specifically addressing the challenge presented by tools like alacritty-themes that were originally tailored for the YAML configuration.

The alacritty-themes was an excellent npm package which as its name suggests was used for theming alacritty. these features made it good at what it was made for

  • Live preview of the themes
  • 200+ Themes to choose from
  • Apply any theme with just one command at the terminal
  • Option to create your alacritty.yml config file
  • Simple, Easy and intuitive User experience

GitHub logo rajasegar / alacritty-themes

🌈 🍭 Themes 🍬 😍 for Alacritty: A cross-platform GPU-accelerated Terminal emulator

🌈 alacritty-themes 🍭

Build and Deploy npm version semantic-release Conventional Commits

Themes 🍬 for alacritty A cross-platform, GPU-accelerated terminal emulator

To find the list of themes, you can visit the alacritty wiki page

  • Live preview the themes
  • 200+ Themes to choose from
  • Apply any theme with just one command at the terminal
  • Option to create your alacritty.toml config file
  • Simple, Easy and intuitive User experience

Install

Install the alacritty-themes package globally with npm

npm i -g alacritty-themes

If you are using npx you don't have to install the package:

npx alacritty-themes

If you are using Archlinux, you can install it from AUR

paru -S alacritty-themes

Usage

alacritty-themes

To apply a theme directly, provide the theme name as an option

alacritty-themes Dracula

To find the themes, you can check the file names here

alacritty-themes demo gif

Choose the theme from the list of options by typing the theme name and press Enter to apply The list of options are cycled through automatically…

But this tool was made for alacritty.yml files and seeing the last commit on it which was 7 months ago as of writing this post, it seems like it will be a while before they fix this problem.

So for this, I found a temporary workaround not as great as the tool.

First, let's move all your alacritty.yml to alacritty.toml for this you'll need to learn toml file format and re-write your entire configuration from yaml to toml, good let's start from the basics. hehe just kidding just run this command



alacritty migrate


Enter fullscreen mode Exit fullscreen mode

Now your alacritty.yml has been converted to alacritty.toml.

Now let's collect some themes we'll use this official alacritty repo of themes collection all are in toml format.

GitHub logo alacritty / alacritty-theme

Collection of Alacritty color schemes

Alacritty Theme

Collection of colorschemes for easy configuration of the Alacritty terminal emulator.

Installation

Imports

Clone the repository, or download the theme of your choice:

# We use Alacritty's default Linux config directory as our storage location here.
mkdir -p ~/.config/alacritty/themes
git clone https://github.com/alacritty/alacritty-theme ~/.config/alacritty/themes
Enter fullscreen mode Exit fullscreen mode

Add an import to your alacritty.toml (Replace {theme} with your desired colorscheme):

import = [
    "~/.config/alacritty/themes/themes/{theme}.toml"
]
Enter fullscreen mode Exit fullscreen mode

Manual

To manually include a colorscheme in an existing alacritty.toml, you just need to copy the entire content of the theme into the root level of your configuration file.

Color Schemes

NAME COLORS
afterglow
source
base16_default_dark
alabaster
source
alabaster
alabaster_dark
source
alabaster_dark
alacritty_0_12
source
alacritty_0_12
argonaut
source
base16_default_dark
ashes_dark
source
base16_ashes_dark
ashes_light
source
base16_ashes_light
atom_one_light
source
atom_one_light
aura
source
aura
ayu_dark
source
ayu_dark
ayu_light
source
ayu_light
baitong
source
baitong
base16_default_dark
source
base16_default_dark
blood_moon
source
blood_moon
bluish bluish
breeze
source
breeze
campbell
source
campbell
carbonfox
source
carbonfox
catppuccin_frappe
source
catppuccin_frappe
catppuccin_latte
source
catppuccin_latte
catppuccin_macchiato
source
catppuccin_macchiato
catppuccin_mocha
source
catppuccin_mocha
challenger_deep
source
challenger_deep
chicago95 chicago95
citylights
source
citylights
Cobalt2
…

Clone this repo where your alacritty.yml file is for it was at ~/.config/alacritty/ so I cloned it there
Use these commands



# We use Alacritty's default Linux config directory as our storage location here.
mkdir -p ~/.config/alacritty/themes
git clone https://github.com/alacritty/alacritty-theme ~/.config/alacritty/themes


Enter fullscreen mode Exit fullscreen mode

Now go to your .bashrc or .zshrc or whatever your configuration file is for your shell environment and create a alias add this line



alias themes="ls ~/.config/alacritty/themes/themes | fzf | xargs -I {} ln -sf ~/.config/alacritty/themes/themes/{} ~/.config/alacritt
y/current_theme.toml && echo "@@@" >> ~/.config/alacritty/alacritty.yml && sed -i '/@@@/d' ~/.config/alacritty/alacritty.yml"



Enter fullscreen mode Exit fullscreen mode

To understand what this command is doing let's break it into 4 parts

  1. ls ~/.config/alacritty/themes/themes This part is just listing the theme files that we git cloned.

  2. The above command's output is piped into fuzzy finder fzf. You can find the installation instructions at

    GitHub logo junegunn / fzf

    🌸 A command-line fuzzy finder

    fzf - a command-line fuzzy finder github-actions

    fzf is a general-purpose command-line fuzzy finder.

    It's an interactive filter program for any kind of list; files, command history, processes, hostnames, bookmarks, git commits, etc. It implements a "fuzzy" matching algorithm, so you can quickly type in patterns with omitted characters and still get the results you want.

    Highlights

    • πŸ“¦ Portable β€” Distributed as a single binary for easy installation
    • ⚑ Blazingly fast β€” Highly optimized code instantly processes millions of items
    • πŸ› οΈ Extremely versatile β€” Fully customizable via an event-action binding mechanism
    • πŸ”‹ Batteries included β€” Includes integration with bash, zsh, fish, Vim, and Neovim

    Sponsors ❀️

    I would like to thank all the sponsors of this project who make it possible for me to continue to improve fzf.

    If…



  3. Now the output of fuzzy finder is piped into xargs -I {} ln -sf ~/.config/alacritty/themes/themes/{} ~/.config/alacritt

    y/current_theme.toml
    This is creating a symbolic link at ~/.config/alacritty/current_theme.toml for the theme file that you selected in fuzzy finder like if you selected gruvbox.toml in fzf it'll create a symbolic link for ~/.config/alacritty/themes/themes/gruvbox.toml to here ~/.config/alacritty/current_theme.toml.

  4. The last part is this echo "@@@" >> ~/.config/alacritty/alacritty.yml && sed -i '/@@@/d' ~/.config/alacritty/alacritty.yml this is just appending a @@@ string at the end of the alacritty.toml file and removing it I'll tell you the reason for this later.

okay now you just need to add this line to your alacritty.toml file



import = [
    "~/.config/alacritty/current_theme.toml"
]


Enter fullscreen mode Exit fullscreen mode

Remove any color scheme in your toml file because if there is already manual color scheme the import of the theme file will not work. All should work now just enter your alias command > choose the theme > press enter and that's it.

Now to explain the reason for the 4 part is that remember we created a symbolic link at ~/.config/alacritty/current_theme.toml for the theme file we'll select and have added an entry of importing it in alacritty but as you'll run the complete command you will not see any color scheme change that is because you have changed the content of current_theme.toml (more specifically it's redirection location) not the content of alacritty.toml and alacritty only refreshes if it detects any changes in it's configuration file the complete command (the 4th part) cause some change in file by adding @@@ and removing it next so the color scheme refreshes.

Top comments (0)