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.yml 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
atom_one_light
source
atom_one_light
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
city_lights
source
city_lights
Cobalt2
source
Cobalt2
cyber_punk_neon
source
cyber_punk_neon
darcula
source
darcula
dark_pastels
source

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 Unix filter for command-line that can be used with any list; files, command history, processes, hostnames, bookmarks, git commits etc.

    Pros

    • Portable, no dependencies
    • Blazingly fast
    • The most comprehensive feature set
    • Flexible layout
    • Batteries included
      • Vim/Neovim plugin, key bindings, and fuzzy auto-completion

    Sponsors ❤️

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

    If you'd like to sponsor this project, please visit https://github.com/sponsors/junegunn.

    miyanokomiyaJon GjengsetKyle L. DavisFrederick ZhangMoritz DietzMikkel MalmbergPierre DubouilhRyan Roden-CorrentJordan ArentsenMislav MarohnićAlex ViscreanuDavid BalateroOndrej SynacekMathias Jean JohansenBen ElanPaweł DudaSantiago LezicaTimo SulgSean MortonDamien RajonArtBITHovisDarius JondaCristian DominguezChang-Hung LiangBen Lechlitneryashgeorge looshchTakumi KAGIYAMAPaul O'Leary McCannRobert BeegerVEEB ProjectsKhue DoanYoway BuornJosh ScalisiAlec Scotttheshankthanks.devTamir Zahavi-BrunnerArtur SapekGuillaume GelinNils DiewaldMikki FreemanLukas SchweizerAldo Schumann

    Table of Contents

  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)