def test_bash(self): from powerline.shell import ShellPowerline args = Args(last_exit_code=1, jobnum=0, ext=['shell'], renderer_module='.bash', config={'ext': {'shell': {'theme': 'default_leftonly'}}}) with ShellPowerline(args, run_once=False) as powerline: powerline.render(segment_info={'args': args}) with ShellPowerline(args, run_once=False) as powerline: powerline.render(segment_info={'args': args})
def test_zsh(self): from powerline.shell import ShellPowerline args = Args(last_pipe_status=[1, 0], ext=['shell'], renderer_module='zsh_prompt') with ShellPowerline(args, run_once=False) as powerline: powerline.render(segment_info={'args': args}) with ShellPowerline(args, run_once=False) as powerline: powerline.render(segment_info={'args': args})
def test_tmux(self): from powerline.segments import common from imp import reload reload(common) from powerline.shell import ShellPowerline with replace_attr(common, 'urllib_read', urllib_read): with ShellPowerline(Args(ext=['tmux']), run_once=False) as powerline: powerline.render() with ShellPowerline(Args(ext=['tmux']), run_once=False) as powerline: powerline.render()
def test_zsh(self): from powerline.shell import ShellPowerline args = Args(last_pipe_status=[1, 0], jobnum=0, ext=['shell'], renderer_module='.zsh') segment_info = {'args': args} with ShellPowerline(args, run_once=False) as powerline: powerline.render(segment_info=segment_info) with ShellPowerline(args, run_once=False) as powerline: powerline.render(segment_info=segment_info) segment_info['local_theme'] = 'select' with ShellPowerline(args, run_once=False) as powerline: powerline.render(segment_info=segment_info) segment_info['local_theme'] = 'continuation' segment_info['parser_state'] = 'if cmdsubst' with ShellPowerline(args, run_once=False) as powerline: powerline.render(segment_info=segment_info)
def setup(): powerline = ShellPowerline(Args()) used_powerlines.append(powerline) used_powerlines.append(powerline) set_prompt(powerline, 'PS1', 'left') set_prompt(powerline, 'RPS1', 'right') atexit.register(shutdown)
def setup(): powerline = ShellPowerline(Args()) used_powerlines.append(powerline) used_powerlines.append(powerline) set_prompt(powerline, 'PS1', 'left', None) set_prompt(powerline, 'RPS1', 'right', None) set_prompt(powerline, 'PS2', 'left', 'continuation') set_prompt(powerline, 'RPS2', 'right', 'continuation') set_prompt(powerline, 'PS3', 'left', 'select') atexit.register(shutdown)
def init_tmux_environment(pl, args, set_tmux_environment=set_tmux_environment): '''Initialize tmux environment from tmux configuration ''' powerline = ShellPowerline(finish_args(os.environ, EmptyArgs('tmux', args.config_path))) # TODO Move configuration files loading out of Powerline object and use it # directly powerline.update_renderer() # FIXME Use something more stable then `theme_kwargs` colorscheme = powerline.renderer_options['theme_kwargs']['colorscheme'] def get_highlighting(group): return colorscheme.get_highlighting([group], None) for varname, highlight_group in ( ('_POWERLINE_BACKGROUND_COLOR', 'background'), ('_POWERLINE_ACTIVE_WINDOW_STATUS_COLOR', 'active_window_status'), ('_POWERLINE_WINDOW_STATUS_COLOR', 'window_status'), ('_POWERLINE_ACTIVITY_STATUS_COLOR', 'activity_status'), ('_POWERLINE_BELL_STATUS_COLOR', 'bell_status'), ('_POWERLINE_WINDOW_COLOR', 'window'), ('_POWERLINE_WINDOW_DIVIDER_COLOR', 'window:divider'), ('_POWERLINE_WINDOW_CURRENT_COLOR', 'window:current'), ('_POWERLINE_WINDOW_NAME_COLOR', 'window_name'), ('_POWERLINE_SESSION_COLOR', 'session'), ): highlight = get_highlighting(highlight_group) set_tmux_environment(varname, powerline.renderer.hlstyle(**highlight)[2:-1]) for varname, prev_group, next_group in ( ('_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_COLOR', 'window', 'window:current'), ('_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_NEXT_COLOR', 'window:current', 'window'), ('_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR', 'session', 'background'), ): prev_highlight = get_highlighting(prev_group) next_highlight = get_highlighting(next_group) set_tmux_environment( varname, powerline.renderer.hlstyle( fg=prev_highlight['bg'], bg=next_highlight['bg'], attrs=0, )[2:-1] ) for varname, attr, group in ( ('_POWERLINE_ACTIVE_WINDOW_FG', 'fg', 'active_window_status'), ('_POWERLINE_WINDOW_STATUS_FG', 'fg', 'window_status'), ('_POWERLINE_ACTIVITY_STATUS_FG', 'fg', 'activity_status'), ('_POWERLINE_ACTIVITY_STATUS_ATTR', 'attrs', 'activity_status'), ('_POWERLINE_BELL_STATUS_FG', 'fg', 'bell_status'), ('_POWERLINE_BELL_STATUS_ATTR', 'attrs', 'bell_status'), ('_POWERLINE_BACKGROUND_FG', 'fg', 'background'), ('_POWERLINE_BACKGROUND_BG', 'bg', 'background'), ('_POWERLINE_SESSION_FG', 'fg', 'session'), ('_POWERLINE_SESSION_BG', 'bg', 'session'), ('_POWERLINE_SESSION_ATTR', 'attrs', 'session'), ('_POWERLINE_SESSION_PREFIX_FG', 'fg', 'session:prefix'), ('_POWERLINE_SESSION_PREFIX_BG', 'bg', 'session:prefix'), ('_POWERLINE_SESSION_PREFIX_ATTR', 'attrs', 'session:prefix'), ): if attr == 'attrs': attrs = attrs_to_tmux_attrs(get_highlighting(group)[attr]) set_tmux_environment(varname, ']#['.join(attrs)) set_tmux_environment(varname + '_LEGACY', (','.join( # Tmux-1.6 does not accept no… attributes in # window-status-…-attr options. (attr for attr in attrs if not attr.startswith('no'))) # But it does not support empty attributes as well. or 'none')) 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']) set_tmux_environment('_POWERLINE_LEFT_SOFT_DIVIDER', left_dividers['soft']) set_tmux_environment('_POWERLINE_LEFT_HARD_DIVIDER_SPACES', ( ' ' * powerline.renderer.strwidth(left_dividers['hard'])))
def init_tmux_environment(pl, args, set_tmux_environment=set_tmux_environment): '''Initialize tmux environment from tmux configuration ''' powerline = ShellPowerline( finish_args(None, os.environ, EmptyArgs('tmux', args.config_path))) # TODO Move configuration files loading out of Powerline object and use it # directly powerline.update_renderer() # FIXME Use something more stable then `theme_kwargs` colorscheme = powerline.renderer_options['theme_kwargs']['colorscheme'] def get_highlighting(group): return colorscheme.get_highlighting([group], None) for varname, highlight_group in ( ('_POWERLINE_BACKGROUND_COLOR', 'background'), ('_POWERLINE_ACTIVE_WINDOW_STATUS_COLOR', 'active_window_status'), ('_POWERLINE_WINDOW_STATUS_COLOR', 'window_status'), ('_POWERLINE_ACTIVITY_STATUS_COLOR', 'activity_status'), ('_POWERLINE_BELL_STATUS_COLOR', 'bell_status'), ('_POWERLINE_WINDOW_COLOR', 'window'), ('_POWERLINE_WINDOW_DIVIDER_COLOR', 'window:divider'), ('_POWERLINE_WINDOW_CURRENT_COLOR', 'window:current'), ('_POWERLINE_WINDOW_NAME_COLOR', 'window_name'), ('_POWERLINE_SESSION_COLOR', 'session'), ): highlight = get_highlighting(highlight_group) set_tmux_environment(varname, powerline.renderer.hlstyle(**highlight)[2:-1]) for varname, prev_group, next_group in ( ('_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_COLOR', 'window', 'window:current'), ('_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_NEXT_COLOR', 'window:current', 'window'), ('_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR', 'session', 'background'), ): prev_highlight = get_highlighting(prev_group) next_highlight = get_highlighting(next_group) set_tmux_environment( varname, powerline.renderer.hlstyle( fg=prev_highlight['bg'], bg=next_highlight['bg'], attrs=0, )[2:-1]) for varname, attr, group in ( ('_POWERLINE_ACTIVE_WINDOW_FG', 'fg', 'active_window_status'), ('_POWERLINE_WINDOW_STATUS_FG', 'fg', 'window_status'), ('_POWERLINE_ACTIVITY_STATUS_FG', 'fg', 'activity_status'), ('_POWERLINE_ACTIVITY_STATUS_ATTR', 'attrs', 'activity_status'), ('_POWERLINE_BELL_STATUS_FG', 'fg', 'bell_status'), ('_POWERLINE_BELL_STATUS_ATTR', 'attrs', 'bell_status'), ('_POWERLINE_BACKGROUND_FG', 'fg', 'background'), ('_POWERLINE_BACKGROUND_BG', 'bg', 'background'), ('_POWERLINE_SESSION_FG', 'fg', 'session'), ('_POWERLINE_SESSION_BG', 'bg', 'session'), ('_POWERLINE_SESSION_ATTR', 'attrs', 'session'), ('_POWERLINE_SESSION_PREFIX_FG', 'fg', 'session:prefix'), ('_POWERLINE_SESSION_PREFIX_BG', 'bg', 'session:prefix'), ('_POWERLINE_SESSION_PREFIX_ATTR', 'attrs', 'session:prefix'), ): if attr == 'attrs': attrs = attrs_to_tmux_attrs(get_highlighting(group)[attr]) set_tmux_environment(varname, ']#['.join(attrs)) set_tmux_environment( varname + '_LEGACY', ( ','.join( # Tmux-1.6 does not accept no… attributes in # window-status-…-attr options. (attr for attr in attrs if not attr.startswith('no'))) # But it does not support empty attributes as well. or 'none')) else: if powerline.common_config['term_truecolor']: 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']) set_tmux_environment('_POWERLINE_LEFT_SOFT_DIVIDER', left_dividers['soft']) set_tmux_environment( '_POWERLINE_LEFT_HARD_DIVIDER_SPACES', (' ' * powerline.renderer.strwidth(left_dividers['hard'])))