diff --git a/docs/source/configuration/local.rst b/docs/source/configuration/local.rst index ec56560c..b7c23c80 100644 --- a/docs/source/configuration/local.rst +++ b/docs/source/configuration/local.rst @@ -16,11 +16,11 @@ Vim configuration can be overridden using the following options: Dictionary, recursively merged with contents of :file:`powerline/config.json`. -``g:powerline_theme_overrides__{theme_name}`` - Dictionary, recursively merged with contents of - :file:`powerline/themes/vim/{theme_name}.json`. Note that this way you can’t - redefine some value (e.g. segment) in list, only the whole list itself: only - dictionaries are merged recursively. +``g:powerline_theme_overrides`` + Dictionary mapping theme names to theme overrides, recursively merged with + contents of :file:`powerline/themes/vim/{key}.json`. Note that this way you + can’t redefine some value (e.g. segment) in list, only the whole list + itself: only dictionaries are merged recursively. ``g:powerline_config_paths`` 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 `. Level is always :ref:`log_level `, same for format. +.. _local-configuration-overrides-script: + Powerline script overrides ========================== Powerline script has a number of options controlling powerline behavior. Here ``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`. ``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 @@ -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 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`. ``KEY.NESTED_KEY=VALUE`` is processed like described above, ``{ext}`` is the 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 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 ` + 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 `. + Latter are suggested for tests only. + Zsh/zpython overrides ===================== 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 +` are also supported: if variable is a string +this variant is used. ``POWERLINE_CONFIG_OVERRIDES`` 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 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 a zsh associative array with keys equal to ``THEME_NAME.KEY.NESTED_KEY`` and 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 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 default locations are searched for configuration. No expansions are performed thus you cannot use paths starting with ``~/``. @@ -128,10 +215,11 @@ putting powerline into different directory. .. note:: - ``$POWERLINE_COMMAND`` appears in shell scripts without quotes thus you can - specify additional parameters in bash. In tmux it is passed to ``eval`` and - depends on the shell used. POSIX-compatible shells, zsh, bash and fish will - split this variable in this case. + ``$POWERLINE_COMMAND`` is always treated as one path in shell bindings, so + you may use paths with spaces in it. To specify additional arguments one may + use ``$POWERLINE_COMMAND_ARGS``, but note that this variable exists for + testing purposes only and may be removed. One should use :ref:`Environment + variable overrides ` instead. 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 diff --git a/powerline/__init__.py b/powerline/__init__.py index b7198a86..c7dad904 100644 --- a/powerline/__init__.py +++ b/powerline/__init__.py @@ -13,6 +13,7 @@ from powerline.lib.unicode import safe_unicode, FailedUnicode from powerline.config import DEFAULT_SYSTEM_CONFIG_DIR from powerline.lib.dict import mergedicts from powerline.lib.encoding import get_preferred_output_encoding +from powerline.lib.path import join class NotInterceptedError(BaseException): @@ -29,7 +30,7 @@ def _find_config_files(search_paths, config_file, config_loader=None, loader_cal config_file += '.json' found = False 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): yield config_file_path found = True @@ -142,12 +143,12 @@ def get_config_paths(): :return: list of paths ''' 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_dirs = os.environ.get('XDG_CONFIG_DIRS', DEFAULT_SYSTEM_CONFIG_DIR) if config_dirs is not None: - config_paths[:0] = reversed([os.path.join(d, 'powerline') for d in config_dirs.split(':')]) - plugin_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), 'config_files') + config_paths[:0] = reversed([join(d, 'powerline') for d in config_dirs.split(':')]) + plugin_path = join(os.path.realpath(os.path.dirname(__file__)), 'config_files') config_paths.insert(0, plugin_path) return config_paths diff --git a/powerline/bindings/bash/powerline.sh b/powerline/bindings/bash/powerline.sh index cd454656..8f69546f 100644 --- a/powerline/bindings/bash/powerline.sh +++ b/powerline/bindings/bash/powerline.sh @@ -41,7 +41,7 @@ _powerline_init_tmux_support() { _powerline_local_prompt() { # Arguments: side, renderer_module arg, last_exit_code, jobnum, local theme - $POWERLINE_COMMAND shell $1 \ + "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \ $2 \ --last-exit-code=$3 \ --jobnum=$4 \ @@ -51,7 +51,7 @@ _powerline_local_prompt() { _powerline_prompt() { # Arguments: side, last_exit_code, jobnum - $POWERLINE_COMMAND shell $1 \ + "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \ --width="${COLUMNS:-$(_powerline_columns_fallback)}" \ -r.bash \ --last-exit-code=$2 \ diff --git a/powerline/bindings/config.py b/powerline/bindings/config.py index 8b7326e2..03b0b5bb 100644 --- a/powerline/bindings/config.py +++ b/powerline/bindings/config.py @@ -8,11 +8,12 @@ import sys from powerline.config import POWERLINE_ROOT, TMUX_CONFIG_DIRECTORY from powerline.lib.config import ConfigLoader 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.bindings.tmux import TmuxVersionInfo, run_tmux_command, set_tmux_environment, get_tmux_version from powerline.lib.encoding import get_preferred_output_encoding 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\d+)\.(?P\d+)(?P[a-z]+)?(?:_(?Pplus|minus))?\.conf') @@ -77,10 +78,19 @@ def source_tmux_files(pl, args): 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): '''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 # directly powerline.update_renderer() diff --git a/powerline/bindings/fish/powerline-setup.fish b/powerline/bindings/fish/powerline-setup.fish index 3eabff4d..6cdf0e5a 100644 --- a/powerline/bindings/fish/powerline-setup.fish +++ b/powerline/bindings/fish/powerline-setup.fish @@ -65,10 +65,10 @@ function powerline-setup end eval " function fish_prompt - $POWERLINE_COMMAND shell $promptside $addargs + env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell $promptside $addargs end function fish_right_prompt - $POWERLINE_COMMAND shell right $addargs + env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell right $addargs $rpromptpast end function --on-signal WINCH _powerline_set_columns diff --git a/powerline/bindings/ipython/post_0_11.py b/powerline/bindings/ipython/post_0_11.py index bf2358ac..3d8aea0d 100644 --- a/powerline/bindings/ipython/post_0_11.py +++ b/powerline/bindings/ipython/post_0_11.py @@ -72,7 +72,7 @@ class ConfigurableIPythonPowerline(IPythonPowerline): config = ip.config.Powerline self.config_overrides = config.get('config_overrides') self.theme_overrides = config.get('theme_overrides', {}) - self.paths = config.get('paths') + self.config_paths = config.get('config_paths') super(ConfigurableIPythonPowerline, self).init() def do_setup(self, ip, shutdown_hook): diff --git a/powerline/bindings/ipython/pre_0_11.py b/powerline/bindings/ipython/pre_0_11.py index 6e5e356d..fa34cd86 100644 --- a/powerline/bindings/ipython/pre_0_11.py +++ b/powerline/bindings/ipython/pre_0_11.py @@ -95,10 +95,10 @@ class PowerlinePrompt2(PowerlinePromptOut): 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.theme_overrides = theme_overrides - self.paths = paths + self.config_paths = config_paths super(ConfigurableIPythonPowerline, self).init() def ipython_magic(self, ip, parameter_s=''): diff --git a/powerline/bindings/shell/powerline.sh b/powerline/bindings/shell/powerline.sh index 29a13094..7ae7237f 100644 --- a/powerline/bindings/shell/powerline.sh +++ b/powerline/bindings/shell/powerline.sh @@ -136,7 +136,7 @@ _powerline_set_jobs() { _powerline_local_prompt() { # Arguments: side, exit_code, local theme _powerline_set_jobs - $POWERLINE_COMMAND shell $1 \ + "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \ $_POWERLINE_RENDERER_ARG \ --renderer-arg="client_id=$$" \ --last-exit-code=$2 \ @@ -147,7 +147,7 @@ _powerline_local_prompt() { _powerline_prompt() { # Arguments: side, exit_code _powerline_set_jobs - $POWERLINE_COMMAND shell $1 \ + "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \ --width="${COLUMNS:-$(_powerline_columns_fallback)}" \ $_POWERLINE_RENDERER_ARG \ --renderer-arg="client_id=$$" \ diff --git a/powerline/bindings/tcsh/powerline.tcsh b/powerline/bindings/tcsh/powerline.tcsh index 386ea3ee..502e95e3 100644 --- a/powerline/bindings/tcsh/powerline.tcsh +++ b/powerline/bindings/tcsh/powerline.tcsh @@ -32,15 +32,18 @@ if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses prompt } ) then set POWERLINE_COMMAND="`$POWERLINE_CONFIG_COMMAND:q shell command`" endif endif + if ! $?POWERLINE_COMMAND_ARGS then + set POWERLINE_COMMAND_ARGS="" + endif if ( $?POWERLINE_NO_TCSH_ABOVE || $?POWERLINE_NO_SHELL_ABOVE ) then alias _powerline_above true 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 - 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_rprompt 'set rprompt="`$POWERLINE_COMMAND shell right -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: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 precmd 'set POWERLINE_STATUS=$? ; '"`alias precmd`"' ; _powerline_set_columns ; _powerline_above ; _powerline_set_prompt ; _powerline_set_rprompt' diff --git a/powerline/bindings/tmux/powerline-base.conf b/powerline/bindings/tmux/powerline-base.conf index 38b5de60..cc0eedc8 100644 --- a/powerline/bindings/tmux/powerline-base.conf +++ b/powerline/bindings/tmux/powerline-base.conf @@ -2,7 +2,7 @@ set -g status on set -g status-utf8 on set -g status-interval 2 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 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" diff --git a/powerline/bindings/tmux/powerline_tmux_1.8_plus.conf b/powerline/bindings/tmux/powerline_tmux_1.8_plus.conf index d3e1e153..7d694e8a 100644 --- a/powerline/bindings/tmux/powerline_tmux_1.8_plus.conf +++ b/powerline/bindings/tmux/powerline_tmux_1.8_plus.conf @@ -1,5 +1,5 @@ # powerline_tmux_1.8_plus.conf # tmux Version 1.8 introduces the 'client_prefix' format variable, applicable # 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 diff --git a/powerline/bindings/zsh/__init__.py b/powerline/bindings/zsh/__init__.py index a54c6cfd..3eab4d79 100644 --- a/powerline/bindings/zsh/__init__.py +++ b/powerline/bindings/zsh/__init__.py @@ -8,7 +8,7 @@ from weakref import WeakValueDictionary, ref import zsh 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.encoding import (get_preferred_output_encoding, get_preferred_environment_encoding) @@ -25,7 +25,13 @@ def shutdown(): def get_var_config(var): 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: return None @@ -36,12 +42,12 @@ class Args(object): renderer_module = '.zsh' @property - def config(self): + def config_override(self): return get_var_config('POWERLINE_CONFIG_OVERRIDES') @property - def theme_option(self): - return get_var_config('POWERLINE_THEME_CONFIG') + def theme_override(self): + return get_var_config('POWERLINE_THEME_OVERRIDES') @property def config_path(self): @@ -51,7 +57,11 @@ class Args(object): return None else: 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: return ret @@ -91,7 +101,7 @@ class Environment(object): return False -environ = Environment() +environ = getattr(zsh, 'environ', Environment()) class ZshPowerline(ShellPowerline): diff --git a/powerline/bindings/zsh/powerline.zsh b/powerline/bindings/zsh/powerline.zsh index e025201b..d433d3de 100644 --- a/powerline/bindings/zsh/powerline.zsh +++ b/powerline/bindings/zsh/powerline.zsh @@ -151,11 +151,11 @@ _powerline_setup_prompt() { local add_args_2=$add_args$new_args_2 add_args+=' --width=$(( ${COLUMNS:-$(_powerline_columns_fallback)} - ${ZLE_RPROMPT_INDENT:-1} ))' local add_args_r2=$add_args$new_args_2 - PS1='$($=POWERLINE_COMMAND shell aboveleft '$add_args')' - RPS1='$($=POWERLINE_COMMAND shell right '$add_args')' - PS2='$($=POWERLINE_COMMAND shell left '$add_args_2')' - RPS2='$($=POWERLINE_COMMAND shell right '$add_args_r2')' - PS3='$($=POWERLINE_COMMAND shell left '$add_args_3')' + PS1='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell aboveleft '$add_args')' + RPS1='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell right '$add_args')' + PS2='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell left '$add_args_2')' + RPS2='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell right '$add_args_r2')' + PS3='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell left '$add_args_3')' fi } diff --git a/powerline/commands/lint.py b/powerline/commands/lint.py index a09aa35c..27010d3d 100755 --- a/powerline/commands/lint.py +++ b/powerline/commands/lint.py @@ -6,6 +6,6 @@ import argparse def get_argparser(ArgumentParser=argparse.ArgumentParser): 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.') return parser diff --git a/powerline/commands/main.py b/powerline/commands/main.py index 03e53618..7c05874f 100644 --- a/powerline/commands/main.py +++ b/powerline/commands/main.py @@ -5,7 +5,9 @@ from __future__ import (division, absolute_import, print_function) import argparse 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.encoding import get_preferred_arguments_encoding @@ -14,21 +16,43 @@ if sys.version_info < (3,): encoding = get_preferred_arguments_encoding() 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: def arg_to_unicode(s): return s -def finish_args(args): - if args.config: - args.config = mergeargs((parsedotval(v) for v in args.config)) - if args.theme_option: - args.theme_option = mergeargs((parsedotval(v) for v in args.theme_option)) - else: - args.theme_option = {} +def finish_args(environ, args): + '''Do some final transformations + + Transforms ``*_override`` arguments into dictionaries, adding overrides from + environment variables. Transforms ``renderer_arg`` argument into dictionary + as well, but only if it is true. + + :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: - 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): @@ -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-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('-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('-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('-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-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('-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).') diff --git a/powerline/ipython.py b/powerline/ipython.py index 8c4ec991..6e22c41b 100644 --- a/powerline/ipython.py +++ b/powerline/ipython.py @@ -32,8 +32,8 @@ class IPythonPowerline(Powerline): ) def get_config_paths(self): - if self.paths: - return self.paths + if self.config_paths: + return self.config_paths else: return super(IPythonPowerline, self).get_config_paths() diff --git a/powerline/lib/__init__.py b/powerline/lib/__init__.py index af3b9913..2a5fbd09 100644 --- a/powerline/lib/__init__.py +++ b/powerline/lib/__init__.py @@ -1,12 +1,8 @@ # vim:fileencoding=utf-8:noet from __future__ import (unicode_literals, division, absolute_import, print_function) -import json - from functools import wraps -from powerline.lib.dict import REMOVE_THIS_KEY - def wraps_saveargs(wrapped): def dec(wrapper): @@ -30,59 +26,3 @@ def add_divider_highlight_group(highlight_group): return None return f 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) diff --git a/powerline/lib/dict.py b/powerline/lib/dict.py index 95b90c86..76728aba 100644 --- a/powerline/lib/dict.py +++ b/powerline/lib/dict.py @@ -5,26 +5,44 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct REMOVE_THIS_KEY = object() -def mergeargs(argvalue): +def mergeargs(argvalue, remove=False): if not argvalue: return None r = {} for subval in argvalue: - mergedicts(r, dict([subval])) + mergedicts(r, dict([subval]), remove=remove) 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 First dictionary is modified in-place. ''' for k in d2: if k in d1 and isinstance(d1[k], dict) and isinstance(d2[k], dict): - mergedicts(d1[k], d2[k]) - elif d2[k] is REMOVE_THIS_KEY: + mergedicts(d1[k], d2[k], remove) + elif remove and d2[k] is REMOVE_THIS_KEY: d1.pop(k, None) else: + if remove and isinstance(d2[k], dict): + _clear_special_values(d2[k]) d1[k] = d2[k] diff --git a/powerline/lib/overrides.py b/powerline/lib/overrides.py new file mode 100644 index 00000000..cf0ac7b1 --- /dev/null +++ b/powerline/lib/overrides.py @@ -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 + ) diff --git a/powerline/shell.py b/powerline/shell.py index d5b73c2e..e10692c1 100644 --- a/powerline/shell.py +++ b/powerline/shell.py @@ -12,14 +12,14 @@ class ShellPowerline(Powerline): def load_main_config(self): r = super(ShellPowerline, self).load_main_config() - if self.args.config: - mergedicts(r, self.args.config) + if self.args.config_override: + mergedicts(r, self.args.config_override) return r def load_theme_config(self, name): r = super(ShellPowerline, self).load_theme_config(name) - if self.args.theme_option and name in self.args.theme_option: - mergedicts(r, self.args.theme_option[name]) + if self.args.theme_override and name in self.args.theme_override: + mergedicts(r, self.args.theme_override[name]) return r def get_config_paths(self): diff --git a/powerline/tmux.py b/powerline/tmux.py deleted file mode 100644 index 15f42127..00000000 --- a/powerline/tmux.py +++ /dev/null @@ -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() diff --git a/powerline/vim.py b/powerline/vim.py index d9cf8013..b93788a8 100644 --- a/powerline/vim.py +++ b/powerline/vim.py @@ -15,11 +15,16 @@ from powerline.lib.dict import mergedicts from powerline.lib.unicode import u -def _override_from(config, override_varname): +def _override_from(config, override_varname, key=None): try: overrides = vim_getvar(override_varname) except KeyError: return config + if key is not None: + try: + overrides = overrides[key] + except KeyError: + return config mergedicts(config, overrides) return config @@ -111,12 +116,10 @@ class VimPowerline(Powerline): return _override_from(super(VimPowerline, self).load_main_config(), 'powerline_config_overrides') 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() won’t throw). Won’t fix, use proper - # theme names. return _override_from( super(VimPowerline, self).load_theme_config(name), - 'powerline_theme_overrides__' + name + 'powerline_theme_overrides', + name ) def get_local_themes(self, local_themes): diff --git a/scripts/powerline-daemon b/scripts/powerline-daemon index 7e78b6b0..ad7bd47d 100755 --- a/scripts/powerline-daemon +++ b/scripts/powerline-daemon @@ -75,11 +75,14 @@ def render(args, environ, cwd): key = ( args.ext[0], args.renderer_module, - tuple(args.config) if args.config else None, - tuple(args.theme_option) if args.theme_option else None, + tuple(args.config_override) if args.config_override else None, + tuple(args.theme_override) if args.theme_override 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 try: powerline = powerlines[key] diff --git a/scripts/powerline-render b/scripts/powerline-render index 5e4eb05a..07016705 100755 --- a/scripts/powerline-render +++ b/scripts/powerline-render @@ -24,7 +24,7 @@ else: if __name__ == '__main__': args = get_argparser().parse_args() - finish_args(args) + finish_args(os.environ, args) powerline = ShellPowerline(args, run_once=True) segment_info = {'args': args, 'environ': os.environ} write_output(args, powerline, segment_info, write, get_preferred_output_encoding()) diff --git a/tests/lib/__init__.py b/tests/lib/__init__.py index 2b5af567..b9c0d3ad 100644 --- a/tests/lib/__init__.py +++ b/tests/lib/__init__.py @@ -23,8 +23,8 @@ class Pl(object): class Args(object): - theme_option = {} - config = None + theme_override = {} + config_override = {} config_path = None ext = ['shell'] renderer_module = None diff --git a/tests/run_vim_tests.sh b/tests/run_vim_tests.sh index 0856a381..54612e53 100755 --- a/tests/run_vim_tests.sh +++ b/tests/run_vim_tests.sh @@ -29,6 +29,11 @@ else OLD_VIM="$VIM" 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() { local vim="$1" local script="$2" diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index a4539964..1244e25d 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -41,8 +41,8 @@ class TestParser(TestCase): (['shell', '--width'], 'expected one argument'), (['shell', '--last-exit-code'], 'expected one argument'), (['shell', '--last-pipe-status'], 'expected one argument'), - (['shell', '--config'], 'expected one argument'), - (['shell', '--theme-option'], 'expected one argument'), + (['shell', '--config-override'], 'expected one argument'), + (['shell', '--theme-override'], 'expected one argument'), (['shell', '--config-path'], 'expected one argument'), (['shell', '--renderer-arg'], 'expected one argument'), (['shell', '--jobnum'], 'expected one argument'), @@ -85,8 +85,8 @@ class TestParser(TestCase): 'last_pipe_status': [10, 20, 30], 'jobnum': 10, 'width': 100, - 'config': {'common': {'term_truecolor': True, 'spaces': 4}}, - 'theme_option': { + 'config_override': {'common': {'term_truecolor': True, 'spaces': 4}}, + 'theme_override': { 'default': { 'segment_data': { 'hostname': { @@ -103,7 +103,7 @@ class TestParser(TestCase): (['shell', '-R', 'arg='], {'ext': ['shell'], 'renderer_arg': {}}), (['shell', '-t', 'default.segment_info={"hostname": {}}'], { 'ext': ['shell'], - 'theme_option': { + 'theme_override': { 'default': { 'segment_info': { '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) - finish_args(args) + finish_args({}, args) for key, val in expargs.items(): self.assertEqual(getattr(args, key), val) for key, val in args.__dict__.items(): diff --git a/tests/test_local_overrides.vim b/tests/test_local_overrides.vim index f6cf0931..353c086d 100755 --- a/tests/test_local_overrides.vim +++ b/tests/test_local_overrides.vim @@ -2,7 +2,7 @@ set encoding=utf-8 let g:powerline_config_paths = [expand(':p:h:h') . '/powerline/config_files'] 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 diff --git a/tests/test_provided_config_files.py b/tests/test_provided_config_files.py index 50aef95b..00eec49c 100644 --- a/tests/test_provided_config_files.py +++ b/tests/test_provided_config_files.py @@ -138,7 +138,7 @@ class TestConfig(TestCase): 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'}}}) + 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: powerline.render(segment_info={'args': args}) with ShellPowerline(args, logger=get_logger(), run_once=False) as powerline: @@ -148,7 +148,7 @@ class TestConfig(TestCase): from powerline.ipython import IPythonPowerline class IpyPowerline(IPythonPowerline): - paths = None + config_paths = None config_overrides = None theme_overrides = {} diff --git a/tests/test_shells/bash.daemon.ok b/tests/test_shells/bash.daemon.ok index f6c3d0ff..e4535b1e 100644 --- a/tests/test_shells/bash.daemon.ok +++ b/tests/test_shells/bash.daemon.ok @@ -7,8 +7,8 @@   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s [1]+ Terminated bgscript.sh -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" - USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false + USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false   BRANCH  ⋯  tests  shell  3rd  echo '                                      abc                                      def @@ -26,5 +26,5 @@ def   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   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 diff --git a/tests/test_shells/bash.nodaemon.ok b/tests/test_shells/bash.nodaemon.ok index 36e317fe..56dd1fc5 100644 --- a/tests/test_shells/bash.nodaemon.ok +++ b/tests/test_shells/bash.nodaemon.ok @@ -7,8 +7,8 @@   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s [1]+ Terminated bgscript.sh -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" - USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.display false + USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false   BRANCH  ⋯  tests  shell  3rd  echo '    abc    def @@ -26,5 +26,5 @@ def   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   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 diff --git a/tests/test_shells/busybox.daemon.ok b/tests/test_shells/busybox.daemon.ok index fcaf7474..0230f4de 100644 --- a/tests/test_shells/busybox.daemon.ok +++ b/tests/test_shells/busybox.daemon.ok @@ -6,8 +6,8 @@   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s [1]+ Terminated bgscript.sh -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" - USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  set_theme_option default_leftonly.segment_data.hostname.display false + USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false   BRANCH  ⋯  tests  shell  3rd  echo '                                      abc                                      def @@ -25,5 +25,5 @@ def   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   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 diff --git a/tests/test_shells/busybox.nodaemon.ok b/tests/test_shells/busybox.nodaemon.ok index f3edb6e8..fa485401 100644 --- a/tests/test_shells/busybox.nodaemon.ok +++ b/tests/test_shells/busybox.nodaemon.ok @@ -6,8 +6,8 @@   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1s [1]+ Terminated bgscript.sh -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" - USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  set_theme_option default_leftonly.segment_data.hostname.display false + USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.user.display false   BRANCH  ⋯  tests  shell  3rd  echo '    abc    def @@ -25,5 +25,5 @@ def   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   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 diff --git a/tests/test_shells/dash.daemon.ok b/tests/test_shells/dash.daemon.ok index cbcd8f79..042665d8 100644 --- a/tests/test_shells/dash.daemon.ok +++ b/tests/test_shells/dash.daemon.ok @@ -5,8 +5,8 @@   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  1  kill `cat pid` ; sleep 1s -POWERLINE_COMMAND="$POWERLINE_COMMAND -t 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" +set_theme_option default_leftonly.segment_data.hostname.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 '                                      abc                                      def @@ -24,5 +24,5 @@ def   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   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 diff --git a/tests/test_shells/dash.nodaemon.ok b/tests/test_shells/dash.nodaemon.ok index 64e455b6..bac163c1 100644 --- a/tests/test_shells/dash.nodaemon.ok +++ b/tests/test_shells/dash.nodaemon.ok @@ -5,8 +5,8 @@   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  1  kill `cat pid` ; sleep 1s -POWERLINE_COMMAND="$POWERLINE_COMMAND -t 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" +set_theme_option default_leftonly.segment_data.hostname.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 '    abc    def @@ -24,5 +24,5 @@ def   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   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 diff --git a/tests/test_shells/input.bash b/tests/test_shells/input.bash index 4ad925fc..0a1c0165 100644 --- a/tests/test_shells/input.bash +++ b/tests/test_shells/input.bash @@ -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= 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 .git cd .. @@ -10,8 +16,8 @@ VIRTUAL_ENV= bgscript.sh & waitpid.sh false kill `cat pid` ; sleep 1s -POWERLINE_COMMAND="$POWERLINE_COMMAND -t 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.hostname.display false +set_theme_option default_leftonly.segment_data.user.display false echo ' abc def @@ -25,7 +31,7 @@ cd ../'(echo)' cd ../'$(echo)' cd ../'`echo`' cd ../'«Unicode!»' -POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC" +set_theme_option default_leftonly.dividers.left.hard \$ABC false true is the last line exit diff --git a/tests/test_shells/input.busybox b/tests/test_shells/input.busybox index 94bee2f5..16824d7b 100644 --- a/tests/test_shells/input.busybox +++ b/tests/test_shells/input.busybox @@ -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_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= cd tests/shell/3rd cd .git @@ -10,8 +16,8 @@ VIRTUAL_ENV= bgscript.sh & waitpid.sh false kill `cat pid` ; sleep 1s -POWERLINE_COMMAND="$POWERLINE_COMMAND -t 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.hostname.display false +set_theme_option default_leftonly.segment_data.user.display false echo ' abc def @@ -25,7 +31,7 @@ cd ../'(echo)' cd ../'$(echo)' cd ../'`echo`' cd ../'«Unicode!»' -POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC" +set_theme_option default_leftonly.dividers.left.hard \$ABC false true is the last line exit diff --git a/tests/test_shells/input.dash b/tests/test_shells/input.dash index 94bee2f5..16824d7b 100644 --- a/tests/test_shells/input.dash +++ b/tests/test_shells/input.dash @@ -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_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= cd tests/shell/3rd cd .git @@ -10,8 +16,8 @@ VIRTUAL_ENV= bgscript.sh & waitpid.sh false kill `cat pid` ; sleep 1s -POWERLINE_COMMAND="$POWERLINE_COMMAND -t 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.hostname.display false +set_theme_option default_leftonly.segment_data.user.display false echo ' abc def @@ -25,7 +31,7 @@ cd ../'(echo)' cd ../'$(echo)' cd ../'`echo`' cd ../'«Unicode!»' -POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC" +set_theme_option default_leftonly.dividers.left.hard \$ABC false true is the last line exit diff --git a/tests/test_shells/input.fish b/tests/test_shells/input.fish index 0e09b54d..968248f1 100644 --- a/tests/test_shells/input.fish +++ b/tests/test_shells/input.fish @@ -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 while jobs | grep fish_update_completions sleep 1 end 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 cd tests/shell/3rd cd .git @@ -23,7 +29,7 @@ cd ../'(echo)' cd ../'$(echo)' cd ../'`echo`' cd ../'«Unicode!»' -set POWERLINE_COMMAND "$POWERLINE_COMMAND -c ext.shell.theme=default" +set_theme default set -g fish_key_bindings fish_vi_key_bindings ii false diff --git a/tests/test_shells/input.mksh b/tests/test_shells/input.mksh index 8174254a..1656800e 100644 --- a/tests/test_shells/input.mksh +++ b/tests/test_shells/input.mksh @@ -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_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= cd tests/shell/3rd cd .git @@ -10,8 +16,8 @@ VIRTUAL_ENV= bgscript.sh & waitpid.sh false kill `cat pid` ; sleep 1 -POWERLINE_COMMAND="$POWERLINE_COMMAND -t 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.hostname.display false +set_theme_option default_leftonly.segment_data.user.display false echo -n echo ' abc @@ -26,7 +32,7 @@ cd ../'(echo)' cd ../'$(echo)' cd ../'`echo`' cd ../'«Unicode!»' -POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.dividers.left.hard=\$ABC" +set_theme_option default_leftonly.dividers.left.hard \$ABC false true is the last line exit diff --git a/tests/test_shells/input.tcsh b/tests/test_shells/input.tcsh index 5302783b..509c7ae6 100644 --- a/tests/test_shells/input.tcsh +++ b/tests/test_shells/input.tcsh @@ -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 -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 cd tests/shell/3rd cd .git diff --git a/tests/test_shells/input.zsh b/tests/test_shells/input.zsh index 44f74e1b..7775ba97 100644 --- a/tests/test_shells/input.zsh +++ b/tests/test_shells/input.zsh @@ -2,28 +2,18 @@ unset HOME unsetopt promptsp notransientrprompt setopt interactivecomments setopt autonamedirs -if test -z "$POWERLINE_NO_ZSH_ZPYTHON" ; then - function set_theme_option() { - POWERLINE_THEME_CONFIG[$1]=$2 - powerline-reload-config - } - function set_theme() { - typeset -A POWERLINE_CONFIG_OVERRIDES - POWERLINE_CONFIG_OVERRIDES=( - ext.shell.theme $1 - ) - powerline-reload-config - } -else - function set_theme_option() { - POWERLINE_COMMAND="$POWERLINE_COMMAND -t $1=$2" - } - function set_theme() { - POWERLINE_COMMAND="$POWERLINE_COMMAND -c ext.shell.theme=$1" - } +function set_theme_option() { + export POWERLINE_THEME_OVERRIDES="${POWERLINE_THEME_OVERRIDES};$1=$2" + powerline-reload-config +} +function set_theme() { + export POWERLINE_CONFIG_OVERRIDES="ext.shell.theme=$1" + powerline-reload-config +} +if test -n "$POWERLINE_NO_ZSH_ZPYTHON" ; then + powerline-reload-config(): fi 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.segment_data.hostname.args.only_if_ssh false set_theme default_leftonly diff --git a/tests/test_shells/mksh.daemon.ok b/tests/test_shells/mksh.daemon.ok index 72d58e3d..3619f422 100644 --- a/tests/test_shells/mksh.daemon.ok +++ b/tests/test_shells/mksh.daemon.ok @@ -8,8 +8,8 @@   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1 [1] + Terminated bash -c ... -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" - USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.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 '                                      abc @@ -28,5 +28,5 @@ def   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   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 diff --git a/tests/test_shells/mksh.nodaemon.ok b/tests/test_shells/mksh.nodaemon.ok index a3550ca6..754633ab 100644 --- a/tests/test_shells/mksh.nodaemon.ok +++ b/tests/test_shells/mksh.nodaemon.ok @@ -8,8 +8,8 @@   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  false   HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  1  1  kill `cat pid` ; sleep 1 [1] + Terminated bash -c ... -  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.hostname.display=false" - USER   BRANCH  ⋯  tests  shell  3rd  POWERLINE_COMMAND="$POWERLINE_COMMAND -t default_leftonly.segment_data.user.display=false" +  HOSTNAME  USER   BRANCH  ⋯  tests  shell  3rd  set_theme_option default_leftonly.segment_data.hostname.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 '    abc @@ -28,5 +28,5 @@ def   BRANCH  ⋯  shell  3rd  (echo)  cd ../'$(echo)'   BRANCH  ⋯  shell  3rd  $(echo)  cd ../'`echo`'   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 diff --git a/tests/test_shells/test.sh b/tests/test_shells/test.sh index 03ac0ebb..4244c976 100755 --- a/tests/test_shells/test.sh +++ b/tests/test_shells/test.sh @@ -76,9 +76,13 @@ run() { XDG_CONFIG_HOME="$PWD/tests/shell/fish_home" \ IPYTHONDIR="$PWD/tests/shell/ipython_home" \ PYTHONPATH="${PWD}${PYTHONPATH:+:}$PYTHONPATH" \ + POWERLINE_CONFIG_OVERRIDES="${POWERLINE_CONFIG_OVERRIDES}" \ + POWERLINE_THEME_OVERRIDES="${POWERLINE_THEME_OVERRIDES}" \ POWERLINE_SHELL_CONTINUATION=$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 continue fi - POWERLINE_COMMAND="$POWERLINE_COMMAND --socket $ADDRESS" + POWERLINE_COMMAND_ARGS="--socket $ADDRESS" + POWERLINE_COMMAND="$POWERLINE_COMMAND" export POWERLINE_COMMAND echo ">> powerline command is ${POWERLINE_COMMAND:-empty}" J=-1 @@ -384,11 +389,16 @@ fi if test "x${ONLY_SHELL}" = "x" || test "x${ONLY_SHELL}" = "xipython" ; 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)" if ! run_test ipython ipython ipython ; then FAILED=1 FAIL_SUMMARY="${FAIL_SUMMARY}${NL}T ipython" fi + unset POWERLINE_THEME_OVERRIDES + unset POWERLINE_CONFIG_OVERRIDES fi fi