toggle-corp / alacritty-colorscheme Goto Github PK
View Code? Open in Web Editor NEWChange colorscheme of alacritty with ease.
License: Apache License 2.0
Change colorscheme of alacritty with ease.
License: Apache License 2.0
Hey there, I like your script. Is there a way to add support for bat somehow? When I have a light theme enabled bat still uses white letters, which aren't visible then...
This can be done by exporting BAT_THEME
as described in the help/man.
Would be nice!
If I start the program, it crashes with an AttributeError. This is because of a failed import of tap, see issue swansonk14/typed-argument-parser#55.
I worked around it by changing my installed tap:
--- tap.py.orig 2021-06-06 23:22:00.000000000 +0200
+++ tap.py 2021-06-06 23:19:41.000000000 +0200
@@ -32,7 +32,8 @@
# Constants
-EMPTY_TYPE = get_args(List)[0] if len(get_args(List)) > 0 else tuple()
+# EMPTY_TYPE = get_args(List)[0] if len(get_args(List)) > 0 else tuple()
+EMPTY_TYPE = tuple()
BOXED_COLLECTION_TYPES = {List, list, Set, set, Tuple, tuple}
OPTIONAL_TYPES = {Optional, Union}
BOXED_TYPES = BOXED_COLLECTION_TYPES | OPTIONAL_TYPES
Please consider releasing this under a license so potential users will be clear on the terms of use and copying.
$ alacritty-colorscheme -C ~/alacritty-theme/themes -l
base16_default_dark.yaml
challenger_deep.yaml
darcula.yaml
dracula.yaml
falcon.yaml
gruvbox_dark.yaml
gruvbox_light.yaml
high_contrast.yaml
hyper.yaml
iterm.yaml
low_contrast.yaml
material_theme.yaml
nord.yaml
one_dark.yaml
papercolor_light.yaml
pencil_dark.yaml
pencil_light.yaml
snazzy.yaml
solarized_dark.yaml
solarized_light.yaml
taerminal.yaml
terminal_app.yaml
tomorrow_night.yaml
tomorrow_night_bright.yaml
wombat.yaml
xterm.yaml
$ alacritty-colorscheme -C ~/alacritty-theme/themes -T
Bad configuration file.
We can avoid manually adding markers for color section if we can parse yaml config.
Config file contains following information (dict):
{
"cursor" : {
"style" : "Beam"
},
"font" : {
"bold" : {
"family" : "DejaVu Sans Mono for Powerline",
"style" : "bold"
},
"italic" : {
"family" : "DejaVu Sans Mono for Powerline",
"style" : "italic"
},
"normal" : {
"family" : "DejaVu Sans Mono for Powerline"
},
"size" : 10
},
"shell" : {
"args" : [
"-l"
],
"program" : "/bin/fish"
}
}
Executing:
alacritty-colorscheme -C /home/mono/.config/alacritty/alacritty-theme/themes -t solarized_light.yaml solarized_dark.yaml
Results in:
Traceback (most recent call last):
File "/home/mono/.local/bin/alacritty-colorscheme", line 8, in <module>
sys.exit(main())
File "/home/mono/.local/lib/python3.8/site-packages/alacritty_colorscheme/cli.py", line 235, in main
replace_colorscheme(colors_path, args.config_file,
File "/home/mono/.local/lib/python3.8/site-packages/alacritty_colorscheme/cli.py", line 155, in replace_colorscheme
if config_yaml['colors']:
File "/usr/lib/python3.8/site-packages/ruamel/yaml/comments.py", line 753, in __getitem__
return ordereddict.__getitem__(self, key)
KeyError: 'colors'
Issue here:
It should be catched via try / except KeyError instead of "if" (this would be the pythonic way)
As said :)
Here is info from the newest version (arch linux , fully updated)
Created log file at "/tmp/Alacritty-34233.log"
[0.000005726s] [INFO ] [alacritty] Welcome to Alacritty
[0.000069480s] [INFO ] [alacritty] Version 0.13.0 (78fa4d6f)
[0.000079388s] [INFO ] [alacritty] Running on X11
[0.000557672s] [INFO ] [alacritty] Configuration files loaded from:
"/home/emil/.config/alacritty/alacritty.toml"
[0.012437660s] [INFO ] [alacritty] Using GLX 1.4
I followed the instructions at PyPi to successfully install the programme. I would also like to synchronise vim. I started by installing the base16-vim
plug-in, adding the following snipets to .vimrc
:
" Base16 colour schemes
Plugin 'chriskempson/base16-vim'
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256 " Remove this line if not necessary
source ~/.vimrc_background
endif
After which :VundleInstall
completed successfully.
Then I generated the ~/.vimrc_background
file:
$ alacritty-colorscheme -C ~/.config/alacritty/colors -V apply base16-tomorrow-night-256.yml
$ cat ~/.vimrc_background
if !exists('g:colors_name') || g:colors_name != 'base16-tomorrow-night-256'
colorscheme base16-tomorrow-night-256
But then vim
complains at startup:
$ vim
Error detected while processing /home/duque004/.vimrc[51]../home/duque004/.vimrc_background:
line 2:
E185: Cannot find color scheme 'base16-tomorrow-night-256'
Press ENTER or type command to continue
It looks some configuration step is missing, but I do not know which.
Thank you.
The file vim.py
contains the following code:
folders = [f for f in listdir('/tmp') if f.startswith('nvim')]
On MacOS, there are no files in /tmp
that start with nvim
while nvim is running. Instead, the socket file is in /var/folders/40/[REDACTED]/T/nvimegTUh6/0
. This means the script fails to detect neovim instances. This directory happens to be in the TMPDIR
environment variable. The following change fixed the problem for me:
--- vim.py.orig 2021-06-07 08:19:43.000000000 +0200
+++ vim.py 2021-06-07 08:21:15.000000000 +0200
@@ -1,4 +1,4 @@
-from os import listdir
+from os import listdir, environ
from os.path import join
from pynvim import attach
@@ -14,11 +14,12 @@
def _get_all_instances():
instances = []
- folders = [f for f in listdir('/tmp') if f.startswith('nvim')]
+ tmpdir = environ.get('TMPDIR','/tmp')
+ folders = [f for f in listdir(tmpdir) if f.startswith('nvim')]
for folder in folders:
- dc = listdir(join('/tmp', folder))
+ dc = listdir(join(tmpdir, folder))
if '0' in dc:
- instances.append(join('/tmp', folder, '0'))
+ instances.append(join(tmpdir, folder, '0'))
return instances
It doesn't matter which command I execute, or rather try to. I always get an error message that says:
TypeError: 'NoneType' object is not subscriptable
Listing the installed themes works, when I go to apply one though this happens:
blink@rosie:~$ alacritty-colorscheme -a pencil_dark.yaml
Traceback (most recent call last):
File "/home/blink/.local/bin/alacritty-colorscheme", line 8, in <module>
sys.exit(main())
File "/home/blink/.local/lib/python3.8/site-packages/alacritty_colorscheme/cli.py", line 226, in main
replace_colorscheme(colors_path, args.config_file,
File "/home/blink/.local/lib/python3.8/site-packages/alacritty_colorscheme/cli.py", line 155, in replace_colorscheme
if config_yaml['colors']:
TypeError: 'NoneType' object is not subscriptable
I just tried using this and despite a bit confusing README, usage is very simple, except for the fact that some themes have .yaml extension and some have .yml extension, and I don't want to remember which one has which, or type whole path by hand, so for myself I just stripped extensions from theme filenames and it works, but for everyone else I believe that it would be nice to be able to change theme without having to specify extension, it seems easy to add this without having to change much else in code.
I believe I have followed the steps in the readme correctly, but neovim is still not using alacritty's settings. I have cloned the aaron-williamson-alacritty-theme repo into my home directory.
alacritty-colorscheme -C ~/.aaron-williamson-alacritty-theme/colors/ -a base16-gruvbox-dark-hard-256.yml
works as expected. However, when adding the -V
option to the last command, neovim states the following errors:
Error detected while processing /home/dominic/.vimrc_background:
line 2:
E185: Cannot find color scheme 'base16-gruvbox-dark-hard-256'
Error detected while processing function lightline#update[5]..lightline#colorscheme[12]..lightl
ine#highlight:
line 18:
E421: Colour name or number not recognised: ctermfg= ctermbg= term=bold cterm=bold gui=bold
Error detected while processing function lightline#update:
line 5:
E171: Missing :endif
I have installed neovim-remote
and I have also added the following to my init.vim
:
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256 " Remove this line if not necessary
source ~/.vimrc_background
endif
and these lines to my .bashrc
:
function reload_nvim {
for SERVER in $(nvr --serverlist); do
nvr -cc "source ~/.config/nvim/init.vim" --servername $SERVER &
done
}
COLOR_DIR="$HOME/.aaron-williamson-alacritty-theme/colors"
LIGHT_COLOR='base16-gruvbox-light-soft.yml'
DARK_COLOR='base16-gruvbox-dark-soft.yml'
alias day="alacritty-colorscheme -C $COLOR_DIR -a $LIGHT_COLOR -V && reload_nvim"
alias night="alacritty-colorscheme -C $COLOR_DIR -a $DARK_COLOR -V && reload_nvim"
The day/night snippets are not working, unfortunately.
Having just done pip install alacritty-colorscheme
and nothing else, running alacritty-colorscheme -l
produces the following output.
> alacritty-colorscheme -l
Traceback (most recent call last):
File "/home/jscdev/bin/alacritty-colorscheme", line 8, in <module>
sys.exit(main())
File "/home/jscdev/.local/lib/python3.8/site-packages/alacritty_colorscheme/cli.py", line 218, in main
files = get_files_in_directory(args.colorscheme_dir)
File "/home/jscdev/.local/lib/python3.8/site-packages/alacritty_colorscheme/cli.py", line 101, in get_files_in_directory
onlyfiles = [f for f in (listdir(expanded_path))
FileNotFoundError: [Errno 2] No such file or directory: '/home/jscdev/.config/alacritty/colors/'
The version installed by pip is 0.2.1.
Obviously, this bug is incredibly minor, and has no practical effect on the user, but I thought it would probably be worth reporting it anyway.
Hi,
When calling cli.py from python 3.9 on MacOS, I get the error below:
Traceback (most recent call last):
File "/Users/noahgaertner/Library/Python/3.9/lib/python/site-packages/alacritty_colorscheme/cli.py", line 9, in <module>
from . import __version__
ImportError: attempted relative import with no known parent package
How do I fix this? Is it a bug that's 3.9 specific?
I'm on Ubuntu 18.04 and installed the package with pip3 install --user alacritty-colorscheme
[I] ➜ alacritty-colorscheme -l | grep nord
nord.yaml
But:
[I] ➜ alacritty-colorscheme -a nord.yaml
Traceback (most recent call last):
File "/home/glaux/.local/bin/alacritty-colorscheme", line 11, in <module>
sys.exit(main())
File "/home/glaux/.local/lib/python3.6/site-packages/alacritty_colorscheme/cli.py", line 195, in main
args.colorscheme, args.base16_vim)
File "/home/glaux/.local/lib/python3.6/site-packages/alacritty_colorscheme/cli.py", line 143, in replace_colorscheme
config_yaml['colors'].update(colors_yaml['colors'])
File "/home/glaux/.local/lib/python3.6/site-packages/ruamel/yaml/comments.py", line 753, in __getitem__
return ordereddict.__getitem__(self, key)
KeyError: 'colors'
Here is my nord.yml
. I have added the surrounding # color_start/end
according to #6
# color_start
colors:
# Default colors
primary:
background: '0x2E3440'
foreground: '0xD8DEE9'
# Normal colors
normal:
black: '0x3B4252'
red: '0xBF616A'
green: '0xA3BE8C'
yellow: '0xEBCB8B'
blue: '0x81A1C1'
magenta: '0xB48EAD'
cyan: '0x88C0D0'
white: '0xE5E9F0'
# Bright colors
bright:
black: '0x4C566A'
red: '0xBF616A'
green: '0xA3BE8C'
yellow: '0xEBCB8B'
blue: '0x81A1C1'
magenta: '0xB48EAD'
cyan: '0x8FBCBB'
white: '0xECEFF4'
# color_end
alacritty-colorscheme/pyproject.toml
Line 24 in e7b9866
timothy@yoga ~/.c/alacritty> alacritty-colorscheme list
Traceback (most recent call last):
File "/home/timothy/.local/bin/alacritty-colorscheme", line 6, in <module>
from alacritty_colorscheme.cli import main
File "/home/timothy/.local/lib/python3.7/site-packages/alacritty_colorscheme/cli.py", line 5, in <module>
from typing import List, Optional, Literal, cast
ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)
https://stackoverflow.com/questions/61206437/importerror-cannot-import-name-literal-from-typing
Calling the -V
option generates a .vimrc_background
which does not take into account that the base16-vim doesn't use -256
naming convention, but the let base16colorspace=256
option. Striping "-256"
from the name would fix that. Something like this?
For example:
alacritty-colorscheme -V apply base16-onedark-256.yml
needs a colorscheme base16-onedark
, not colorscheme base16-onedark-256
Happens on 1.0.1 arch
Hi, so I just installed this, on an up-to-date manjaro linux distro.
pip install --user alacritty-colorscheme
colorschemes:
REPO=https://github.com/eendroroy/alacritty-theme.git
git clone $REPO $HOME/.config/alacritty/colors
but when I run
alacritty-colorscheme -V toggle
No colorscheme is changing, and this is the output from terminal:
Traceback (most recent call last):
File "/home/emil/.local/bin/alacritty-colorscheme", line 8, in
sys.exit(main())
File "/home/emil/.local/lib/python3.10/site-packages/alacritty_colorscheme/cli.py", line 158, in main
handle_args(args)
File "/home/emil/.local/lib/python3.10/site-packages/alacritty_colorscheme/cli.py", line 121, in handle_args
colorscheme = get_applied_colorscheme(args.config_file)
File "/home/emil/.local/lib/python3.10/site-packages/alacritty_colorscheme/colorscheme.py", line 32, in get_applied_colorscheme
has_comment = _has_comment_token(config_yaml['colors'].ca.comment)
TypeError: 'NoneType' object is not subscriptable
Not really sure what to do about that - I emptied my alacritty.yml just to make sure that something wasn't interferring (at first I got an error because I already had a section in the yaml defining colorschemes)
Traceback (most recent call last):
File "/home/ac/.local/bin/alacritty-colorscheme", line 8, in <module>
sys.exit(main())
File "/home/ac/.local/lib/python3.10/site-packages/alacritty_colorscheme/cli.py", line 158, in main
handle_args(args)
File "/home/ac/.local/lib/python3.10/site-packages/alacritty_colorscheme/cli.py", line 147, in handle_args
replace_colorscheme(colors_path, args.config_file,
File "/home/ac/.local/lib/python3.10/site-packages/alacritty_colorscheme/colorscheme.py", line 72, in replace_colorscheme
config_yaml['colors'].update(colors_yaml['colors'])
TypeError: 'NoneType' object is not subscriptable
@eendroroy @tnagorra
Guys, it would be awesome to see color changing script with a bunch of themes together!
Consider uniting the efforts somehow:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.