Added support for truecolor in tmux status line

This commit is contained in:
Alex Maese 2018-02-13 10:27:31 -06:00
parent a4a1c83539
commit b53708b577
2 changed files with 12 additions and 3 deletions

View File

@ -164,7 +164,10 @@ def init_tmux_environment(pl, args, set_tmux_environment=set_tmux_environment):
# But it does not support empty attributes as well.
or 'none'))
else:
set_tmux_environment(varname, 'colour' + str(get_highlighting(group)[attr][0]))
if powerline.common_config['term_truecolor'] is True:
set_tmux_environment(varname, '#{0:06x}'.format(get_highlighting(group)[attr][1]))
else:
set_tmux_environment(varname, 'colour' + str(get_highlighting(group)[attr][0]))
left_dividers = powerline.renderer.theme.dividers['left']
set_tmux_environment('_POWERLINE_LEFT_HARD_DIVIDER', left_dividers['hard'])

View File

@ -48,12 +48,18 @@ class TmuxRenderer(Renderer):
if fg is False or fg[0] is False:
tmux_attrs += ['fg=default']
else:
tmux_attrs += ['fg=colour' + str(fg[0])]
if self.term_truecolor and fg[1]:
tmux_attrs += ['fg=#{0:06x}'.format(int(fg[1]))]
else:
tmux_attrs += ['fg=colour' + str(fg[0])]
if bg is not None:
if bg is False or bg[0] is False:
tmux_attrs += ['bg=default']
else:
tmux_attrs += ['bg=colour' + str(bg[0])]
if self.term_truecolor and bg[1]:
tmux_attrs += ['bg=#{0:06x}'.format(int(bg[1]))]
else:
tmux_attrs += ['bg=colour' + str(bg[0])]
if attrs is not None:
tmux_attrs += attrs_to_tmux_attrs(attrs)
return '#[' + ','.join(tmux_attrs) + ']'