1
0
Fork 0

Improve colorscheme for Kitty

main
Ambrose Chua 2020-11-07 12:00:52 +08:00
parent cb957d3b74
commit 07f03b97d9
12 changed files with 246 additions and 215 deletions

View File

@ -1 +1 @@
colorscheme.dark.conf
colorscheme.greyscale-dark.conf

View File

@ -1,26 +1,22 @@
cursor #a3a3a3
cursor_text_color background
foreground #999999
background #202020
selection_foreground #a3a3a3
selection_background #606060
color0 #2d2d2d
cursor_text_color #073642
cursor #839496
foreground #839496
background #002b36
selection_foreground #93a1a1
selection_background #073642
color0 #073642
color1 #dc322f
color2 #859900
color3 #b58900
color4 #268bd2
color5 #d33682
color6 #2aa198
color7 #f0f0f0
color7 #eee8d5
color8 #002b36
color9 #cb4b16
color8 #202020
color10 #606060
color11 #6d6d6D
color12 #999999
color10 #586e75
color11 #657b83
color12 #839496
color13 #6c71c4
color14 #a3a3a3
color15 #ffffff
color14 #93a1a1
color15 #fdf6e3

View File

@ -1,42 +1,136 @@
#!/usr/bin/env python
def parse_line(line):
cleaned = line.strip()
split = cleaned.split(maxsplit=1)
if not split:
return None, None
if len(split) < 2:
return split[0], None
return split
import sys
import re
def parse_variables(section):
parsed = {}
with open("colorscheme.variables.conf", "r") as f:
current_section = None
for line in f:
key, value = parse_line(line)
if key == "!":
current_section = value
COLORSCHEMES = {
"dark": {
"theme": "solarized",
"palette": "solarized",
"cursor_text_color": "{base02}",
"cursor": "{base0}",
"foreground": "{base0}",
"background": "{base03}",
"selection_foreground": "{base1}",
"selection_background": "{base02}",
},
"light": {
"theme": "solarized",
"palette": "solarized",
"cursor_text_color": "{base2}",
"cursor": "{base00}",
"foreground": "{base00}",
"background": "{base3}",
"selection_foreground": "{base01}",
"selection_background": "{base2}",
},
"greyscale-dark": {
"theme": "solarized",
"palette": "solarized-greyscale",
"cursor_text_color": "{base02}",
"cursor": "{base0}",
"foreground": "{base0}",
"background": "{base03}",
"selection_foreground": "{base1}",
"selection_background": "{base02}",
},
"greyscale-light": {
"theme": "solarized",
"palette": "solarized-greyscale",
"cursor_text_color": "{base2}",
"cursor": "{base00}",
"foreground": "{base00}",
"background": "{base3}",
"selection_foreground": "{base01}",
"selection_background": "{base2}",
},
}
THEMES = {
"solarized": {
"color0": "{base02}",
"color1": "{red}",
"color2": "{green}",
"color3": "{yellow}",
"color4": "{blue}",
"color5": "{magenta}",
"color6": "{cyan}",
"color7": "{base2}",
"color8": "{base03}",
"color9": "{orange}",
"color10": "{base01}",
"color11": "{base00}",
"color12": "{base0}",
"color13": "{violet}",
"color14": "{base1}",
"color15": "{base3}",
},
}
TABLE_HEADER = """
" SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B sRGB HSB
" --------- ------- ---- ------- ----------- ---------- ----------- -----------
""".strip().split(
"\n"
)
def read_table(f):
match_window = []
# Read until we find the table header
for line in f:
line = line.strip()
match_window.append(line)
if len(match_window) <= len(TABLE_HEADER):
continue
match_window.pop(0)
if match_window == TABLE_HEADER:
break
# Read table
for line in f:
parts = [p for p in re.split("[ \"']+", line) if len(p) > 0]
if len(parts) < 3:
break
yield (parts[0], parts[1])
def read_palette(filename):
palette = {}
with open(filename, "r") as f:
for name, value in read_table(f):
palette[name] = value
return palette
PALETTES = {
"solarized": read_palette("../../.config/nvim/colors/solarized.vim"),
"solarized-greyscale": {
**read_palette("../../.config/nvim/colors/solarized.vim"),
**{
"base03": "#202020",
"base02": "#2d2d2d",
"base01": "#606060",
"base00": "#6d6d6d",
"base0": "#969696",
"base1": "#a0a0a0",
"base2": "#eaeaea",
"base3": "#f9f9f9",
},
},
}
for name, scheme in COLORSCHEMES.items():
theme = THEMES[scheme["theme"]]
palette = PALETTES[scheme["palette"]]
with open(f"colorscheme.{name}.conf", "w") as f:
for name, value in scheme.items():
if name in ("theme", "palette"):
continue
if current_section == section:
parsed[key] = value
del parsed[None]
return parsed
common = parse_variables("Common")
for scheme in ("Dark", "Light"):
variables = parse_variables(scheme)
with open("colorscheme.template.conf", "r") as f:
template = f.read()
rewritten = template
for key, value in variables.items():
rewritten = rewritten.replace(key, value)
for key, value in common.items():
rewritten = rewritten.replace(key, value)
save_as = "colorscheme.{}.conf".format(scheme.lower())
with open(save_as, "w") as f:
f.write(rewritten)
s = f"{name} {value.format(**palette)}\n"
f.write(s)
for name, value in theme.items():
s = f"{name} {value.format(**palette)}\n"
f.write(s)

View File

@ -0,0 +1,22 @@
cursor_text_color #2d2d2d
cursor #969696
foreground #969696
background #202020
selection_foreground #a0a0a0
selection_background #2d2d2d
color0 #2d2d2d
color1 #dc322f
color2 #859900
color3 #b58900
color4 #268bd2
color5 #d33682
color6 #2aa198
color7 #eaeaea
color8 #202020
color9 #cb4b16
color10 #606060
color11 #6d6d6d
color12 #969696
color13 #6c71c4
color14 #a0a0a0
color15 #f9f9f9

View File

@ -0,0 +1,22 @@
cursor_text_color #eaeaea
cursor #6d6d6d
foreground #6d6d6d
background #f9f9f9
selection_foreground #606060
selection_background #eaeaea
color0 #2d2d2d
color1 #dc322f
color2 #859900
color3 #b58900
color4 #268bd2
color5 #d33682
color6 #2aa198
color7 #eaeaea
color8 #202020
color9 #cb4b16
color10 #606060
color11 #6d6d6d
color12 #969696
color13 #6c71c4
color14 #a0a0a0
color15 #f9f9f9

View File

@ -1,26 +1,22 @@
cursor #606060
cursor_text_color background
foreground #6d6d6d
background #dfdfdf
selection_foreground #606060
selection_background #9d9d9d
color0 #2d2d2d
cursor_text_color #eee8d5
cursor #657b83
foreground #657b83
background #fdf6e3
selection_foreground #586e75
selection_background #eee8d5
color0 #073642
color1 #dc322f
color2 #859900
color3 #b58900
color4 #268bd2
color5 #d33682
color6 #2aa198
color7 #f0f0f0
color7 #eee8d5
color8 #002b36
color9 #cb4b16
color8 #202020
color10 #606060
color11 #6d6d6D
color12 #999999
color10 #586e75
color11 #657b83
color12 #839496
color13 #6c71c4
color14 #a3a3a3
color15 #ffffff
color14 #93a1a1
color15 #fdf6e3

View File

@ -1,26 +0,0 @@
cursor S_base1
cursor_text_color background
foreground S_base0
background S_base03
selection_foreground S_base1
selection_background S_base01
color0 S_base02
color1 S_red
color2 S_green
color3 S_yellow
color4 S_blue
color5 S_magenta
color6 S_cyan
color7 S_base2
color9 S_orange
color8 S_base03
color10 S_base01
color11 S_base00
color12 S_base0
color13 S_violet
color14 S_base1
color15 S_base3

View File

@ -1,90 +0,0 @@
! Common
S_yellow #b58900
S_orange #cb4b16
S_red #dc322f
S_magenta #d33682
S_violet #6c71c4
S_blue #268bd2
S_cyan #2aa198
S_green #859900
! Dark
S_base03 #353535 ! 0x15
S_base03 #202020
S_base02 #424242
S_base02 #2d2d2d
S_base01 #757575
S_base01 #606060
S_base00 #828282
S_base00 #6d6d6D
S_base0 #969696 ! 0x3
S_base0 #999999
S_base1 #a0a0a0
S_base1 #a3a3a3
S_base2 #ededed
S_base2 #f0f0f0
S_base3 #fcfcfc
S_base3 #ffffff
! Light-Alt
S_base03 #fcfcfc ! 0x3
S_base03 #f9f9f9
S_base02 #ededed
S_base02 #eaeaea
S_base01 #a0a0a0
S_base01 #9d9d9d
S_base00 #969696
S_base00 #939393
S_base0 #828282 ! 0x15
S_base0 #6d6d6d
S_base1 #757575
S_base1 #606060
S_base2 #424242
S_base2 #2d2d2d
S_base3 #353535
S_base3 #202020
! Light
S_base03 #fcfcfc ! 0x1d
S_base03 #dfdfdf
S_base02 #ededed
S_base02 #eaeaea
S_base01 #a0a0a0
S_base01 #9d9d9d
S_base00 #969696
S_base00 #939393
S_base0 #828282 ! 0x15
S_base0 #6d6d6d
S_base1 #757575
S_base1 #606060
S_base2 #424242
S_base2 #2d2d2d
S_base3 #353535
S_base3 #202020
! Solarized-Dark
S_base03 #002b36
S_base02 #073642
S_base01 #586e75
S_base00 #657b83
S_base0 #839496
S_base1 #93a1a1
S_base2 #eee8d5
S_base3 #fdf6e3
! Solarized-Light
S_base03 #fdf6e3
S_base02 #eee8d5
S_base01 #93a1a1
S_base00 #839496
S_base0 #657b83
S_base1 #586e75
S_base2 #073642
S_base3 #002b36

20
.config/kitty/fontawesome.generate.py Normal file → Executable file
View File

@ -1,29 +1,31 @@
#!/usr/bin/env python
import json
import sys
if len(sys.argv) == 1:
print('Usage: {} fontawesome_icons.json'.format(sys.argv[0]))
print("Usage: {} fontawesome_icons.json".format(sys.argv[0]))
sys.exit(1)
with open(sys.argv[1], 'r') as f:
with open(sys.argv[1], "r") as f:
obj = json.load(f)
points = []
points_brands = []
for icon, data in obj.items():
styles = data['styles']
u = data['unicode']
ufmt = 'U+{}'.format(u.upper())
styles = data["styles"]
u = data["unicode"]
ufmt = "U+{}".format(u.upper())
if "brands" in styles:
points_brands.append(ufmt)
continue
points.append(ufmt)
pointsfmt = ','.join(points)
configline = 'symbol_map {} Font Awesome 5 Pro'.format(pointsfmt)
pointsfmt = ",".join(points)
configline = "symbol_map {} Font Awesome 5 Pro".format(pointsfmt)
pointsfmt_brands = ','.join(points_brands)
configline_brands = 'symbol_map {} Font Awesome 5 Brands'.format(pointsfmt_brands)
pointsfmt_brands = ",".join(points_brands)
configline_brands = "symbol_map {} Font Awesome 5 Brands".format(pointsfmt_brands)
print(configline)
print(configline_brands)

View File

@ -8,7 +8,7 @@
# font_family IBM Plex Mono
# font_family Source Code Pro
font_family Fira Code Retina
font_family Fira Code
bold_font Fira Code Bold
# bold_font auto
italic_font IBM Plex Mono Italic
@ -32,7 +32,7 @@ font_size 11.0
#: Font size (in pts)
adjust_line_height 115%
adjust_line_height 130%
# adjust_column_width 0
#: Change the size of each character cell kitty renders. You can use
@ -974,11 +974,11 @@ macos_show_window_title_in window
#: You can change the font size for all top-level kitty OS windows at
#: a time or only the current one.
# map kitty_mod+equal change_font_size all +2.0
map kitty_mod+f>plus change_font_size all +2.0
# map cmd+plus change_font_size all +2.0
# map kitty_mod+minus change_font_size all -2.0
map kitty_mod+f>minus change_font_size all -2.0
# map cmd+minus change_font_size all -2.0
# map kitty_mod+backspace change_font_size all 0
map kitty_mod+f>backspace change_font_size all 0
# map cmd+0 change_font_size all 0
#: To setup shortcuts for specific font sizes::

View File

@ -138,6 +138,7 @@
let s:terms_italic=[
\"rxvt",
\"gnome-terminal",
\"xterm-kitty",
\"iTerm.app"
\]
" For reference only, terminals are known to be incomptible.
@ -150,6 +151,9 @@ if has("gui_running")
else
let s:terminal_italic=0 " terminals will be guilty until proven compatible
for term in s:terms_italic
if $TERM =~ term
let s:terminal_italic=1
endif
if $TERM_PROGRAM =~ term
let s:terminal_italic=1
endif

31
.zshrc
View File

@ -31,8 +31,8 @@ if [[ -f "$HOME/.deno" ]]; then
export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
fi
if [[ -f "$HOME/.gem/ruby/2.6.0/bin" ]]; then
export PATH="$HOME/.gem/ruby/2.6.0/bin:$PATH"
if [[ -f "$(which go 2>/dev/null)" ]]; then
export PATH="$(ruby -e 'puts Gem.user_dir')/bin:$PATH"
fi
if [[ -f "$(which go 2>/dev/null)" ]]; then
export PATH="$(go env GOPATH)/bin:$PATH"
@ -67,7 +67,9 @@ case "$(uname -s)" in
esac
if [[ $PLATFORM == macos ]]; then
export PATH="$HOME/Library/Python/3.8/bin:$PATH"
export PATH="$HOME/Library/Python/3.9/bin:$PATH"
export PATH="$HOME/Library/Python/3.10/bin:$PATH" # LOL
# On Linux, scripts are installed into $HOME/.local/bin
fi
setup_term_integration() {}
@ -130,7 +132,7 @@ format_vcs_info() {
echo "$text"
fi
}
if [[ $FAST != "true" ]]; then
if [[ $FAST != true ]]; then
setup_prompt_vcs
fi
# prompt: return code
@ -198,7 +200,8 @@ setup_prompt_colors() {
PROMPT_COLOR_BLUE=4
PROMPT_COLOR_CYAN=6
PROMPT_COLOR_GREEN=2
if [[ "$LIGHT" == "true" ]]; then
PROMPT_COLOR_ALWAYS_BASE3=$PROMPT_COLOR_BASE3
if [[ $LIGHT == true ]]; then
PROMPT_COLOR_TEMP03=$PROMPT_COLOR_TEMP03
PROMPT_COLOR_TEMP02=$PROMPT_COLOR_TEMP02
PROMPT_COLOR_TEMP01=$PROMPT_COLOR_TEMP01
@ -222,12 +225,12 @@ setup_prompt() {
PROMPT_FMT_ITALIC=$(tput sitm)
PROMPT_FMT_RESET=$(tput sgr 0)
PROMPT_USER=$'%{'"$PROMPT_FMT_ITALIC"$'%}%F{'"$PROMPT_COLOR_BASE3"$'}%(!.%K{'"$PROMPT_COLOR_ORANGE"$'}.%K{'"$PROMPT_COLOR_BLUE"$'}) %n'"$PROMPT_USER_MACHINE"$' %k%f%{'"$PROMPT_FMT_RESET"$'%}'
PROMPT_HISTORY=$'%F{'"$PROMPT_COLOR_BASE01"$'}%{'"$PROMPT_FMT_ITALIC"$'%} %h %{'"$PROMPT_FMT_RESET"$'%}%f'
PROMPT_USER=$'%{'"$PROMPT_FMT_ITALIC"$'%}%F{'"$PROMPT_COLOR_ALWAYS_BASE3"$'}%(!.%K{'"$PROMPT_COLOR_ORANGE"$'}.%K{'"$PROMPT_COLOR_BLUE"$'}) %n'"$PROMPT_USER_MACHINE"$' %k%f%{'"$PROMPT_FMT_RESET"$'%}'
PROMPT_HISTORY=$'%F{'"$PROMPT_COLOR_BASE01"$'} %h %f'
PROMPT_ERROR_PREV=$'$(format_return_code_prev $?)'
PROMPT_VCS=$'%K{'$PROMPT_COLOR_BASE03$'}$(format_vcs_info $vcs_info_msg_0_)%k'
PROMPT_DIRECTORY=$'%K{'$PROMPT_COLOR_BASE02$'} %2~ %k'
PROMPT_VI=$'%F{'"$PROMPT_COLOR_BASE3"$'}%{'"$PROMPT_FMT_ITALIC"$'%}$zle_vi_mode_%{'"$PROMPT_FMT_RESET"$'%}%f'
PROMPT_VI=$'%F{'"$PROMPT_COLOR_ALWAYS_BASE3"$'}%{'"$PROMPT_FMT_ITALIC"$'%}$zle_vi_mode_%{'"$PROMPT_FMT_RESET"$'%}%f'
RPROMPT="$PROMPT_HISTORY$PROMPT_USER"
PROMPT="$PROMPT_VI$PROMPT_VCS$PROMPT_DIRECTORY "
}
@ -268,15 +271,23 @@ fi
# helper scripts
function theme {
case "$2" in
g)
KITTY_VARIATION=greyscale-
;;
*)
KITTY_VARIATION=
;;
esac
case "$1" in
light)
ITERM_PROFILE=Light
KITTY_THEME=light
KITTY_THEME=${KITTY_VARIATION}light
export LIGHT=true
;;
dark)
ITERM_PROFILE=Default
KITTY_THEME=dark
KITTY_THEME=${KITTY_VARIATION}dark
export LIGHT=false
;;
esac