mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
Merge ba81ac9502 into 4b19aa47f1
This commit is contained in:
commit
acd612b5e9
13
README.md
13
README.md
|
|
@ -261,10 +261,17 @@ to the path of the file. For example your configuration might have:
|
|||
"theme": "~/mythemes/my-great-theme.py"
|
||||
```
|
||||
|
||||
You can then modify the color codes to your liking. Theme colors are specified
|
||||
using [Xterm-256 color codes](https://jonasjacek.github.io/colors/).
|
||||
You can then modify the color codes to your liking. Theme colors can be specified
|
||||
using [Xterm-256 color codes](https://jonasjacek.github.io/colors/), or using RGB tuple values
|
||||
if your terminal supports TrueColor. To check if this is the case, you can run:
|
||||
|
||||
A script for testing color combinations is provided at `colortest.py`. Note
|
||||
```
|
||||
$ echo $COLORTERM
|
||||
```
|
||||
|
||||
If `truecolor` is printed, you're good to go with RGB values.
|
||||
|
||||
Scripts for testing color combinations are provided at `colortest.py` and `colortest_truecolor.py`. Note
|
||||
that the colors you see may vary depending on your terminal. When designing a
|
||||
theme, please test your theme on multiple terminals, especially with default
|
||||
settings.
|
||||
|
|
|
|||
23
colortest_truecolor.py
Executable file
23
colortest_truecolor.py
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env python2
|
||||
import sys
|
||||
|
||||
ESCAPE = chr(27)
|
||||
|
||||
def fg(color):
|
||||
return ESCAPE + '[38;2;%d;%d;%dm' % color
|
||||
|
||||
def bg(color):
|
||||
return ESCAPE + '[48;2;%d;%d;%dm' % color
|
||||
|
||||
def reset():
|
||||
return ESCAPE + '[48;0m'
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 8:
|
||||
print 'Usage: colortest_truecolor.py fg_red fg_green fg_blue bg_red bg_green bg_blue test_string'
|
||||
sys.exit(1)
|
||||
|
||||
fg_red, fg_green, fg_blue, bg_red, bg_green, bg_blue = map(int, sys.argv[1:-1])
|
||||
test_string = sys.argv[-1]
|
||||
|
||||
print bg((bg_red, bg_green, bg_blue)), fg((fg_red, fg_green, fg_blue)), test_string, reset()
|
||||
|
|
@ -6,6 +6,7 @@ import os
|
|||
import sys
|
||||
import importlib
|
||||
import json
|
||||
from . import colortrans
|
||||
from .utils import warn, py3, import_file
|
||||
import re
|
||||
|
||||
|
|
@ -86,6 +87,8 @@ class Powerline(object):
|
|||
def __init__(self, args, config, theme):
|
||||
self.args = args
|
||||
self.config = config
|
||||
env_colorterm = os.getenv("COLORTERM")
|
||||
self.truecolor_supported = env_colorterm is not None and "truecolor" in env_colorterm
|
||||
self.theme = theme
|
||||
self.cwd = get_valid_cwd()
|
||||
mode = config.get("mode", "patched")
|
||||
|
|
@ -105,6 +108,12 @@ class Powerline(object):
|
|||
return ''
|
||||
elif code == self.theme.RESET:
|
||||
return self.reset
|
||||
elif isinstance(code, tuple):
|
||||
# Do we support TrueColor? If not, supply the closest possible xterm-256 color.
|
||||
if self.truecolor_supported:
|
||||
return self.color_template % ('[%s;2;%s;%s;%sm' % (prefix, *code))
|
||||
else:
|
||||
return self.color_template % ('[%s;5;%sm' % (prefix, colortrans.rgb2short(*code)))
|
||||
else:
|
||||
return self.color_template % ('[%s;5;%sm' % (prefix, code))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue