Merge pull request #1249 from ZyX-I/refactor-overrides

Refactor overrides
This commit is contained in:
Nikolai Aleksandrovich Pavlov 2015-01-07 18:36:12 +03:00
commit c9d1b81954
45 changed files with 437 additions and 237 deletions

View File

@ -16,11 +16,11 @@ Vim configuration can be overridden using the following options:
Dictionary, recursively merged with contents of Dictionary, recursively merged with contents of
:file:`powerline/config.json`. :file:`powerline/config.json`.
``g:powerline_theme_overrides__{theme_name}`` ``g:powerline_theme_overrides``
Dictionary, recursively merged with contents of Dictionary mapping theme names to theme overrides, recursively merged with
:file:`powerline/themes/vim/{theme_name}.json`. Note that this way you cant contents of :file:`powerline/themes/vim/{key}.json`. Note that this way you
redefine some value (e.g. segment) in list, only the whole list itself: only cant redefine some value (e.g. segment) in list, only the whole list
dictionaries are merged recursively. itself: only dictionaries are merged recursively.
``g:powerline_config_paths`` ``g:powerline_config_paths``
Paths list (each path must be expanded, ``~`` shortcut is not supported). Paths list (each path must be expanded, ``~`` shortcut is not supported).
@ -37,13 +37,15 @@ Vim configuration can be overridden using the following options:
was configured in :ref:`log_* options <config-common-log>`. Level is always was configured in :ref:`log_* options <config-common-log>`. Level is always
:ref:`log_level <config-common-log_level>`, same for format. :ref:`log_level <config-common-log_level>`, same for format.
.. _local-configuration-overrides-script:
Powerline script overrides Powerline script overrides
========================== ==========================
Powerline script has a number of options controlling powerline behavior. Here Powerline script has a number of options controlling powerline behavior. Here
``VALUE`` always means “some JSON object”. ``VALUE`` always means “some JSON object”.
``-c KEY.NESTED_KEY=VALUE`` or ``--config=KEY.NESTED_KEY=VALUE`` ``-c KEY.NESTED_KEY=VALUE`` or ``--config-override=KEY.NESTED_KEY=VALUE``
Overrides options from :file:`powerline/config.json`. Overrides options from :file:`powerline/config.json`.
``KEY.KEY2.KEY3=VALUE`` is a shortcut for ``KEY={"KEY2": {"KEY3": VALUE}}``. ``KEY.KEY2.KEY3=VALUE`` is a shortcut for ``KEY={"KEY2": {"KEY3": VALUE}}``.
Multiple options (i.e. ``-c K1=V1 -c K2=V2``) are allowed, result (in the Multiple options (i.e. ``-c K1=V1 -c K2=V2``) are allowed, result (in the
@ -53,7 +55,7 @@ Powerline script has a number of options controlling powerline behavior. Here
If ``VALUE`` is omitted then corresponding key will be removed from the If ``VALUE`` is omitted then corresponding key will be removed from the
configuration (if it was present). configuration (if it was present).
``-t THEME_NAME.KEY.NESTED_KEY=VALUE`` or ``--theme-option=THEME_NAME.KEY.NESTED_KEY=VALUE`` ``-t THEME_NAME.KEY.NESTED_KEY=VALUE`` or ``--theme-override=THEME_NAME.KEY.NESTED_KEY=VALUE``
Overrides options from :file:`powerline/themes/{ext}/{THEME_NAME}.json`. Overrides options from :file:`powerline/themes/{ext}/{THEME_NAME}.json`.
``KEY.NESTED_KEY=VALUE`` is processed like described above, ``{ext}`` is the ``KEY.NESTED_KEY=VALUE`` is processed like described above, ``{ext}`` is the
first argument to powerline script. May be passed multiple times. first argument to powerline script. May be passed multiple times.
@ -67,11 +69,96 @@ Powerline script has a number of options controlling powerline behavior. Here
performed by powerline script itself, but ``-p ~/.powerline`` will likely be performed by powerline script itself, but ``-p ~/.powerline`` will likely be
expanded by the shell to something like ``-p /home/user/.powerline``. expanded by the shell to something like ``-p /home/user/.powerline``.
.. warning::
Such overrides are suggested for testing purposes only. Use
:ref:`Environment variables overrides <local-configuration-overrides-env>`
for other purposes.
.. _local-configuration-overrides-env:
Environment variables overrides
===============================
All bindings that use ``POWERLINE_COMMAND`` environment variable support taking
overrides from environment variables. In this case overrides should look like
the following::
OVERRIDE='key1.key2.key3=value;key4.key5={"value":1};key6=true;key1.key7=10'
. This will be parsed into
.. code-block:: Python
{
"key1": {
"key2": {
"key3": "value"
},
"key7": 10,
},
"key4": {
"key5": {
"value": 1,
},
},
"key6": True,
}
. Rules:
#. Environment variable must form a semicolon-separated list of key-value pairs:
``key=value;key2=value2``.
#. Keys are always dot-separated strings that must not contain equals sign (as
well as semicolon) or start with an underscore. They are interpreted
literally and create a nested set of dictionaries: ``k1.k2.k3`` creates
``{"k1":{"k2":{}}}`` and inside the innermost dictionary last key (``k3`` in
the example) is contained with its value.
#. Value may be empty in which case they are interpreted as an order to remove
some value: ``k1.k2=`` will form ``{"k1":{"k2":REMOVE_THIS_KEY}}`` nested
dictionary where ``k2`` value is a special value that tells
dictionary-merging function to remove ``k2`` rather then replace it with
something.
#. Value may be a JSON strings like ``{"a":1}`` (JSON dictionary), ``["a",1]``
(JSON list), ``1`` or ``-1`` (JSON number), ``"abc"`` (JSON string) or
``true``, ``false`` and ``null`` (JSON boolean objects and ``Null`` object
from JSON). General rule is that anything starting with a digit (U+0030 till
U+0039, inclusive), a hyphenminus (U+002D), a quotation mark (U+0022), a left
curly bracket (U+007B) or a left square bracket (U+005B) is considered to be
some JSON object, same for *exact* values ``true``, ``false`` and ``null``.
#. Any other value is considered to be literal string: ``k1=foo:bar`` parses to
``{"k1": "foo:bar"}``.
The following environment variables may be used for overrides according to the
above rules:
``POWERLINE_CONFIG_OVERRIDES``
Overrides values from :file:`powerline/config.json`.
``POWERLINE_THEME_OVERRIDES``
Overrides values from :file:`powerline/themes/{ext}/{key}.json`. Top-level
key is treated as a name of the theme for which overrides are used: e.g. to
disable cwd segment defined in :file:`powerline/themes/shell/default.json`
one needs to use::
POWERLINE_THEME_OVERRIDES=default.segment_data.cwd.display=false
Additionally one environment variable is a usual *colon*-separated list of
directories: ``POWERLINE_CONFIG_PATHS``. This one defines paths which will be
searched for configuration. Empty paths in ``POWERLINE_CONFIG_PATHS`` are
ignored.
.. note::
Overrides from environment variables have lower priority then
:ref:`Powerline script overrides <local-configuration-overrides-script>`.
Latter are suggested for tests only.
Zsh/zpython overrides Zsh/zpython overrides
===================== =====================
Here overrides are controlled by similarly to the powerline script, but values Here overrides are controlled by similarly to the powerline script, but values
are taken from zsh variables. are taken from zsh variables. :ref:`Environment variable overrides
<local-configuration-overrides-env>` are also supported: if variable is a string
this variant is used.
``POWERLINE_CONFIG_OVERRIDES`` ``POWERLINE_CONFIG_OVERRIDES``
Overrides options from :file:`powerline/config.json`. Should be a zsh Overrides options from :file:`powerline/config.json`. Should be a zsh
@ -80,7 +167,7 @@ are taken from zsh variables.
VALUE}}``. All pairs are then recursively merged into one dictionary and VALUE}}``. All pairs are then recursively merged into one dictionary and
this dictionary is recursively merged with the contents of the file. this dictionary is recursively merged with the contents of the file.
``POWERLINE_THEME_CONFIG`` ``POWERLINE_THEME_OVERRIDES``
Overrides options from :file:`powerline/themes/shell/*.json`. Should be Overrides options from :file:`powerline/themes/shell/*.json`. Should be
a zsh associative array with keys equal to ``THEME_NAME.KEY.NESTED_KEY`` and a zsh associative array with keys equal to ``THEME_NAME.KEY.NESTED_KEY`` and
values being JSON strings. Is processed like the above values being JSON strings. Is processed like the above
@ -112,7 +199,7 @@ use ``c.Powerline.KEY``. Supported ``KEY`` strings or keyword argument names:
a dictionary where keys are theme names and values are dictionaries which a dictionary where keys are theme names and values are dictionaries which
will be recursively merged with the contents of the given theme. will be recursively merged with the contents of the given theme.
``paths`` ``config_paths``
Sets directories where configuration should be read from. If present, no Sets directories where configuration should be read from. If present, no
default locations are searched for configuration. No expansions are default locations are searched for configuration. No expansions are
performed thus you cannot use paths starting with ``~/``. performed thus you cannot use paths starting with ``~/``.
@ -128,10 +215,11 @@ putting powerline into different directory.
.. note:: .. note::
``$POWERLINE_COMMAND`` appears in shell scripts without quotes thus you can ``$POWERLINE_COMMAND`` is always treated as one path in shell bindings, so
specify additional parameters in bash. In tmux it is passed to ``eval`` and you may use paths with spaces in it. To specify additional arguments one may
depends on the shell used. POSIX-compatible shells, zsh, bash and fish will use ``$POWERLINE_COMMAND_ARGS``, but note that this variable exists for
split this variable in this case. testing purposes only and may be removed. One should use :ref:`Environment
variable overrides <local-configuration-overrides-env>` instead.
If you want to disable prompt in shell, but still have tmux support or if you If you want to disable prompt in shell, but still have tmux support or if you
want to disable tmux support you can use variables want to disable tmux support you can use variables

View File

@ -13,6 +13,7 @@ from powerline.lib.unicode import safe_unicode, FailedUnicode
from powerline.config import DEFAULT_SYSTEM_CONFIG_DIR from powerline.config import DEFAULT_SYSTEM_CONFIG_DIR
from powerline.lib.dict import mergedicts from powerline.lib.dict import mergedicts
from powerline.lib.encoding import get_preferred_output_encoding from powerline.lib.encoding import get_preferred_output_encoding
from powerline.lib.path import join
class NotInterceptedError(BaseException): class NotInterceptedError(BaseException):
@ -29,7 +30,7 @@ def _find_config_files(search_paths, config_file, config_loader=None, loader_cal
config_file += '.json' config_file += '.json'
found = False found = False
for path in search_paths: for path in search_paths:
config_file_path = os.path.join(path, config_file) config_file_path = join(path, config_file)
if os.path.isfile(config_file_path): if os.path.isfile(config_file_path):
yield config_file_path yield config_file_path
found = True found = True
@ -142,12 +143,12 @@ def get_config_paths():
:return: list of paths :return: list of paths
''' '''
config_home = os.environ.get('XDG_CONFIG_HOME', os.path.join(os.path.expanduser('~'), '.config')) config_home = os.environ.get('XDG_CONFIG_HOME', os.path.join(os.path.expanduser('~'), '.config'))
config_path = os.path.join(config_home, 'powerline') config_path = join(config_home, 'powerline')
config_paths = [config_path] config_paths = [config_path]
config_dirs = os.environ.get('XDG_CONFIG_DIRS', DEFAULT_SYSTEM_CONFIG_DIR) config_dirs = os.environ.get('XDG_CONFIG_DIRS', DEFAULT_SYSTEM_CONFIG_DIR)
if config_dirs is not None: if config_dirs is not None:
config_paths[:0] = reversed([os.path.join(d, 'powerline') for d in config_dirs.split(':')]) config_paths[:0] = reversed([join(d, 'powerline') for d in config_dirs.split(':')])
plugin_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), 'config_files') plugin_path = join(os.path.realpath(os.path.dirname(__file__)), 'config_files')
config_paths.insert(0, plugin_path) config_paths.insert(0, plugin_path)
return config_paths return config_paths

View File

@ -41,7 +41,7 @@ _powerline_init_tmux_support() {
_powerline_local_prompt() { _powerline_local_prompt() {
# Arguments: side, renderer_module arg, last_exit_code, jobnum, local theme # Arguments: side, renderer_module arg, last_exit_code, jobnum, local theme
$POWERLINE_COMMAND shell $1 \ "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
$2 \ $2 \
--last-exit-code=$3 \ --last-exit-code=$3 \
--jobnum=$4 \ --jobnum=$4 \
@ -51,7 +51,7 @@ _powerline_local_prompt() {
_powerline_prompt() { _powerline_prompt() {
# Arguments: side, last_exit_code, jobnum # Arguments: side, last_exit_code, jobnum
$POWERLINE_COMMAND shell $1 \ "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
--width="${COLUMNS:-$(_powerline_columns_fallback)}" \ --width="${COLUMNS:-$(_powerline_columns_fallback)}" \
-r.bash \ -r.bash \
--last-exit-code=$2 \ --last-exit-code=$2 \

View File

@ -8,11 +8,12 @@ import sys
from powerline.config import POWERLINE_ROOT, TMUX_CONFIG_DIRECTORY from powerline.config import POWERLINE_ROOT, TMUX_CONFIG_DIRECTORY
from powerline.lib.config import ConfigLoader from powerline.lib.config import ConfigLoader
from powerline import generate_config_finder, load_config, create_logger, PowerlineLogger, finish_common_config from powerline import generate_config_finder, load_config, create_logger, PowerlineLogger, finish_common_config
from powerline.tmux import TmuxPowerline from powerline.shell import ShellPowerline
from powerline.lib.shell import which from powerline.lib.shell import which
from powerline.bindings.tmux import TmuxVersionInfo, run_tmux_command, set_tmux_environment, get_tmux_version from powerline.bindings.tmux import TmuxVersionInfo, run_tmux_command, set_tmux_environment, get_tmux_version
from powerline.lib.encoding import get_preferred_output_encoding from powerline.lib.encoding import get_preferred_output_encoding
from powerline.renderers.tmux import attrs_to_tmux_attrs from powerline.renderers.tmux import attrs_to_tmux_attrs
from powerline.commands.main import finish_args
CONFIG_FILE_NAME = re.compile(r'powerline_tmux_(?P<major>\d+)\.(?P<minor>\d+)(?P<suffix>[a-z]+)?(?:_(?P<mod>plus|minus))?\.conf') CONFIG_FILE_NAME = re.compile(r'powerline_tmux_(?P<major>\d+)\.(?P<minor>\d+)(?P<suffix>[a-z]+)?(?:_(?P<mod>plus|minus))?\.conf')
@ -77,10 +78,19 @@ def source_tmux_files(pl, args):
run_tmux_command('refresh-client') run_tmux_command('refresh-client')
class EmptyArgs(object):
def __init__(self, ext, config_path):
self.ext = ext
self.config_path = None
def __getattr__(self, attr):
return None
def init_environment(pl, args): def init_environment(pl, args):
'''Initialize tmux environment from tmux configuration '''Initialize tmux environment from tmux configuration
''' '''
powerline = TmuxPowerline(args.config_path) powerline = ShellPowerline(finish_args(EmptyArgs('tmux', args.config_path)))
# TODO Move configuration files loading out of Powerline object and use it # TODO Move configuration files loading out of Powerline object and use it
# directly # directly
powerline.update_renderer() powerline.update_renderer()

View File

@ -65,10 +65,10 @@ function powerline-setup
end end
eval " eval "
function fish_prompt function fish_prompt
$POWERLINE_COMMAND shell $promptside $addargs env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell $promptside $addargs
end end
function fish_right_prompt function fish_right_prompt
$POWERLINE_COMMAND shell right $addargs env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell right $addargs
$rpromptpast $rpromptpast
end end
function --on-signal WINCH _powerline_set_columns function --on-signal WINCH _powerline_set_columns

View File

@ -72,7 +72,7 @@ class ConfigurableIPythonPowerline(IPythonPowerline):
config = ip.config.Powerline config = ip.config.Powerline
self.config_overrides = config.get('config_overrides') self.config_overrides = config.get('config_overrides')
self.theme_overrides = config.get('theme_overrides', {}) self.theme_overrides = config.get('theme_overrides', {})
self.paths = config.get('paths') self.config_paths = config.get('config_paths')
super(ConfigurableIPythonPowerline, self).init() super(ConfigurableIPythonPowerline, self).init()
def do_setup(self, ip, shutdown_hook): def do_setup(self, ip, shutdown_hook):

View File

@ -95,10 +95,10 @@ class PowerlinePrompt2(PowerlinePromptOut):
class ConfigurableIPythonPowerline(IPythonPowerline): class ConfigurableIPythonPowerline(IPythonPowerline):
def init(self, config_overrides=None, theme_overrides={}, paths=None): def init(self, config_overrides=None, theme_overrides={}, config_paths=None):
self.config_overrides = config_overrides self.config_overrides = config_overrides
self.theme_overrides = theme_overrides self.theme_overrides = theme_overrides
self.paths = paths self.config_paths = config_paths
super(ConfigurableIPythonPowerline, self).init() super(ConfigurableIPythonPowerline, self).init()
def ipython_magic(self, ip, parameter_s=''): def ipython_magic(self, ip, parameter_s=''):

View File

@ -136,7 +136,7 @@ _powerline_set_jobs() {
_powerline_local_prompt() { _powerline_local_prompt() {
# Arguments: side, exit_code, local theme # Arguments: side, exit_code, local theme
_powerline_set_jobs _powerline_set_jobs
$POWERLINE_COMMAND shell $1 \ "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
$_POWERLINE_RENDERER_ARG \ $_POWERLINE_RENDERER_ARG \
--renderer-arg="client_id=$$" \ --renderer-arg="client_id=$$" \
--last-exit-code=$2 \ --last-exit-code=$2 \
@ -147,7 +147,7 @@ _powerline_local_prompt() {
_powerline_prompt() { _powerline_prompt() {
# Arguments: side, exit_code # Arguments: side, exit_code
_powerline_set_jobs _powerline_set_jobs
$POWERLINE_COMMAND shell $1 \ "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
--width="${COLUMNS:-$(_powerline_columns_fallback)}" \ --width="${COLUMNS:-$(_powerline_columns_fallback)}" \
$_POWERLINE_RENDERER_ARG \ $_POWERLINE_RENDERER_ARG \
--renderer-arg="client_id=$$" \ --renderer-arg="client_id=$$" \

View File

@ -32,15 +32,18 @@ if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses prompt } ) then
set POWERLINE_COMMAND="`$POWERLINE_CONFIG_COMMAND:q shell command`" set POWERLINE_COMMAND="`$POWERLINE_CONFIG_COMMAND:q shell command`"
endif endif
endif endif
if ! $?POWERLINE_COMMAND_ARGS then
set POWERLINE_COMMAND_ARGS=""
endif
if ( $?POWERLINE_NO_TCSH_ABOVE || $?POWERLINE_NO_SHELL_ABOVE ) then if ( $?POWERLINE_NO_TCSH_ABOVE || $?POWERLINE_NO_SHELL_ABOVE ) then
alias _powerline_above true alias _powerline_above true
else else
alias _powerline_above '$POWERLINE_COMMAND shell above --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS' alias _powerline_above '$POWERLINE_COMMAND:q $POWERLINE_COMMAND_ARGS shell above --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS'
endif endif
alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND shell left -r .tcsh --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS`"' alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND:q $POWERLINE_COMMAND_ARGS shell left -r .tcsh --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS`"'
alias _powerline_set_rprompt 'set rprompt="`$POWERLINE_COMMAND shell right -r .tcsh --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS` "' alias _powerline_set_rprompt 'set rprompt="`$POWERLINE_COMMAND:q $POWERLINE_COMMAND_ARGS shell right -r .tcsh --renderer-arg=client_id=$$ --last-exit-code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS` "'
alias _powerline_set_columns 'set POWERLINE_COLUMNS=`stty size|cut -d" " -f2` ; set POWERLINE_COLUMNS=`expr $POWERLINE_COLUMNS - 2`' alias _powerline_set_columns 'set POWERLINE_COLUMNS=`stty size|cut -d" " -f2` ; set POWERLINE_COLUMNS=`expr $POWERLINE_COLUMNS - 2`'
alias precmd 'set POWERLINE_STATUS=$? ; '"`alias precmd`"' ; _powerline_set_columns ; _powerline_above ; _powerline_set_prompt ; _powerline_set_rprompt' alias precmd 'set POWERLINE_STATUS=$? ; '"`alias precmd`"' ; _powerline_set_columns ; _powerline_above ; _powerline_set_prompt ; _powerline_set_rprompt'

View File

@ -2,7 +2,7 @@ set -g status on
set -g status-utf8 on set -g status-utf8 on
set -g status-interval 2 set -g status-interval 2
set -g status-left-length 20 set -g status-left-length 20
set -g status-right '#(eval $POWERLINE_COMMAND tmux right -R pane_id=`tmux display -p "#D"`)' set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id=`tmux display -p "#D"`)'
set -g status-right-length 150 set -g status-right-length 150
set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I #[$_POWERLINE_WINDOW_DIVIDER_COLOR]$_POWERLINE_LEFT_SOFT_DIVIDER#[default]#W $_POWERLINE_LEFT_HARD_DIVIDER_SPACES" set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I #[$_POWERLINE_WINDOW_DIVIDER_COLOR]$_POWERLINE_LEFT_SOFT_DIVIDER#[default]#W $_POWERLINE_LEFT_HARD_DIVIDER_SPACES"
set -g window-status-current-format "#[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#[$_POWERLINE_WINDOW_CURRENT_COLOR]#I $_POWERLINE_LEFT_SOFT_DIVIDER#[$_POWERLINE_WINDOW_NAME_COLOR]#W #[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER" set -g window-status-current-format "#[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#[$_POWERLINE_WINDOW_CURRENT_COLOR]#I $_POWERLINE_LEFT_SOFT_DIVIDER#[$_POWERLINE_WINDOW_NAME_COLOR]#W #[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER"

View File

@ -1,5 +1,5 @@
# powerline_tmux_1.8_plus.conf # powerline_tmux_1.8_plus.conf
# tmux Version 1.8 introduces the 'client_prefix' format variable, applicable # tmux Version 1.8 introduces the 'client_prefix' format variable, applicable
# for versions 1.8+ # for versions 1.8+
set -qg status-left "#{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_FG]#[bg=$_POWERLINE_SESSION_PREFIX_BG]#[$_POWERLINE_SESSION_PREFIX_ATTR],#[fg=$_POWERLINE_SESSION_FG]#[bg=$_POWERLINE_SESSION_BG]#[$_POWERLINE_SESSION_ATTR]} #S #{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_BG],#[fg=$_POWERLINE_SESSION_BG]}#[bg=$_POWERLINE_BACKGROUND_BG]#[nobold]$_POWERLINE_LEFT_HARD_DIVIDER#(eval \$POWERLINE_COMMAND tmux left)" set -qg status-left "#{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_FG]#[bg=$_POWERLINE_SESSION_PREFIX_BG]#[$_POWERLINE_SESSION_PREFIX_ATTR],#[fg=$_POWERLINE_SESSION_FG]#[bg=$_POWERLINE_SESSION_BG]#[$_POWERLINE_SESSION_ATTR]} #S #{?client_prefix,#[fg=$_POWERLINE_SESSION_PREFIX_BG],#[fg=$_POWERLINE_SESSION_BG]}#[bg=$_POWERLINE_BACKGROUND_BG]#[nobold]$_POWERLINE_LEFT_HARD_DIVIDER#(env \$POWERLINE_COMMAND \$POWERLINE_COMMAND_ARGS tmux left)"
# vim: ft=tmux # vim: ft=tmux

View File

@ -8,7 +8,7 @@ from weakref import WeakValueDictionary, ref
import zsh import zsh
from powerline.shell import ShellPowerline from powerline.shell import ShellPowerline
from powerline.lib import parsedotval from powerline.lib.overrides import parsedotval, parse_override_var
from powerline.lib.unicode import unicode, u from powerline.lib.unicode import unicode, u
from powerline.lib.encoding import (get_preferred_output_encoding, from powerline.lib.encoding import (get_preferred_output_encoding,
get_preferred_environment_encoding) get_preferred_environment_encoding)
@ -25,7 +25,13 @@ def shutdown():
def get_var_config(var): def get_var_config(var):
try: try:
return mergeargs([parsedotval((u(k), u(v))) for k, v in zsh.getvalue(var).items()]) val = zsh.getvalue(var)
if isinstance(val, dict):
return mergeargs([parsedotval((u(k), u(v))) for k, v in val.items()])
elif isinstance(val, (unicode, str, bytes)):
return mergeargs(parse_override_var(u(val)))
else:
return None
except: except:
return None return None
@ -36,12 +42,12 @@ class Args(object):
renderer_module = '.zsh' renderer_module = '.zsh'
@property @property
def config(self): def config_override(self):
return get_var_config('POWERLINE_CONFIG_OVERRIDES') return get_var_config('POWERLINE_CONFIG_OVERRIDES')
@property @property
def theme_option(self): def theme_override(self):
return get_var_config('POWERLINE_THEME_CONFIG') return get_var_config('POWERLINE_THEME_OVERRIDES')
@property @property
def config_path(self): def config_path(self):
@ -51,7 +57,11 @@ class Args(object):
return None return None
else: else:
if isinstance(ret, (unicode, str, bytes)): if isinstance(ret, (unicode, str, bytes)):
return ret.split(type(ret)(':')) return [
path
for path in ret.split((b':' if isinstance(ret, bytes) else ':'))
if path
]
else: else:
return ret return ret
@ -91,7 +101,7 @@ class Environment(object):
return False return False
environ = Environment() environ = getattr(zsh, 'environ', Environment())
class ZshPowerline(ShellPowerline): class ZshPowerline(ShellPowerline):

View File

@ -151,11 +151,11 @@ _powerline_setup_prompt() {
local add_args_2=$add_args$new_args_2 local add_args_2=$add_args$new_args_2
add_args+=' --width=$(( ${COLUMNS:-$(_powerline_columns_fallback)} - ${ZLE_RPROMPT_INDENT:-1} ))' add_args+=' --width=$(( ${COLUMNS:-$(_powerline_columns_fallback)} - ${ZLE_RPROMPT_INDENT:-1} ))'
local add_args_r2=$add_args$new_args_2 local add_args_r2=$add_args$new_args_2
PS1='$($=POWERLINE_COMMAND shell aboveleft '$add_args')' PS1='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell aboveleft '$add_args')'
RPS1='$($=POWERLINE_COMMAND shell right '$add_args')' RPS1='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell right '$add_args')'
PS2='$($=POWERLINE_COMMAND shell left '$add_args_2')' PS2='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell left '$add_args_2')'
RPS2='$($=POWERLINE_COMMAND shell right '$add_args_r2')' RPS2='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell right '$add_args_r2')'
PS3='$($=POWERLINE_COMMAND shell left '$add_args_3')' PS3='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell left '$add_args_3')'
fi fi
} }

View File

@ -6,6 +6,6 @@ import argparse
def get_argparser(ArgumentParser=argparse.ArgumentParser): def get_argparser(ArgumentParser=argparse.ArgumentParser):
parser = ArgumentParser(description='Powerline configuration checker.') parser = ArgumentParser(description='Powerline configuration checker.')
parser.add_argument('-p', '--config_path', action='append', metavar='PATH', help='Paths where configuration should be checked, in order. You must supply all paths necessary for powerline to work, checking partial (e.g. only user overrides) configuration is not supported.') parser.add_argument('-p', '--config-path', action='append', metavar='PATH', help='Paths where configuration should be checked, in order. You must supply all paths necessary for powerline to work, checking partial (e.g. only user overrides) configuration is not supported.')
parser.add_argument('-d', '--debug', action='store_const', const=True, help='Display additional information. Used for debugging `powerline-lint\' itself, not for debugging configuration.') parser.add_argument('-d', '--debug', action='store_const', const=True, help='Display additional information. Used for debugging `powerline-lint\' itself, not for debugging configuration.')
return parser return parser

View File

@ -5,7 +5,9 @@ from __future__ import (division, absolute_import, print_function)
import argparse import argparse
import sys import sys
from powerline.lib import parsedotval from itertools import chain
from powerline.lib.overrides import parsedotval, parse_override_var
from powerline.lib.dict import mergeargs from powerline.lib.dict import mergeargs
from powerline.lib.encoding import get_preferred_arguments_encoding from powerline.lib.encoding import get_preferred_arguments_encoding
@ -14,21 +16,43 @@ if sys.version_info < (3,):
encoding = get_preferred_arguments_encoding() encoding = get_preferred_arguments_encoding()
def arg_to_unicode(s): def arg_to_unicode(s):
return unicode(s, encoding, 'replace') if not isinstance(s, unicode) else s return unicode(s, encoding, 'replace') if not isinstance(s, unicode) else s # NOQA
else: else:
def arg_to_unicode(s): def arg_to_unicode(s):
return s return s
def finish_args(args): def finish_args(environ, args):
if args.config: '''Do some final transformations
args.config = mergeargs((parsedotval(v) for v in args.config))
if args.theme_option: Transforms ``*_override`` arguments into dictionaries, adding overrides from
args.theme_option = mergeargs((parsedotval(v) for v in args.theme_option)) environment variables. Transforms ``renderer_arg`` argument into dictionary
else: as well, but only if it is true.
args.theme_option = {}
:param dict environ:
Environment from which additional overrides should be taken from.
:param args:
Arguments object returned by
:py:meth:`argparse.ArgumentParser.parse_args`. Will be modified
in-place.
:return: Object received as second (``args``) argument.
'''
args.config_override = mergeargs(chain(
parse_override_var(environ.get('POWERLINE_CONFIG_OVERRIDES', '')),
(parsedotval(v) for v in args.config_override or ()),
))
args.theme_override = mergeargs(chain(
parse_override_var(environ.get('POWERLINE_THEME_OVERRIDES', '')),
(parsedotval(v) for v in args.theme_override or ()),
))
if args.renderer_arg: if args.renderer_arg:
args.renderer_arg = mergeargs((parsedotval(v) for v in args.renderer_arg)) args.renderer_arg = mergeargs((parsedotval(v) for v in args.renderer_arg), remove=True)
args.config_path = (
[path for path in environ.get('POWERLINE_CONFIG_PATHS', '').split(':') if path]
+ (args.config_path or [])
)
return args
def get_argparser(ArgumentParser=argparse.ArgumentParser): def get_argparser(ArgumentParser=argparse.ArgumentParser):
@ -43,8 +67,8 @@ def get_argparser(ArgumentParser=argparse.ArgumentParser):
parser.add_argument('--last-exit-code', metavar='INT', type=int, help='Last exit code.') parser.add_argument('--last-exit-code', metavar='INT', type=int, help='Last exit code.')
parser.add_argument('--last-pipe-status', metavar='LIST', default='', type=lambda s: [int(status) for status in s.split()], help='Like above, but is supposed to contain space-separated array of statuses, representing exit statuses of commands in one pipe.') parser.add_argument('--last-pipe-status', metavar='LIST', default='', type=lambda s: [int(status) for status in s.split()], help='Like above, but is supposed to contain space-separated array of statuses, representing exit statuses of commands in one pipe.')
parser.add_argument('--jobnum', metavar='INT', type=int, help='Number of jobs.') parser.add_argument('--jobnum', metavar='INT', type=int, help='Number of jobs.')
parser.add_argument('-c', '--config', metavar='KEY.KEY=VALUE', type=arg_to_unicode, action='append', help='Configuration overrides for `config.json\'. Is translated to a dictionary and merged with the dictionary obtained from actual JSON configuration: KEY.KEY=VALUE is translated to `{"KEY": {"KEY": VALUE}}\' and then merged recursively. VALUE may be any JSON value, values that are not `null\', `true\', `false\', start with digit, `{\', `[\' are treated like strings. If VALUE is omitted then corresponding key is removed.') parser.add_argument('-c', '--config-override', metavar='KEY.KEY=VALUE', type=arg_to_unicode, action='append', help='Configuration overrides for `config.json\'. Is translated to a dictionary and merged with the dictionary obtained from actual JSON configuration: KEY.KEY=VALUE is translated to `{"KEY": {"KEY": VALUE}}\' and then merged recursively. VALUE may be any JSON value, values that are not `null\', `true\', `false\', start with digit, `{\', `[\' are treated like strings. If VALUE is omitted then corresponding key is removed.')
parser.add_argument('-t', '--theme-option', metavar='THEME.KEY.KEY=VALUE', type=arg_to_unicode, action='append', help='Like above, but theme-specific. THEME should point to an existing and used theme to have any effect, but it is fine to use any theme here.') parser.add_argument('-t', '--theme-override', metavar='THEME.KEY.KEY=VALUE', type=arg_to_unicode, action='append', help='Like above, but theme-specific. THEME should point to an existing and used theme to have any effect, but it is fine to use any theme here.')
parser.add_argument('-R', '--renderer-arg', metavar='KEY=VAL', type=arg_to_unicode, action='append', help='Like above, but provides argument for renderer. Is supposed to be used only by shell bindings to provide various data like last-exit-code or last-pipe-status (they are not using `--renderer-arg\' for historical resons: `--renderer-arg\' was added later).') parser.add_argument('-R', '--renderer-arg', metavar='KEY=VAL', type=arg_to_unicode, action='append', help='Like above, but provides argument for renderer. Is supposed to be used only by shell bindings to provide various data like last-exit-code or last-pipe-status (they are not using `--renderer-arg\' for historical resons: `--renderer-arg\' was added later).')
parser.add_argument('-p', '--config-path', action='append', metavar='PATH', help='Path to configuration directory. If it is present then configuration files will only be seeked in the provided path. May be provided multiple times to search in a list of directories.') parser.add_argument('-p', '--config-path', action='append', metavar='PATH', help='Path to configuration directory. If it is present then configuration files will only be seeked in the provided path. May be provided multiple times to search in a list of directories.')
parser.add_argument('--socket', metavar='ADDRESS', type=str, help='Socket address to use in daemon clients. Is always UNIX domain socket on linux and file socket on Mac OS X. Not used here, present only for compatibility with other powerline clients. This argument must always be the first one and be in a form `--socket ADDRESS\': no `=\' or short form allowed (in other powerline clients, not here).') parser.add_argument('--socket', metavar='ADDRESS', type=str, help='Socket address to use in daemon clients. Is always UNIX domain socket on linux and file socket on Mac OS X. Not used here, present only for compatibility with other powerline clients. This argument must always be the first one and be in a form `--socket ADDRESS\': no `=\' or short form allowed (in other powerline clients, not here).')

View File

@ -32,8 +32,8 @@ class IPythonPowerline(Powerline):
) )
def get_config_paths(self): def get_config_paths(self):
if self.paths: if self.config_paths:
return self.paths return self.config_paths
else: else:
return super(IPythonPowerline, self).get_config_paths() return super(IPythonPowerline, self).get_config_paths()

View File

@ -1,12 +1,8 @@
# vim:fileencoding=utf-8:noet # vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function) from __future__ import (unicode_literals, division, absolute_import, print_function)
import json
from functools import wraps from functools import wraps
from powerline.lib.dict import REMOVE_THIS_KEY
def wraps_saveargs(wrapped): def wraps_saveargs(wrapped):
def dec(wrapper): def dec(wrapper):
@ -30,59 +26,3 @@ def add_divider_highlight_group(highlight_group):
return None return None
return f return f
return dec return dec
def parse_value(s):
'''Convert string to Python object
Rules:
* Empty string means that corresponding key should be removed from the
dictionary.
* Strings that start with a minus, digit or with some character that starts
JSON collection or string object are parsed as JSON.
* JSON special values ``null``, ``true``, ``false`` (case matters) are
parsed as JSON.
* All other values are considered to be raw strings.
:param str s: Parsed string.
:return: Python object.
'''
if not s:
return REMOVE_THIS_KEY
elif s[0] in '"{[0193456789-' or s in ('null', 'true', 'false'):
return json.loads(s)
else:
return s
def keyvaluesplit(s):
if '=' not in s:
raise TypeError('Option must look like option=json_value')
if s[0] == '_':
raise ValueError('Option names must not start with `_\'')
idx = s.index('=')
o = s[:idx]
val = parse_value(s[idx + 1:])
return (o, val)
def parsedotval(s):
if type(s) is tuple:
o, val = s
val = parse_value(val)
else:
o, val = keyvaluesplit(s)
keys = o.split('.')
if len(keys) > 1:
r = (keys[0], {})
rcur = r[1]
for key in keys[1:-1]:
rcur[key] = {}
rcur = rcur[key]
rcur[keys[-1]] = val
return r
else:
return (o, val)

View File

@ -5,26 +5,44 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
REMOVE_THIS_KEY = object() REMOVE_THIS_KEY = object()
def mergeargs(argvalue): def mergeargs(argvalue, remove=False):
if not argvalue: if not argvalue:
return None return None
r = {} r = {}
for subval in argvalue: for subval in argvalue:
mergedicts(r, dict([subval])) mergedicts(r, dict([subval]), remove=remove)
return r return r
def mergedicts(d1, d2): def _clear_special_values(d):
'''Remove REMOVE_THIS_KEY values from dictionary
'''
l = [d]
while l:
i = l.pop()
pops = []
for k, v in i.items():
if v is REMOVE_THIS_KEY:
pops.append(k)
elif isinstance(v, dict):
l.append(v)
for k in pops:
i.pop(k)
def mergedicts(d1, d2, remove=True):
'''Recursively merge two dictionaries '''Recursively merge two dictionaries
First dictionary is modified in-place. First dictionary is modified in-place.
''' '''
for k in d2: for k in d2:
if k in d1 and isinstance(d1[k], dict) and isinstance(d2[k], dict): if k in d1 and isinstance(d1[k], dict) and isinstance(d2[k], dict):
mergedicts(d1[k], d2[k]) mergedicts(d1[k], d2[k], remove)
elif d2[k] is REMOVE_THIS_KEY: elif remove and d2[k] is REMOVE_THIS_KEY:
d1.pop(k, None) d1.pop(k, None)
else: else:
if remove and isinstance(d2[k], dict):
_clear_special_values(d2[k])
d1[k] = d2[k] d1[k] = d2[k]

View File

@ -0,0 +1,80 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import json
from powerline.lib.dict import REMOVE_THIS_KEY
def parse_value(s):
'''Convert string to Python object
Rules:
* Empty string means that corresponding key should be removed from the
dictionary.
* Strings that start with a minus, digit or with some character that starts
JSON collection or string object are parsed as JSON.
* JSON special values ``null``, ``true``, ``false`` (case matters) are
parsed as JSON.
* All other values are considered to be raw strings.
:param str s: Parsed string.
:return: Python object.
'''
if not s:
return REMOVE_THIS_KEY
elif s[0] in '"{[0193456789-' or s in ('null', 'true', 'false'):
return json.loads(s)
else:
return s
def keyvaluesplit(s):
'''Split K1.K2=VAL into K1.K2 and parsed VAL
'''
if '=' not in s:
raise TypeError('Option must look like option=json_value')
if s[0] == '_':
raise ValueError('Option names must not start with `_\'')
idx = s.index('=')
o = s[:idx]
val = parse_value(s[idx + 1:])
return (o, val)
def parsedotval(s):
'''Parse K1.K2=VAL into {"K1":{"K2":VAL}}
``VAL`` is processed according to rules defined in :py:func:`parse_value`.
'''
if type(s) is tuple:
o, val = s
val = parse_value(val)
else:
o, val = keyvaluesplit(s)
keys = o.split('.')
if len(keys) > 1:
r = (keys[0], {})
rcur = r[1]
for key in keys[1:-1]:
rcur[key] = {}
rcur = rcur[key]
rcur[keys[-1]] = val
return r
else:
return (o, val)
def parse_override_var(s):
'''Parse a semicolon-separated list of strings into a sequence of values
Emits the same items in sequence as :py:func:`parsedotval` does.
'''
return (
parsedotval(item)
for item in s.split(';')
if item
)

View File

@ -12,14 +12,14 @@ class ShellPowerline(Powerline):
def load_main_config(self): def load_main_config(self):
r = super(ShellPowerline, self).load_main_config() r = super(ShellPowerline, self).load_main_config()
if self.args.config: if self.args.config_override:
mergedicts(r, self.args.config) mergedicts(r, self.args.config_override)
return r return r
def load_theme_config(self, name): def load_theme_config(self, name):
r = super(ShellPowerline, self).load_theme_config(name) r = super(ShellPowerline, self).load_theme_config(name)
if self.args.theme_option and name in self.args.theme_option: if self.args.theme_override and name in self.args.theme_override:
mergedicts(r, self.args.theme_option[name]) mergedicts(r, self.args.theme_override[name])
return r return r
def get_config_paths(self): def get_config_paths(self):

View File

@ -1,16 +0,0 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from powerline import Powerline
class TmuxPowerline(Powerline):
def init(self, config_paths):
self.paths = config_paths
return super(TmuxPowerline, self).init('tmux')
def get_config_paths(self):
if self.paths:
return self.paths
else:
return super(TmuxPowerline, self).get_config_paths()

View File

@ -15,11 +15,16 @@ from powerline.lib.dict import mergedicts
from powerline.lib.unicode import u from powerline.lib.unicode import u
def _override_from(config, override_varname): def _override_from(config, override_varname, key=None):
try: try:
overrides = vim_getvar(override_varname) overrides = vim_getvar(override_varname)
except KeyError: except KeyError:
return config return config
if key is not None:
try:
overrides = overrides[key]
except KeyError:
return config
mergedicts(config, overrides) mergedicts(config, overrides)
return config return config
@ -111,12 +116,10 @@ class VimPowerline(Powerline):
return _override_from(super(VimPowerline, self).load_main_config(), 'powerline_config_overrides') return _override_from(super(VimPowerline, self).load_main_config(), 'powerline_config_overrides')
def load_theme_config(self, name): def load_theme_config(self, name):
# Note: themes with non-[a-zA-Z0-9_] names are impossible to override
# (though as far as I know exists() wont throw). Wont fix, use proper
# theme names.
return _override_from( return _override_from(
super(VimPowerline, self).load_theme_config(name), super(VimPowerline, self).load_theme_config(name),
'powerline_theme_overrides__' + name 'powerline_theme_overrides',
name
) )
def get_local_themes(self, local_themes): def get_local_themes(self, local_themes):

View File

@ -75,11 +75,14 @@ def render(args, environ, cwd):
key = ( key = (
args.ext[0], args.ext[0],
args.renderer_module, args.renderer_module,
tuple(args.config) if args.config else None, tuple(args.config_override) if args.config_override else None,
tuple(args.theme_option) if args.theme_option else None, tuple(args.theme_override) if args.theme_override else None,
tuple(args.config_path) if args.config_path else None, tuple(args.config_path) if args.config_path else None,
environ.get('POWERLINE_THEME_OVERRIDES', ''),
environ.get('POWERLINE_CONFIG_OVERRIDES', ''),
environ.get('POWERLINE_CONFIG_PATHS', ''),
) )
finish_args(args) finish_args(environ, args)
powerline = None powerline = None
try: try:
powerline = powerlines[key] powerline = powerlines[key]

View File

@ -24,7 +24,7 @@ else:
if __name__ == '__main__': if __name__ == '__main__':
args = get_argparser().parse_args() args = get_argparser().parse_args()
finish_args(args) finish_args(os.environ, args)
powerline = ShellPowerline(args, run_once=True) powerline = ShellPowerline(args, run_once=True)
segment_info = {'args': args, 'environ': os.environ} segment_info = {'args': args, 'environ': os.environ}
write_output(args, powerline, segment_info, write, get_preferred_output_encoding()) write_output(args, powerline, segment_info, write, get_preferred_output_encoding())

View File

@ -23,8 +23,8 @@ class Pl(object):
class Args(object): class Args(object):
theme_option = {} theme_override = {}
config = None config_override = {}
config_path = None config_path = None
ext = ['shell'] ext = ['shell']
renderer_module = None renderer_module = None

View File

@ -29,6 +29,11 @@ else
OLD_VIM="$VIM" OLD_VIM="$VIM"
fi fi
# Define some overrides. These ones must be ignored and do not affect Vim
# status/tab lines.
export POWERLINE_CONFIG_OVERRIDES='common.default_top_theme=ascii'
export POWERLINE_THEME_OVERRIDES='default.segments.left=[]'
test_script() { test_script() {
local vim="$1" local vim="$1"
local script="$2" local script="$2"

View File

@ -41,8 +41,8 @@ class TestParser(TestCase):
(['shell', '--width'], 'expected one argument'), (['shell', '--width'], 'expected one argument'),
(['shell', '--last-exit-code'], 'expected one argument'), (['shell', '--last-exit-code'], 'expected one argument'),
(['shell', '--last-pipe-status'], 'expected one argument'), (['shell', '--last-pipe-status'], 'expected one argument'),
(['shell', '--config'], 'expected one argument'), (['shell', '--config-override'], 'expected one argument'),
(['shell', '--theme-option'], 'expected one argument'), (['shell', '--theme-override'], 'expected one argument'),
(['shell', '--config-path'], 'expected one argument'), (['shell', '--config-path'], 'expected one argument'),
(['shell', '--renderer-arg'], 'expected one argument'), (['shell', '--renderer-arg'], 'expected one argument'),
(['shell', '--jobnum'], 'expected one argument'), (['shell', '--jobnum'], 'expected one argument'),
@ -85,8 +85,8 @@ class TestParser(TestCase):
'last_pipe_status': [10, 20, 30], 'last_pipe_status': [10, 20, 30],
'jobnum': 10, 'jobnum': 10,
'width': 100, 'width': 100,
'config': {'common': {'term_truecolor': True, 'spaces': 4}}, 'config_override': {'common': {'term_truecolor': True, 'spaces': 4}},
'theme_option': { 'theme_override': {
'default': { 'default': {
'segment_data': { 'segment_data': {
'hostname': { 'hostname': {
@ -103,7 +103,7 @@ class TestParser(TestCase):
(['shell', '-R', 'arg='], {'ext': ['shell'], 'renderer_arg': {}}), (['shell', '-R', 'arg='], {'ext': ['shell'], 'renderer_arg': {}}),
(['shell', '-t', 'default.segment_info={"hostname": {}}'], { (['shell', '-t', 'default.segment_info={"hostname": {}}'], {
'ext': ['shell'], 'ext': ['shell'],
'theme_option': { 'theme_override': {
'default': { 'default': {
'segment_info': { 'segment_info': {
'hostname': {} 'hostname': {}
@ -111,10 +111,10 @@ class TestParser(TestCase):
} }
}, },
}), }),
(['shell', '-c', 'common={ }'], {'ext': ['shell'], 'config': {'common': {}}}), (['shell', '-c', 'common={ }'], {'ext': ['shell'], 'config_override': {'common': {}}}),
]: ]:
args = parser.parse_args(argv) args = parser.parse_args(argv)
finish_args(args) finish_args({}, args)
for key, val in expargs.items(): for key, val in expargs.items():
self.assertEqual(getattr(args, key), val) self.assertEqual(getattr(args, key), val)
for key, val in args.__dict__.items(): for key, val in args.__dict__.items():

View File

@ -2,7 +2,7 @@
set encoding=utf-8 set encoding=utf-8
let g:powerline_config_paths = [expand('<sfile>:p:h:h') . '/powerline/config_files'] let g:powerline_config_paths = [expand('<sfile>:p:h:h') . '/powerline/config_files']
let g:powerline_config_overrides = {'common': {'default_top_theme': 'ascii'}} let g:powerline_config_overrides = {'common': {'default_top_theme': 'ascii'}}
let g:powerline_theme_overrides__default = {'segment_data': {'line_current_symbol': {'contents': 'LN '}, 'branch': {'before': 'B '}}} let g:powerline_theme_overrides = {'default': {'segment_data': {'line_current_symbol': {'contents': 'LN '}, 'branch': {'before': 'B '}}}}
redir => g:messages redir => g:messages

View File

@ -138,7 +138,7 @@ class TestConfig(TestCase):
def test_bash(self): def test_bash(self):
from powerline.shell import ShellPowerline from powerline.shell import ShellPowerline
args = Args(last_exit_code=1, jobnum=0, ext=['shell'], renderer_module='.bash', config={'ext': {'shell': {'theme': 'default_leftonly'}}}) args = Args(last_exit_code=1, jobnum=0, ext=['shell'], renderer_module='.bash', config_override={'ext': {'shell': {'theme': 'default_leftonly'}}})
with ShellPowerline(args, logger=get_logger(), run_once=False) as powerline: with ShellPowerline(args, logger=get_logger(), run_once=False) as powerline:
powerline.render(segment_info={'args': args}) powerline.render(segment_info={'args': args})
with ShellPowerline(args, logger=get_logger(), run_once=False) as powerline: with ShellPowerline(args, logger=get_logger(), run_once=False) as powerline:
@ -148,7 +148,7 @@ class TestConfig(TestCase):
from powerline.ipython import IPythonPowerline from powerline.ipython import IPythonPowerline
class IpyPowerline(IPythonPowerline): class IpyPowerline(IPythonPowerline):
paths = None config_paths = None
config_overrides = None config_overrides = None
theme_overrides = {} theme_overrides = {}

View File

@ -7,8 +7,8 @@
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bgscript.sh [1]+ Terminated bgscript.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false
  BRANCH  ⋯  tests  shell  3rd  echo '   BRANCH  ⋯  tests  shell  3rd  echo '
                                     abc                                      abc
                                     def                                      def
@ -26,5 +26,5 @@ def
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'   BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'
  BRANCH  ⋯  shell  3rd  «Unicode!»  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC"   BRANCH  ⋯  shell  3rd  «Unicode!»  set_theme_option default_leftonly.dividers.left.hard \$ABC
  BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse   BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse

View File

@ -7,8 +7,8 @@
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bgscript.sh [1]+ Terminated bgscript.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false
  BRANCH  ⋯  tests  shell  3rd  echo '   BRANCH  ⋯  tests  shell  3rd  echo '
   abc    abc
   def    def
@ -26,5 +26,5 @@ def
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'   BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'
  BRANCH  ⋯  shell  3rd  «Unicode!»  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC"   BRANCH  ⋯  shell  3rd  «Unicode!»  set_theme_option default_leftonly.dividers.left.hard \$ABC
  BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse   BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse

View File

@ -6,8 +6,8 @@
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bgscript.sh [1]+ Terminated bgscript.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  set_theme_option default_leftonly.segment_data.hostname.display false
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false
  BRANCH  ⋯  tests  shell  3rd  echo '   BRANCH  ⋯  tests  shell  3rd  echo '
                                     abc                                      abc
                                     def                                      def
@ -25,5 +25,5 @@ def
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'   BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'
  BRANCH  ⋯  shell  3rd  «Unicode!»  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC"   BRANCH  ⋯  shell  3rd  «Unicode!»  set_theme_option default_leftonly.dividers.left.hard \$ABC
  BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse   BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse

View File

@ -6,8 +6,8 @@
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
[1]+ Terminated bgscript.sh [1]+ Terminated bgscript.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  set_theme_option default_leftonly.segment_data.hostname.display false
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false
  BRANCH  ⋯  tests  shell  3rd  echo '   BRANCH  ⋯  tests  shell  3rd  echo '
   abc    abc
   def    def
@ -25,5 +25,5 @@ def
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'   BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'
  BRANCH  ⋯  shell  3rd  «Unicode!»  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC"   BRANCH  ⋯  shell  3rd  «Unicode!»  set_theme_option default_leftonly.dividers.left.hard \$ABC
  BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse   BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse

View File

@ -5,8 +5,8 @@
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" set_theme_option default_leftonly.segment_data.hostname.display false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1   USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1   USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false
  BRANCH  ⋯  tests  shell  3rd  echo '   BRANCH  ⋯  tests  shell  3rd  echo '
                                     abc                                      abc
                                     def                                      def
@ -24,5 +24,5 @@ def
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'   BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'
  BRANCH  ⋯  shell  3rd  «Unicode!»  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC"   BRANCH  ⋯  shell  3rd  «Unicode!»  set_theme_option default_leftonly.dividers.left.hard \$ABC
  BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse   BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse

View File

@ -5,8 +5,8 @@
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  bgscript.sh & waitpid.sh
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" set_theme_option default_leftonly.segment_data.hostname.display false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1   USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1   USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false
  BRANCH  ⋯  tests  shell  3rd  echo '   BRANCH  ⋯  tests  shell  3rd  echo '
   abc    abc
   def    def
@ -24,5 +24,5 @@ def
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'   BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'
  BRANCH  ⋯  shell  3rd  «Unicode!»  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC"   BRANCH  ⋯  shell  3rd  «Unicode!»  set_theme_option default_leftonly.dividers.left.hard \$ABC
  BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse   BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse

View File

@ -1,7 +1,13 @@
set_theme_option() {
export POWERLINE_THEME_OVERRIDES="${POWERLINE_THEME_OVERRIDES};$1=$2"
}
set_theme() {
export POWERLINE_CONFIG_OVERRIDES="ext.shell.theme=$1"
}
set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false
set_theme default_leftonly
export VIRTUAL_ENV= export VIRTUAL_ENV=
source powerline/bindings/bash/powerline.sh source powerline/bindings/bash/powerline.sh
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false"
POWERLINE_COMMAND="$POWERLINE_COMMAND -c ext.shell.theme=default_leftonly"
cd tests/shell/3rd cd tests/shell/3rd
cd .git cd .git
cd .. cd ..
@ -10,8 +16,8 @@ VIRTUAL_ENV=
bgscript.sh & waitpid.sh bgscript.sh & waitpid.sh
false false
kill `cat pid` ; sleep 1s kill `cat pid` ; sleep 1s
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" set_theme_option default_leftonly.segment_data.hostname.display false
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false" set_theme_option default_leftonly.segment_data.user.display false
echo ' echo '
abc abc
def def
@ -25,7 +31,7 @@ cd ../'(echo)'
cd ../'$(echo)' cd ../'$(echo)'
cd ../'`echo`' cd ../'`echo`'
cd ../'«Unicode!»' cd ../'«Unicode!»'
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC" set_theme_option default_leftonly.dividers.left.hard \$ABC
false false
true is the last line true is the last line
exit exit

View File

@ -1,6 +1,12 @@
set_theme_option() {
export POWERLINE_THEME_OVERRIDES="${POWERLINE_THEME_OVERRIDES};$1=$2"
}
set_theme() {
export POWERLINE_CONFIG_OVERRIDES="ext.shell.theme=$1"
}
set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false
set_theme default_leftonly
. powerline/bindings/shell/powerline.sh . powerline/bindings/shell/powerline.sh
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false"
POWERLINE_COMMAND="$POWERLINE_COMMAND -c ext.shell.theme=default_leftonly"
export VIRTUAL_ENV= export VIRTUAL_ENV=
cd tests/shell/3rd cd tests/shell/3rd
cd .git cd .git
@ -10,8 +16,8 @@ VIRTUAL_ENV=
bgscript.sh & waitpid.sh bgscript.sh & waitpid.sh
false false
kill `cat pid` ; sleep 1s kill `cat pid` ; sleep 1s
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" set_theme_option default_leftonly.segment_data.hostname.display false
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false" set_theme_option default_leftonly.segment_data.user.display false
echo ' echo '
abc abc
def def
@ -25,7 +31,7 @@ cd ../'(echo)'
cd ../'$(echo)' cd ../'$(echo)'
cd ../'`echo`' cd ../'`echo`'
cd ../'«Unicode!»' cd ../'«Unicode!»'
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC" set_theme_option default_leftonly.dividers.left.hard \$ABC
false false
true is the last line true is the last line
exit exit

View File

@ -1,6 +1,12 @@
set_theme_option() {
export POWERLINE_THEME_OVERRIDES="${POWERLINE_THEME_OVERRIDES};$1=$2"
}
set_theme() {
export POWERLINE_CONFIG_OVERRIDES="ext.shell.theme=$1"
}
set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false
set_theme default_leftonly
. powerline/bindings/shell/powerline.sh . powerline/bindings/shell/powerline.sh
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false"
POWERLINE_COMMAND="$POWERLINE_COMMAND -c ext.shell.theme=default_leftonly"
export VIRTUAL_ENV= export VIRTUAL_ENV=
cd tests/shell/3rd cd tests/shell/3rd
cd .git cd .git
@ -10,8 +16,8 @@ VIRTUAL_ENV=
bgscript.sh & waitpid.sh bgscript.sh & waitpid.sh
false false
kill `cat pid` ; sleep 1s kill `cat pid` ; sleep 1s
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" set_theme_option default_leftonly.segment_data.hostname.display false
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false" set_theme_option default_leftonly.segment_data.user.display false
echo ' echo '
abc abc
def def
@ -25,7 +31,7 @@ cd ../'(echo)'
cd ../'$(echo)' cd ../'$(echo)'
cd ../'`echo`' cd ../'`echo`'
cd ../'«Unicode!»' cd ../'«Unicode!»'
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC" set_theme_option default_leftonly.dividers.left.hard \$ABC
false false
true is the last line true is the last line
exit exit

View File

@ -1,10 +1,16 @@
function set_theme_option
set -g -x POWERLINE_THEME_OVERRIDES "$POWERLINE_THEME_OVERRIDES;$argv[1]=$argv[2]"
end
function set_theme
set -g -x POWERLINE_CONFIG_OVERRIDES "ext.shell.theme=$argv"
end
set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false
set_theme default_leftonly
set fish_function_path "$PWD/powerline/bindings/fish" $fish_function_path set fish_function_path "$PWD/powerline/bindings/fish" $fish_function_path
while jobs | grep fish_update_completions while jobs | grep fish_update_completions
sleep 1 sleep 1
end end
powerline-setup powerline-setup
set POWERLINE_COMMAND "$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false"
set POWERLINE_COMMAND "$POWERLINE_COMMAND -c ext.shell.theme=default_leftonly"
setenv VIRTUAL_ENV setenv VIRTUAL_ENV
cd tests/shell/3rd cd tests/shell/3rd
cd .git cd .git
@ -23,7 +29,7 @@ cd ../'(echo)'
cd ../'$(echo)' cd ../'$(echo)'
cd ../'`echo`' cd ../'`echo`'
cd ../'«Unicode!»' cd ../'«Unicode!»'
set POWERLINE_COMMAND "$POWERLINE_COMMAND -c ext.shell.theme=default" set_theme default
set -g fish_key_bindings fish_vi_key_bindings set -g fish_key_bindings fish_vi_key_bindings
ii ii
false false

View File

@ -1,6 +1,12 @@
set_theme_option() {
export POWERLINE_THEME_OVERRIDES="${POWERLINE_THEME_OVERRIDES};$1=$2"
}
set_theme() {
export POWERLINE_CONFIG_OVERRIDES="ext.shell.theme=$1"
}
set_theme default_leftonly
set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false
. powerline/bindings/shell/powerline.sh . powerline/bindings/shell/powerline.sh
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.args.only_if_ssh=false"
POWERLINE_COMMAND="$POWERLINE_COMMAND -c ext.shell.theme=default_leftonly"
export VIRTUAL_ENV= export VIRTUAL_ENV=
cd tests/shell/3rd cd tests/shell/3rd
cd .git cd .git
@ -10,8 +16,8 @@ VIRTUAL_ENV=
bgscript.sh & waitpid.sh bgscript.sh & waitpid.sh
false false
kill `cat pid` ; sleep 1 kill `cat pid` ; sleep 1
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" set_theme_option default_leftonly.segment_data.hostname.display false
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false" set_theme_option default_leftonly.segment_data.user.display false
echo -n echo -n
echo ' echo '
abc abc
@ -26,7 +32,7 @@ cd ../'(echo)'
cd ../'$(echo)' cd ../'$(echo)'
cd ../'`echo`' cd ../'`echo`'
cd ../'«Unicode!»' cd ../'«Unicode!»'
POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC" set_theme_option default_leftonly.dividers.left.hard \$ABC
false false
true is the last line true is the last line
exit exit

View File

@ -1,5 +1,6 @@
setenv POWERLINE_THEME_OVERRIDES "default_leftonly.segment_data.hostname.args.only_if_ssh=false"
setenv POWERLINE_CONFIG_OVERRIDES "ext.shell.theme=default_leftonly"
source powerline/bindings/tcsh/powerline.tcsh source powerline/bindings/tcsh/powerline.tcsh
set POWERLINE_COMMAND=$POWERLINE_COMMAND:q" -t default_leftonly.segment_data.hostname.args.only_if_ssh=false -c ext.shell.theme=default_leftonly"
unsetenv VIRTUAL_ENV unsetenv VIRTUAL_ENV
cd tests/shell/3rd cd tests/shell/3rd
cd .git cd .git

View File

@ -2,28 +2,18 @@ unset HOME
unsetopt promptsp notransientrprompt unsetopt promptsp notransientrprompt
setopt interactivecomments setopt interactivecomments
setopt autonamedirs setopt autonamedirs
if test -z "$POWERLINE_NO_ZSH_ZPYTHON" ; then function set_theme_option() {
function set_theme_option() { export POWERLINE_THEME_OVERRIDES="${POWERLINE_THEME_OVERRIDES};$1=$2"
POWERLINE_THEME_CONFIG[$1]=$2
powerline-reload-config powerline-reload-config
} }
function set_theme() { function set_theme() {
typeset -A POWERLINE_CONFIG_OVERRIDES export POWERLINE_CONFIG_OVERRIDES="ext.shell.theme=$1"
POWERLINE_CONFIG_OVERRIDES=(
ext.shell.theme $1
)
powerline-reload-config powerline-reload-config
} }
else if test -n "$POWERLINE_NO_ZSH_ZPYTHON" ; then
function set_theme_option() { powerline-reload-config():
POWERLINE_COMMAND="$POWERLINE_COMMAND -t $1=$2"
}
function set_theme() {
POWERLINE_COMMAND="$POWERLINE_COMMAND -c ext.shell.theme=$1"
}
fi fi
source powerline/bindings/zsh/powerline.zsh source powerline/bindings/zsh/powerline.zsh
typeset -gA POWERLINE_CONFIG_OVERRIDES POWERLINE_THEME_CONFIG
set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false set_theme_option default_leftonly.segment_data.hostname.args.only_if_ssh false
set_theme_option default.segment_data.hostname.args.only_if_ssh false set_theme_option default.segment_data.hostname.args.only_if_ssh false
set_theme default_leftonly set_theme default_leftonly

View File

@ -8,8 +8,8 @@
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1
[1] + Terminated bash -c ... [1] + Terminated bash -c ...
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false
  BRANCH  ⋯  tests  shell  3rd  echo -n   BRANCH  ⋯  tests  shell  3rd  echo -n
  BRANCH  ⋯  tests  shell  3rd  echo '   BRANCH  ⋯  tests  shell  3rd  echo '
                                     abc                                      abc
@ -28,5 +28,5 @@ def
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'   BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'
  BRANCH  ⋯  shell  3rd  «Unicode!»  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC"   BRANCH  ⋯  shell  3rd  «Unicode!»  set_theme_option default_leftonly.dividers.left.hard \$ABC
  BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse   BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse

View File

@ -8,8 +8,8 @@
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1
[1] + Terminated bash -c ... [1] + Terminated bash -c ...
  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false"   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false
 USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false"  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false
  BRANCH  ⋯  tests  shell  3rd  echo -n   BRANCH  ⋯  tests  shell  3rd  echo -n
  BRANCH  ⋯  tests  shell  3rd  echo '   BRANCH  ⋯  tests  shell  3rd  echo '
   abc    abc
@ -28,5 +28,5 @@ def
  BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'
  BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'
  BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'   BRANCH  ⋯  shell  3rd  `echo`  cd ../'«Unicode!»'
  BRANCH  ⋯  shell  3rd  «Unicode!»  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC"   BRANCH  ⋯  shell  3rd  «Unicode!»  set_theme_option default_leftonly.dividers.left.hard \$ABC
  BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse   BRANCH $ABC⋯  shell  3rd  «Unicode!» $ABCfalse

View File

@ -76,9 +76,13 @@ run() {
XDG_CONFIG_HOME="$PWD/tests/shell/fish_home" \ XDG_CONFIG_HOME="$PWD/tests/shell/fish_home" \
IPYTHONDIR="$PWD/tests/shell/ipython_home" \ IPYTHONDIR="$PWD/tests/shell/ipython_home" \
PYTHONPATH="${PWD}${PYTHONPATH:+:}$PYTHONPATH" \ PYTHONPATH="${PWD}${PYTHONPATH:+:}$PYTHONPATH" \
POWERLINE_CONFIG_OVERRIDES="${POWERLINE_CONFIG_OVERRIDES}" \
POWERLINE_THEME_OVERRIDES="${POWERLINE_THEME_OVERRIDES}" \
POWERLINE_SHELL_CONTINUATION=$additional_prompts \ POWERLINE_SHELL_CONTINUATION=$additional_prompts \
POWERLINE_SHELL_SELECT=$additional_prompts \ POWERLINE_SHELL_SELECT=$additional_prompts \
POWERLINE_COMMAND="${POWERLINE_COMMAND} -p $PWD/powerline/config_files" \ POWERLINE_CONFIG_PATHS="$PWD/powerline/config_files" \
POWERLINE_COMMAND_ARGS="${POWERLINE_COMMAND_ARGS}" \
POWERLINE_COMMAND="${POWERLINE_COMMAND}" \
"$@" "$@"
} }
@ -302,7 +306,8 @@ if test -z "${ONLY_SHELL}" || test "x${ONLY_SHELL%sh}" != "x${ONLY_SHELL}" || te
if test "x$ONLY_TEST_CLIENT" != "x" && test "x$TEST_CLIENT" != "x$ONLY_TEST_CLIENT" ; then if test "x$ONLY_TEST_CLIENT" != "x" && test "x$TEST_CLIENT" != "x$ONLY_TEST_CLIENT" ; then
continue continue
fi fi
POWERLINE_COMMAND="$POWERLINE_COMMAND --socket $ADDRESS" POWERLINE_COMMAND_ARGS="--socket $ADDRESS"
POWERLINE_COMMAND="$POWERLINE_COMMAND"
export POWERLINE_COMMAND export POWERLINE_COMMAND
echo ">> powerline command is ${POWERLINE_COMMAND:-empty}" echo ">> powerline command is ${POWERLINE_COMMAND:-empty}"
J=-1 J=-1
@ -384,11 +389,16 @@ fi
if test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xipython" ; then if test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xipython" ; then
if which ipython >/dev/null ; then if which ipython >/dev/null ; then
# Define some overrides which should be ignored by IPython.
POWERLINE_CONFIG_OVERRIDES='common.term_escape_style=fbterm'
POWERLINE_THEME_OVERRIDES='in.segments.left=[]'
echo "> $(which ipython)" echo "> $(which ipython)"
if ! run_test ipython ipython ipython ; then if ! run_test ipython ipython ipython ; then
FAILED=1 FAILED=1
FAIL_SUMMARY="${FAIL_SUMMARY}${NL}T ipython" FAIL_SUMMARY="${FAIL_SUMMARY}${NL}T ipython"
fi fi
unset POWERLINE_THEME_OVERRIDES
unset POWERLINE_CONFIG_OVERRIDES
fi fi
fi fi