Skip to content

Instantly share code, notes, and snippets.

@weakish
Last active December 18, 2023 05:58
Show Gist options
  • Save weakish/923039 to your computer and use it in GitHub Desktop.
Save weakish/923039 to your computer and use it in GitHub Desktop.
#Solarized themes (dark and light) for #roxterm.
#!/usr/bin/env rc
# by Jakukyo Friel <[email protected]> under GPL v2.
# Generate Solarized dark theme for roxterm.
# Works with both plan9 rc (plan9 unix port)
# and Byron Rakitzis' reimplementation.
# Tested with GNU grep/sed.
#
# Usage:
# Run it under the root of the solarized main repo.
# (At least make sure solarized README.md is under the current dir.)
#
# solarized% /path/to/gen_theme.rc > solarized-dark
#
# If you'd like to generate a light theme, alter the value of
# foreground, background and cursor (directly edit this script
# or edit the theme file afterwards).
fn gen_color_values {
cat README.md |
# extract the table
sed -n '/ SOLARIZED HEX/,/Usage & Development/p' |
sed -n '/ base03/,/ green/p' |
# extract required fields
grep -oE '^ [a-z0-9]+[ ]+#[0-9a-f]{6}[ ]+[0-9]{1,2}/'
}
# #abcdef -> #aabbccddeeff
fn convert_hex {
sed -r 's/#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/#\1\1\2\2\3\3/'
}
fn extract_color_value {
gen_color_values |
# Use $1^' ' to distinguish among base0/base01/base02/base03, etc.
grep $1^' ' | grep -oE '#[^ ]+' | convert_hex
}
fn gen_header {
echo '[roxterm colour scheme]'
echo 'foreground='^`{extract_color_value base0}
echo 'background='^`{extract_color_value base03}
}
fn gen_colormap {
gen_color_values |
grep -oE '#[^/]+' |
# sort from 0 to 15
sort -nk 2 |
# '#073642 0' -> '0=#070736364242'
sed -r 's/(#[^ ]+)[ ]+([0-9]{1,2})/\2=\1/' | convert_hex
}
fn gen_footer {
# Default colors specified by roxterm.
cat <<END
16=#4c4c4c4c4c4c
17=#a8a830303030
18=#202088882020
19=#a8a888880000
20=#555555559898
21=#888830308888
22=#303088888888
23=#d8d8d8d8d8d8
END
echo 'cursor='^`{extract_color_value base1}
echo 'palette_size=16'
}
# main
gen_header && gen_colormap && gen_footer
[roxterm colour scheme]
foreground=#838394949696
background=#00002b2b3636
0=#070736364242
1=#dcdc32322f2f
2=#858599990000
3=#b5b589890000
4=#26268b8bd2d2
5=#d3d336368282
6=#2a2aa1a19898
7=#eeeee8e8d5d5
8=#00002b2b3636
9=#cbcb4b4b1616
10=#58586e6e7575
11=#65657b7b8383
12=#838394949696
13=#6c6c7171c4c4
14=#9393a1a1a1a1
15=#fdfdf6f6e3e3
16=#4c4c4c4c4c4c
17=#a8a830303030
18=#202088882020
19=#a8a888880000
20=#555555559898
21=#888830308888
22=#303088888888
23=#d8d8d8d8d8d8
cursor=#9393a1a1a1a1
palette_size=16
[roxterm colour scheme]
foreground=#65657b7b8383
background=#fdfdf6f6e3e3
0=#070736364242
1=#dcdc32322f2f
2=#858599990000
3=#b5b589890000
4=#26268b8bd2d2
5=#d3d336368282
6=#2a2aa1a19898
7=#eeeee8e8d5d5
8=#00002b2b3636
9=#cbcb4b4b1616
10=#58586e6e7575
11=#65657b7b8383
12=#838394949696
13=#6c6c7171c4c4
14=#9393a1a1a1a1
15=#fdfdf6f6e3e3
16=#4c4c4c4c4c4c
17=#a8a830303030
18=#202088882020
19=#a8a888880000
20=#555555559898
21=#888830308888
22=#303088888888
23=#d8d8d8d8d8d8
cursor=#58586e6e7575
palette_size=16
@dampdigits
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment