Skip to content

Commit

Permalink
Relese 2.5.1
Browse files Browse the repository at this point in the history
- Made more robust theme default.
- Made it use hglib in place of unstable mercurial plugin API.
- Fixed latest fish version support.
- Some other fixes and documentation adjustments
  • Loading branch information
ZyX-I committed Feb 5, 2017
2 parents 6e2e0b2 + 0240643 commit 5718616
Show file tree
Hide file tree
Showing 47 changed files with 841 additions and 571 deletions.
2 changes: 1 addition & 1 deletion docs/source/configuration/listers.rst
Expand Up @@ -29,7 +29,7 @@ Pdb listers
:members:

i3wm listers
----------
------------

.. automodule:: powerline.listers.i3wm
:members:
7 changes: 5 additions & 2 deletions docs/source/configuration/reference.rst
Expand Up @@ -144,8 +144,8 @@ Common configuration is a subdictionary that is a value of ``common`` key in

``default_top_theme``
String, determines which top-level theme will be used as the default.
Defaults to ``powerline`` in unicode locales and ``ascii`` in non-unicode
locales. See `Themes`_ section for more details.
Defaults to ``powerline_terminus`` in unicode locales and ``ascii`` in
non-unicode locales. See `Themes`_ section for more details.

Extension-specific configuration
--------------------------------
Expand Down Expand Up @@ -191,6 +191,8 @@ Common configuration is a subdictionary that is a value of ``ext`` key in
``{output : theme_name}`` that maps the ``xrandr`` output names to the
local themes to use on that output.

.. _config-ext-components:

``components``
Determines which extension components should be enabled. This key is highly
extension-specific, here is the table of extensions and corresponding
Expand Down Expand Up @@ -329,6 +331,7 @@ powerline_unicode7 Theme with powerline dividers and unicode-7 symbols
unicode Theme without any symbols from private use area
unicode_terminus Theme containing only symbols from terminus PCF font
unicode_terminus_condensed Like above, but occupies as less space as possible
powerline_terminus Like unicode_terminus, but with powerline symbols
ascii Theme without any unicode characters at all
========================== ====================================================

Expand Down
10 changes: 5 additions & 5 deletions docs/source/installation.rst
Expand Up @@ -22,8 +22,8 @@ Generic requirements
faster than python version of the client, but still slower than C version.
* ``psutil`` python package. Required for some segments like cpu_percent. Some
segments have linux-only fallbacks for ``psutil`` functionality.
* ``mercurial`` python package (note: *not* standalone executable). Required to
work with mercurial repositories.
* ``hglib`` python package *and* mercurial executable. Required to work with
mercurial repositories.
* ``pygit2`` python package or ``git`` executable. Required to work with ``git``
repositories.
* ``bzr`` python package (note: *not* standalone executable). Required to work
Expand All @@ -35,8 +35,8 @@ Generic requirements
:py:func:`powerline.listers.i3wm.output_lister`.

.. note::
Until mercurial and bazaar support Python-3 or PyPy powerline will not
support repository information when running in these interpreters.
Until bazaar supports Python-3 or PyPy powerline will not support
repository information when running in these interpreters.

.. _repository-root:

Expand Down Expand Up @@ -95,7 +95,7 @@ Fonts installation

Powerline uses several special glyphs to get the arrow effect and some custom
symbols for developers. This requires having either a symbol font or a patched
font installed in the system. Used application (e.g. terminal emulator) must
font installed in the system. The used application (e.g. terminal emulator) must
also either be configured to use patched fonts (in some cases even support it
because custom glyphs live in private use area which some applications reserve
for themselves) or support fontconfig for powerline to work properly with
Expand Down
43 changes: 43 additions & 0 deletions docs/source/usage/other.rst
Expand Up @@ -17,6 +17,10 @@ If installed using pip just add
(replace ``python`` with ``python3`` if appropriate) to the :file:`vimrc`.

.. note::
Status line will not appear by default when there is only a single window
displayed. Run ``:h 'laststatus'`` in Vim for more information.

If the repository was just cloned the following line needs to be added to the
:file:`vimrc`:

Expand Down Expand Up @@ -100,6 +104,29 @@ root <repository-root>`)::

to :file:`.tmux.conf`.

.. warning::
Segments which depend on current working directory (e.g.
:py:func:`powerline.segments.common.vcs.branch`) require also setting up
:ref:`shell bindings <usage-shell>`. It is not required to use powerline
shell prompt, :ref:`components setting <config-ext-components>` allows to
set up only powerline bindings for tmux without altering your prompt.
Without setting up shell bindings powerline will use current working
directory of *tmux server* which is probably not what you need.

Segments which depend on environment like
:py:func:`powerline.segments.common.env.virtualenv` will not work at all
(i.e. they will use environment of the tmux server), tracking environment
changes is going to slow down shell a lot.

In any case it is suggested to avoid both kinds of segments in tmux
:ref:`themes <config-themes>` because even support for tracking current
directory is very limited:

#. It works only in shell. Should you e.g. run Vim and run ``:cd`` there you
will get current working directory from shell.
#. It works only in local shell and requires configuring it.
#. Some shells are not supported at all.

IPython prompt
==============

Expand All @@ -124,6 +151,22 @@ For IPython>=0.11 add the following line to
'powerline.bindings.ipython.post_0_11'
]
For IPython>=5.0 you may use the above set up, but it is deprecated. It is
suggested to use

.. code-block:: Python
from powerline.bindings.ipython.since_5 import PowerlinePrompts
c = get_config()
c.TerminalInteractiveShell.simple_prompt = False
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
.. note::
Setting ``simple_prompt`` to False after IPython-5.0 is required regardless
of whether you use ``c.InteractiveShellApp.extensions`` setting or
``c.TerminalInteractiveShell.prompts_class``. But you probably already have
this line because IPython is not very useful without it.

IPython=0.11* is not supported and does not work. IPython<0.10 was not
tested (not installable by pip).

Expand Down
2 changes: 2 additions & 0 deletions docs/source/usage/shell-prompts.rst
@@ -1,3 +1,5 @@
.. _usage-shell:

*************
Shell prompts
*************
Expand Down
18 changes: 14 additions & 4 deletions powerline/__init__.py
Expand Up @@ -298,6 +298,18 @@ def create_logger(common_config, use_daemon_threads=True, ext='__unknown__',
return logger, pl, get_module_attr


def get_default_theme(is_unicode=True):
'''Get default theme used by powerline
:param bool is_unicode:
If true, return theme for unicode environments, otherwise return theme
that is supposed to be ASCII-only.
:return: theme name.
'''
return 'powerline_terminus' if is_unicode else 'ascii'


def finish_common_config(encoding, common_config):
'''Add default values to common config and expand ~ in paths
Expand All @@ -309,10 +321,8 @@ def finish_common_config(encoding, common_config):
paths.
'''
encoding = encoding.lower()
if encoding.startswith('utf') or encoding.startswith('ucs'):
default_top_theme = 'powerline'
else:
default_top_theme = 'ascii'
default_top_theme = get_default_theme(
encoding.startswith('utf') or encoding.startswith('ucs'))

common_config = common_config.copy()
common_config.setdefault('default_top_theme', default_top_theme)
Expand Down
7 changes: 6 additions & 1 deletion powerline/bindings/bash/powerline.sh
Expand Up @@ -10,8 +10,13 @@ _powerline_columns_fallback() {
return 0
}

_powerline_tmux_pane() {
echo "${TMUX_PANE:-`TMUX="$_POWERLINE_TMUX" tmux display -p "#D"`}" | \
tr -d ' %'
}

_powerline_tmux_setenv() {
TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`tmux display -p "#D" | tr -d %` "$2"
TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`_powerline_tmux_pane` "$2"
TMUX="$_POWERLINE_TMUX" tmux refresh -S
}

Expand Down
22 changes: 15 additions & 7 deletions powerline/bindings/fish/powerline-setup.fish
Expand Up @@ -33,14 +33,14 @@ function powerline-setup
if test -z "$POWERLINE_COMMAND"
set -g POWERLINE_COMMAND (env $POWERLINE_CONFIG_COMMAND shell command)
end
function --on-variable fish_key_bindings _powerline_set_default_mode
function _powerline_set_default_mode --on-variable fish_key_bindings
if test x$fish_key_bindings != xfish_vi_key_bindings
set -g _POWERLINE_DEFAULT_MODE default
else
set -g -e _POWERLINE_DEFAULT_MODE
end
end
function --on-variable POWERLINE_COMMAND _powerline_update
function _powerline_update --on-variable POWERLINE_COMMAND
set -l addargs "--last-exit-code=\$status"
set -l addargs "$addargs --last-pipe-status=\$status"
set -l addargs "$addargs --jobnum=(jobs -p | wc -l)"
Expand Down Expand Up @@ -70,7 +70,7 @@ function powerline-setup
env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell right $addargs
$rpromptpast
end
function --on-signal WINCH _powerline_set_columns
function _powerline_set_columns --on-signal WINCH
set -g _POWERLINE_COLUMNS $columnsexpr
end
"
Expand All @@ -82,14 +82,22 @@ function powerline-setup
if env $POWERLINE_CONFIG_COMMAND shell --shell=fish uses tmux
if test -n "$TMUX"
if tmux refresh -S ^/dev/null
set -g _POWERLINE_TMUX "$TMUX"
function _powerline_tmux_pane
if test -z "$TMUX_PANE"
env TMUX="$_POWERLINE_TMUX" tmux display -p "#D" | tr -d ' %'
else
echo "$TMUX_PANE" | tr -d ' %'
end
end
function _powerline_tmux_setenv
tmux setenv -g TMUX_$argv[1]_(tmux display -p "#D" | tr -d "%") "$argv[2]"
tmux refresh -S
env TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_$argv[1]_(_powerline_tmux_pane) "$argv[2]"
env TMUX="$_POWERLINE_TMUX" tmux refresh -S
end
function --on-variable PWD _powerline_tmux_set_pwd
function _powerline_tmux_set_pwd --on-variable PWD
_powerline_tmux_setenv PWD "$PWD"
end
function --on-signal WINCH _powerline_tmux_set_columns
function _powerline_tmux_set_columns --on-signal WINCH
_powerline_tmux_setenv COLUMNS (_powerline_columns)
end
_powerline_tmux_set_columns
Expand Down
10 changes: 9 additions & 1 deletion powerline/bindings/rc/powerline.rc
Expand Up @@ -36,6 +36,14 @@ fn _powerline_common_setup {
_POWERLINE_SAVED_PWD = ''
}

fn _powerline_tmux_pane {
if (test x$TMUX_PANE '!=' x) {
echo $TMUX_PANE | tr -d ' %'
} else {
TMUX=$_POWERLINE_TMUX tmux display -p '#D' | tr -d ' %'
}
}

fn _powerline_tmux_setenv {
}

Expand Down Expand Up @@ -73,7 +81,7 @@ if (test x$POWERLINE_CONFIG_COMMAND '!=' x) {
fn _powerline_tmux_setenv {
if (test x$2 '!=' x) {
TMUX=$_POWERLINE_TMUX tmux setenv -g TMUX_$1^_`{
TMUX=$_POWERLINE_TMUX tmux display -p '#D' | tr -d %
_powerline_tmux_pane
} $2
}
}
Expand Down
7 changes: 6 additions & 1 deletion powerline/bindings/shell/powerline.sh
Expand Up @@ -104,8 +104,13 @@ _powerline_set_command() {
fi
}

_powerline_tmux_pane() {
echo "${TMUX_PANE:-`TMUX="$_POWERLINE_TMUX" tmux display -p "#D"`}" | \
tr -d ' %'
}

_powerline_tmux_setenv() {
TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`tmux display -p "#D" | tr -d %` "$2"
TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`_powerline_tmux_pane` "$2"
TMUX="$_POWERLINE_TMUX" tmux refresh -S
}

Expand Down
12 changes: 11 additions & 1 deletion powerline/bindings/tcsh/powerline.tcsh
Expand Up @@ -21,7 +21,17 @@ else
endif
endif
if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses tmux } ) then
alias _powerline_tmux_set_pwd 'if ( $?TMUX && { tmux refresh -S >&/dev/null } ) tmux setenv -g TMUX_PWD_`tmux display -p "#D" | tr -d %` $PWD:q ; if ( $?TMUX ) tmux refresh -S >&/dev/null'
if ( $?TMUX_PANE ) then
if ( "$TMUX_PANE" == "" ) then
set _POWERLINE_TMUX_PANE="`tmux display -p '#D'`"
else
set _POWERLINE_TMUX_PANE="$TMUX_PANE"
endif
else
set _POWERLINE_TMUX_PANE="`tmux display -p '#D'`"
endif
set _POWERLINE_TMUX_PANE="`echo $_POWERLINE_TMUX_PANE:q | tr -d '% '`"
alias _powerline_tmux_set_pwd 'if ( $?TMUX && { tmux refresh -S >&/dev/null } ) tmux setenv -g TMUX_PWD_$_POWERLINE_TMUX_PANE $PWD:q ; if ( $?TMUX ) tmux refresh -S >&/dev/null'
alias cwdcmd "`alias cwdcmd` ; _powerline_tmux_set_pwd"
endif
if ( { $POWERLINE_CONFIG_COMMAND shell --shell=tcsh uses prompt } ) then
Expand Down

0 comments on commit 5718616

Please sign in to comment.