Compare commits

...

347 Commits
2.4 ... develop

Author SHA1 Message Date
Will May 574bb1887b
Add font entry for Ubuntu Sans Mono. Fixes #2264 (#2265) 2024-09-30 09:48:39 +09:00
Philip Wellnitz 2c20cc20dd
Update README.rst 2024-08-29 20:08:47 +09:00
Philip Wellnitz [10] ef68bd8c35 update version 2024-08-29 20:05:37 +09:00
Carl Smedstad 8484023b7b
Fix Python deprecations (#2262)
* Add missing import 'types'

The commit 6950c04614d0bd1fc9c61b79ec7e2be0d16abdc4 did the following,
but missed to import the 'types' module:

-    module = imp.new_module(name)
+    module = types.ModuleType(name)

* Remove usage of 'imp' module - removed in Python 3.12

* Remove usage of deprecated method locale.getdefaultlocale()

Fixes the following deprecation warning:

powerline/lib/encoding.py:49: DeprecationWarning: 'locale.getdefaultlocale' is deprecated and slated for removal in Python 3.15. Use setlocale(), getencoding() and getlocale() instead.
  or locale.getdefaultlocale()[1]

* Fix invalid escape sequences

Specifically:

    powerline/bindings/config.py:179: SyntaxWarning: invalid escape sequence '\$'
    powerline/lint/__init__.py:208: SyntaxWarning: invalid escape sequence '\w'
    powerline/lint/__init__.py:226: SyntaxWarning: invalid escape sequence '\w'
    powerline/lint/__init__.py:44: SyntaxWarning: invalid escape sequence '\w'
    powerline/lint/spec.py:24: SyntaxWarning: invalid escape sequence '\w'
    powerline/lint/spec.py:588: SyntaxWarning: invalid escape sequence '\w'
    powerline/segments/common/mail.py:36: SyntaxWarning: invalid escape sequence '\d'
2024-08-29 20:00:48 +09:00
Philip Wellnitz [10] 6b36ba8ae9 fix #2257 2024-05-12 04:45:27 +09:00
Philip Wellnitz a34abe325a
Update main.yaml
3.10 seems to be parsed as 3.1, remove it for now.
2024-02-28 16:35:37 +09:00
Philip Wellnitz beca2d6e87
Update main.yaml
Update supported python versions.
2024-02-28 16:33:59 +09:00
Robin Candau c04a8dd5a1
Remove imp module from tests to make them compatible with python 3.12 (#2251) 2024-02-27 18:59:10 +09:00
wanderboessenkool 14cc0d2df8
Change TMUJX_VAR_RE re.compile to use raw string (#2245) 2023-11-27 21:05:59 +09:00
JesseBot 833f30e88e
Feature: add username_variable, password_variable, server_variable, port_variable to options to mail segment (#2225)
* add username_variable and password_variable to options to mail segment

* add server variable

* make username/password optional for mail, and fix getting env var typo

* add port variable for email

* fix sleepy port_variable typo
2022-12-18 17:38:49 +09:00
Christoph Erhardt 50d73bfbc8
Ensure compatibility with Python 3.11 (#2212)
* Replace deprecated `getargspec()` with `getfullargspec()`
* Replace deprecated `formatargspec()` with custom implementation

Fixes #2209.
2022-06-23 19:05:54 +09:00
PHP Wellnitz 8af6302c81 bump version to 2.8.3 2022-05-19 17:06:54 +09:00
PHP Wellnitz 3555dc97c9 change get_version to adhere to PEP 440 2022-05-19 16:57:18 +09:00
PHP Wellnitz 567e2c930b fix #2194 2022-05-19 16:52:00 +09:00
PHP Wellnitz 90af71c122 Fix #2200 2022-04-09 04:27:02 +09:00
Albert Paul 9ce39e6333 Remove git protocol (#2199)
* Fix outdated Github url

git:// is deprecated from Github starting from Jan. 11th, 2022.

* Update git protocols
2022-03-21 19:02:37 +09:00
Darren 82c1373ba0
Added tips to installation docs (#2175)
* Added virtual environment tips

Documented the use of `POWERLINE_COMMAND` env variable for improved performance with virtual environments.

* Clarify client versions

Adding details from the GitHub issues to clarify the installation docs.

* Added troubleshooting tip for Python environments
2021-08-21 11:21:14 +09:00
Josh Gao 57aea1e400
powerline.zsh: squelch which output. (#2176)
If powerline-config isn't on $PATH, GNU which will output "no
powerline-config in ($PATH)" to stderr, which we previously weren't
silencing.
2021-08-21 11:17:03 +09:00
MrFishFinger 8f0d3f8bd2
doco - add a comma, to make sentence more readable (#2173) 2021-07-26 16:01:39 +09:00
Philip Wellnitz 7310d53ade
i3 segments rework (#2159)
rework i3wm segments
2021-03-15 03:45:17 +09:00
Philip Wellnitz a1309cc116 bump version to 2.8.2 2021-03-01 16:45:49 +09:00
sol 1869cc8bed
Use updated i3ipc syntax in i3 segments/listers (#2062)
Close #2046

Co-authored-by: s-ol <s-ol@users.noreply.github.com>
2021-01-08 19:25:53 +09:00
Cédric Schieli c31f83f831
Emulate a right prompt in bash (#2148)
* Allow passing args from render() to hl() and hlstyle() functions

* New escape arg in ShellRenderer's hlstyle() to enable/disable escaping

* Fix invalid escape sequence

* Emulate a right prompt in bash

Fixes #2103

* Document the new hl_args argument
2021-01-06 18:20:15 +09:00
Tim Gates 999c84a5cb
docs: fix simple typo, proided -> provided (#2144)
There is a small typo in powerline/lint/spec.py.

Should read `provided` rather than `proided`.
2020-12-22 18:58:38 +09:00
StopMotionCuber f401ee3106
Fix escaping of sh specific characters in tmux (#2135)
* Fix escaping of sh specific characters in tmux

* Only have single pane_id (these line length is getting out of hand)
2020-10-28 17:39:17 +09:00
StopMotionCuber a6060c760a
Fix non-meaningful venv names. (#2134)
* Add feature to ignore certain virtualenv names

* Add tests for testing ignored names (specific as well as default)

* Don't use `zsh.environ` as this does not stringify the environment
2020-10-27 21:50:36 +09:00
Ivan Zhukov f4ef122759
Fallback to a current window in tabline() (#2132)
Ref #2125
2020-10-22 07:19:55 +09:00
Philip Wellnitz a1a36699b3
Update .travis.yml 2020-10-12 18:11:48 +09:00
Philip Wellnitz 0cccb7b4bc
Update README.rst 2020-10-12 18:07:37 +09:00
StopMotionCuber a80bbdf17d
Updated uptime segment to have show time in a better way (#2036)
* Updated uptime segment to have show time in a better way

* Made current solution backwards compatible

* Include proposed change for proper uptime support

* Updated tests to reflect new default values for uptime
2020-10-06 04:32:36 +09:00
StopMotionCuber 91ec7982ca
Fixed getcwd for tmux (#2127) 2020-10-06 02:43:09 +09:00
Thom Wiggers 40c3e092b6
Prefer Python 3 in the Vim plugin (#2124)
Python 2 is EOL, so it makes more sense to use Python 3 as the preferred version of Python rather than just fall back on it.
2020-09-26 17:50:51 +09:00
Tais P. Hansen ff629c388e
Implement GitHub actions for build and publish (#2118)
Requires a secret named PYPI_TOKEN containing a valid PyPI API token.

Note that this drop support for Python 2.6 as GitHub Actions only
supports Python 2.7+.

Fixes #2116
2020-09-21 20:03:15 +09:00
StopMotionCuber 73881c1dce
Shifted away from (abandoned) Yahoo API to OpenWeatherMap (#2038)
* Shifted away from (abandoned) Yahoo API to OpenWeatherMap
* Calculate gradient based on converted temperature
* Added Stubs for https://freegeoip.app as well as https://api.openweathermap.com
* Updated tests for weather segment with OpenWeatherMap mocking
* Make Weather API key configurable
* Added documentation for the OpenWeatherMap API keys
2020-09-19 14:31:49 +09:00
रोहित हिल 992c5464ba
Factored statement always executed in conditional (#2121) 2020-09-07 14:28:56 +09:00
Andrew Garrett 8c6874d855
Render cpu_load_percent segment even when psutil returns 0.0 (#2111)
Although the docs for psutil say 0.0 is a nonsense value that's returned
first and supposed to be ignored, but on a relatively idle system it
will actually return 0.0 occasionally after that. So at the expense of
displaying that "nonsense value" when the statusbar first loads, this
change gets rid of the visual disruptions of having the segment pop out
and back in periodically.

Fixes #2110.

Co-authored-by: 2rs2ts <2rs2ts@github>
2020-07-12 19:31:52 +09:00
StopMotionCuber 14a4100c4c
Fixes elapsed time that is provided with a ',' instead of a '.' (#2104) 2020-06-04 15:00:00 +09:00
Jesse Houwing 65f968ad3a
Use `--no-optional-locks` to reduce conflicts with other git editors (#2098)
Adding --no-optional-locks will cause fewer interference with other git clients.
2020-05-27 01:50:45 +09:00
Philip Wellnitz 59a5425597
Add timezone argument to date and fuzzy_time segments (#2097)
* add basic timezone support
2020-05-26 20:08:44 +09:00
Brendan da3ed7e720
Update to include default path for apt-get (#2095) 2020-05-24 17:56:47 +09:00
Philip Wellnitz c26938a980 add subprocess include back to setup.py 2020-05-20 20:32:35 +09:00
Philip Wellnitz 3dc174919d add version file 2020-05-20 20:26:24 +09:00
Philip Wellnitz 022d77dc1e
Update .travis.yml 2020-05-15 07:19:18 +09:00
Philip Wellnitz 1234aafa5d
Update setup.py 2020-05-15 05:33:27 +09:00
Philip Wellnitz 2bddcc9617
Update tips-and-tricks.rst 2020-04-23 21:42:10 +09:00
Ritiek Malhotra 7300197433
Select a D-Bus media player automatically (#2084)
Using the segment `powerline.segments.common.players.dbus_player` does
not work when a player has not been specified explicitly. In such a
case, with this PR, the segment will automatically choose the 1st media
player that implements "org.mpris.MediaPlayer2.Player".

This can be useful in displaying tracks from media players in powerline
without having to know the corresponding media player's properties
before-hand.

For example, this also works for displaying media tracks being played
on Google Chrome (since Chrome implements D-Bus interface) on YouTube,
etc.
2020-03-13 15:37:58 +09:00
Philip Wellnitz b0ea99430c
Update README.rst
Add basic config to readme
2020-02-04 21:12:16 +09:00
沈煜 d498f29261 Add vim plugin coc.nvim segments. (#2057)
* Add vim plugin coc.nvim segments.

* Add coc highlight group to colorschemes: default, solarized, solarizedlight.

* Fix coc highlight group in colorschemes: solarized, solarizedlight.

* Add document for segments.vim.plugin.coc.coc
2019-12-02 00:09:22 +09:00
Max Coplan 4b24e715dc Update Powerline for ipython >=7 (#2048)
* Update Powerline for ipython >=7

The method used for `since_5` does not work, but `since_7` does, however it is not documented.
I personally haven't found `c = get_config()` to be useful once you have generated the default `~/.ipython/profile_default/ipython_config.py` file.

Since `c.TerminalInteractiveShell.simple_prompt` is set to `False` by default, it's not worth mentioning it.  There's many other things that **can** break if you change the default config options too.  Additionally, `simple_prompt=True` doesn't fatally break anything, just make things less pretty.  So it'd be better to not have that, but mention if things don't look pretty to make sure they didn't change that default.

* Making it work on latest version

* spacing
2019-11-20 16:39:25 +09:00
Torstein Husebø 15c611ca46 doc: installation, fix typo (#2041)
* doc: installation, fix typo

* Fix a lot of documentation/comment typos
2019-11-03 04:29:20 +09:00
StopMotionCuber d6c06e002a Refactor tmux bindings (#2034)
* Replaced tmux display with proper formatting of things already available

* Removed client_pid as it is not available

* Also removed other occurrences of explicit `tmux execution`
2019-10-25 18:03:41 +09:00
Lucas Hosseini 5b3e401215 Update divider background color for tmux solarized (#1987)
Current settings leads to the following under tmux (on the right side):
2019-10-20 16:09:39 +09:00
Brendan Byers 43c1707206 Parse out letters in maj. version string (#2033) 2019-10-20 16:04:55 +09:00
Philip Wellnitz 589461e109
Fix #2015 (#2030)
* Added [BOM] (byte-order-mark) text in file encoding info

Like in vim-airline
See https://github.com/vim-airline/vim-airline/pull/992 and fdb74f549d

Ref #2015

* Test with no text added, to check travis results

* make bom a sepaate segment
2019-10-12 17:02:57 +09:00
BK f4dfe39112
Merge pull request #2028 from BlitzKraft/2027-use-command-v
Addressing #2027 gradually - use command -v
2019-10-11 21:25:56 +00:00
BK Bolisetty af557ae60c Reverting test_shells to use `which` 2019-10-11 15:15:28 -05:00
BK Bolisetty fff5c2a7b0 Trigger travis-ci 2019-10-10 13:39:45 -05:00
Philip Wellnitz 4abebb49eb
Fix #2013; Improve fish binding (#2029)
* fix fish resize squid

* fix fish vi squid
2019-10-10 18:36:48 +09:00
BK Bolisetty f9937ab922 Fix #2027 - Use `command -v` instead of which 2019-10-09 23:40:13 -05:00
BK Bolisetty ef6c9b435c Addressing #2027 gradually - use command -v
Currently only changed tests/test.sh and tests/test_bar/test.sh .
2019-10-09 21:51:36 -05:00
Philip Wellnitz 6569cc6cfd disable unstable network_load segment test 2019-10-08 16:05:45 +09:00
Philip Wellnitz f9ce8201c4
Fix #1953 (#1997)
* ipython fix

* ipython fix

* ipython fix

* fix ipython startup

* better fix for nbsp

* ipython7: fix attributes

* Change ipythen tests to use new binding

* ipython test: use proper config
2019-10-08 03:29:43 +09:00
Philip Wellnitz bc33b1ce31
fix #1969 (#2026) 2019-09-27 14:33:24 +02:00
sol 2428f78ea4 support vertically-aligned multi-monitor setups in lemonbar (#1982)
* support vertically-aligned multi-monitor setups in lemonbar

* Fix expected args in lemonbar test
2019-09-26 08:57:56 +02:00
Philip Wellnitz 25737d90eb Disable vterm tests to check ci 2019-09-23 20:14:19 +09:00
Philip Wellnitz aa3d04b2ed
Merge pull request #2011 from JonMontgo/feature/2010-better-mpc
Added mpc support for state and elapsed
2019-09-23 19:19:17 +09:00
Jonathan Montgomery 8c0577d9fd Added mpc support for state and elapsed
- mpc current format only used to get album info
- state, artist, title, total and elapsed now gotten from mpc command
with no extra parameters and a regular expression
- state uses convert state to sanitize the state from mpc
Ref #2010
2019-06-12 17:20:14 -05:00
Nikolai Aleksandrovich Pavlov 5d82d544f3
Merge pull request #1962 from rvantonder/patch-1
Fix duplicate conditional check
2018-11-11 15:23:53 +03:00
Rijnard van Tonder e64ce9bd1a
Fix duplicate conditional check 2018-11-09 22:16:02 -05:00
Nikolai Aleksandrovich Pavlov 393ff7119f
Merge pull request #1873 from synapticarbors/patch-1
Include license file in MANIFEST.in
2018-10-12 01:26:07 +03:00
Nikolai Aleksandrovich Pavlov d7a9393888
Merge pull request #1945 from chrisbra/develop
doc: Correct links to vim-airline
2018-09-23 03:44:57 +03:00
Christian Brabandt 6a7b7d97f3
doc: Correct links to vim-airline 2018-09-20 11:53:41 +02:00
Foo 616ea816c8 Merge branch 'release-2.7' into develop 2018-08-12 22:41:43 +03:00
Foo b7a68da865 Update base version 2018-08-12 22:41:43 +03:00
Foo 1bed167d8e Merge branch 'update-tests' (early part) into develop
Missing most recent commit which disabled stages because
1. Disabling stages is not important.
2. Need not to close relevant PR.
2018-08-12 22:39:48 +03:00
Foo a92bc72801 fix! Allow failing old vim test when running with Python-2.7 2018-08-12 22:10:15 +03:00
Nikolai Aleksandrovich Pavlov 6257332372
Merge pull request #1915 from dkrieger/develop
Recognize Terminal-Job mode (added in vim 8)
2018-06-07 11:32:58 +03:00
Doug Krieger 4a8e8b5b0c Recognize Terminal-Job mode (added in vim 8) 2018-06-06 11:56:32 -07:00
Nikolai Aleksandrovich Pavlov e3c34e7136
Merge pull request #1914 from Aurze/fix-1875
Fix for i3 if you have i3-py and i3ipc install
2018-05-30 09:43:18 +03:00
Aurze 1da9485f5f Fix if you have i3ipc and i3 on your system. Will prioritize i3ipc 2018-05-29 23:18:02 -04:00
Nikolai Aleksandrovich Pavlov a5dd717ac4
Merge pull request #1907 from yparisien/patch-1
Transparency doesn't need to be disabled
2018-05-09 13:54:50 +03:00
yparisien 052260ad4d
Markdown correction 2018-05-09 10:29:29 +02:00
yparisien f813171596
Correcting markdown 2018-05-09 10:21:33 +02:00
yparisien 80156fb840
Transparency doesn't need to be disabled 2018-05-08 22:18:51 +02:00
Nikolai Aleksandrovich Pavlov e52754d5c5
Merge pull request #1896 from stepharr/patch-1
grammar fix
2018-03-21 09:39:38 +03:00
Stephon Harris 166013aab0
grammar fix
Including `, the` for readability
2018-03-21 00:32:17 -04:00
Nikolai Aleksandrovich Pavlov d36850f33d
Merge pull request #1893 from StopMotionCuber/1754-spotify-new-dbus-protocol
(fix) updated spotify segment to support both new and old protocol

Closes #1870
2018-03-16 01:07:41 +03:00
ruben 74c08cd538 Spotify segment checks for new protocol first 2018-03-15 08:22:44 +01:00
ruben cc965526fb Added detection of old Spotify DBus protocol
Ref #1754
2018-03-14 09:13:26 +01:00
Foo 3c4ec09281 Do not set -x, it fails some tests and makes some output not readable 2018-02-25 22:36:52 +03:00
Foo d27961f0b0 Unset POWERLINE_SUITE_FINAL if exit_suite is continuing 2018-02-25 22:35:11 +03:00
Foo 2fc0e8e520 Use proper $PYTHON in case of UCS2 build and non-bash script 2018-02-25 22:28:29 +03:00
Foo 4a834f38aa Only enable tracing for “final” suites: suites not having subsuites 2018-02-25 22:16:05 +03:00
Foo 23bec031a4 Do not use python from ~/opt directly
It causes problems with sys.path: interpreter could not use installed packages.
2018-02-25 21:53:24 +03:00
Foo 466ee2e295 Print more detailed diagnostics
Specifically, disable set -x from main.sh, but add nicer print_environ function 
executed before each test suite, also setting `set -x` in `enter_suite`.
2018-02-25 21:37:47 +03:00
Nikolai Aleksandrovich Pavlov fbf711bc10
Merge pull request #1880 from ForTheReallys/1869_tmux_truecolor
Added support for truecolor in tmux
2018-02-14 01:39:39 +03:00
Alex Maese a5e5ed00d4 Removed unnecessary code 2018-02-13 15:50:06 -06:00
Alex Maese b53708b577 Added support for truecolor in tmux status line 2018-02-13 10:27:31 -06:00
Joshua Adelman bad86469b7
Include license file in MANIFEST.in 2018-01-19 10:06:41 -05:00
Gabriel Fróes Franco 3b3d546e89 (fix) updated linux spotify app dbus config 2018-01-10 00:49:28 -02:00
Foo 910c6a33dd Define PYTHON and LD_LIBRARY_PATH before sourcing main.sh 2017-12-16 16:28:56 +03:00
Foo ed0630d074 Make UCS2 Python a separate stage and run that first 2017-12-03 00:17:08 +03:00
Foo f507a6370a Do commit code which is actually using virtualenv 2017-12-02 23:16:17 +03:00
Foo 9d836d70e0 Use virtualenv for tmux and vshells tests as well 2017-12-02 19:25:01 +03:00
Foo cee07a69b1 Always supply verb argument 2017-12-02 19:06:38 +03:00
Foo 2a01c4687e Supply segment_info to powerline.segments.env.user() segment in tests 2017-12-02 18:30:24 +03:00
Foo b558d200fe Only shift if verb was supplied 2017-12-02 18:24:01 +03:00
Foo 1b0df9c2bd Wait for thread to start 2017-12-02 17:56:45 +03:00
Foo 0c594b0b34 Use verboser installation, check for installed powerline 2017-12-02 17:56:45 +03:00
Foo d18b58821b Separate PyPy tests from old python tests in a different stage 2017-12-02 17:56:43 +03:00
Foo 436b4b680a Rename test_shell.py to test_shells.py 2017-12-02 17:56:43 +03:00
Foo eb17b5374b Add some working dash tests 2017-12-02 17:56:41 +03:00
Foo 870de7be21 Improve terminal.py:
1. Make it print true color escape sequences when debugging.
2. Add support for automatic row detection.
2017-12-02 17:56:37 +03:00
Foo 6bbcb610c7 Make vterm UTF-8 2017-12-02 17:56:36 +03:00
Foo 3fca2f8d02 Add skip command, rename tests/failures to tests/status 2017-12-02 17:56:34 +03:00
Foo 96f9c62d86 Start creating shell vterm tests
Should replace #1448.
2017-12-02 17:56:33 +03:00
Foo 44e0a30b80 Ignore some files generated by tests 2017-12-02 17:56:32 +03:00
Foo 29d0a3c171 Remove “output is not to a terminal” from Vim output 2017-12-02 17:56:31 +03:00
Foo cbea5357a9 Use different character for strwidth tests 2017-12-02 17:56:30 +03:00
Foo eb5834cf3e Move version
I do not actually see this character in diff of EastAsianWidth.txt though, but 
it appears that test with 5.1.0 uses 2 and succeeds, tests with 6.0.0 and 8.0.0 
use 1 and succeed, but test with 5.2.0 uses 2 and fails.
2017-12-02 17:56:28 +03:00
Foo 335be73d3e Check unidata_version to determine width
Did not actually determine whether this check is correct.
2017-12-02 17:56:26 +03:00
Foo b047abcd9a First call suite.fail, then super().fail 2017-12-02 17:56:24 +03:00
Foo 55d9c320dc Add missing import 2017-12-02 17:56:23 +03:00
Foo 0a1cf1780f Use better failure message 2017-12-02 17:56:22 +03:00
Foo f111a95b0d Change width to 1
May make test fail on older Python’s
2017-12-02 17:56:21 +03:00
Foo 2787855008 Disable travis hack
Assuming it is outdated.
2017-12-02 17:56:19 +03:00
Foo f0944f840e Make python tests also print to summary 2017-12-02 17:56:15 +03:00
Foo 2a4f76e4fa Also temporary allow pdp failures 2017-12-02 17:56:11 +03:00
Foo 45e148b3a0 Fix what attempts means for PowerlineTestSuite.test 2017-12-02 17:56:07 +03:00
Foo 0ad1d9be40 More granular failure reports in summary from vterm tests 2017-12-02 17:56:03 +03:00
Foo 468397b224 Split CI into stages 2017-12-02 17:56:00 +03:00
Foo e71cc3e9ef Add python-3.6 to build matrix 2017-12-02 17:55:58 +03:00
Foo 783b56066f Use trusty for tests
Bot-ci was switched to it, better upgrade upstream tests then downgrade bot-ci.
2017-12-02 17:55:58 +03:00
Nikolai Aleksandrovich Pavlov a4a1c83539
Merge pull request #1860 from bewing/wsl_battery
Check for battery percentage if no charge/energy
2017-11-25 00:34:15 +03:00
Brandon Ewing 6be991c571 Check for battery percentage if no charge/energy
Windows Subsystem for Linux abstracts the batteries in a laptop
into a single battery, and only states the percent charge via
/sys/power_supply/battery/capacity.  If dbus is unavailable,
and no charge/energy readings are available for any power supply,
search for the first power supply that has a capacity file, and use it
(and its state) as the battery status.

Tested on a Surface Book 2 running Windows 10 with  Windows
Subsytem for Linux Ubuntu 16.04
2017-11-24 15:03:30 -06:00
Nikolai Aleksandrovich Pavlov 5198b50463
Merge pull request #1851 from pmacosta/develop
Added Vim segment plugin for the Asynchronous Linter Engine (ALE)
2017-10-27 23:29:56 +03:00
Pablo Acosta-Serafini 421a71ee53 Brought back modeline and added spaces around plus signs 2017-10-27 08:44:47 -04:00
Pablo Acosta-Serafini 67683ecbb8 Introduced requested chanages 2017-10-24 04:40:03 -04:00
Pablo Acosta-Serafini c8f361c9ca Added Vim segment plugin for the Asynchronous Linter Engine (ALE).
This segment has the same functionality and interface as the Syntastic
Vim segment plugin, and the code is largely adapted from it.
Documentation stub is also included
2017-10-23 13:28:16 -04:00
Nikolai Aleksandrovich Pavlov 119c709bf2 Merge pull request #1849 from hede/patch-1
Fixes typo in documentation
2017-10-15 14:30:55 +03:00
hede d7cbeb9022 Typo fix
In the first paragraph: s/Presense/Presence of Python support in vim...
2017-10-15 13:59:49 +03:00
Nikolai Aleksandrovich Pavlov 9bebc2fe7f Merge pull request #1828 from powerline/ZyX-I-patch-1
Fix data type in branch segment documentation
2017-09-02 22:39:49 +03:00
Nikolai Aleksandrovich Pavlov 5adb7d11a3 Fix data type in branch segment documentation
Closes #1827
2017-09-02 22:39:28 +03:00
Nikolai Aleksandrovich Pavlov 5a24eceae9 Merge pull request #1823 from ZyX-I/ZyX-I-patch-1
Do not use negative indexes
2017-08-22 12:04:46 +03:00
Nikolai Aleksandrovich Pavlov 6b3c71bf3b Do not use negative indexes
Ref #1821.
2017-08-22 10:30:49 +03:00
Nikolai Aleksandrovich Pavlov bc1713d58b Merge pull request #1818 from arslan2012/add_elapsed_spotify_osascript
added elapsed time to spotify applescript player segment
2017-08-09 20:03:05 +03:00
Arslan Ablikim 01f2a3ae92 added a trailing comma 2017-08-09 21:30:21 +08:00
Arslan Ablikim 2a9a0a8282
added elapsed time to spotify applescript player segment 2017-08-08 13:45:31 +08:00
Nikolai Aleksandrovich Pavlov 2fe9282d61 Merge pull request #1816 from arslan2012/fix_apple_script
fix spotify applescript track length
2017-08-08 07:41:59 +03:00
Arslan Ablikim 146cf8994d
fix spotify track length 2017-08-08 12:33:25 +08:00
Nikolai Aleksandrovich Pavlov 5d6aa0e07a Merge pull request #1817 from arslan2012/fix_mac_to_use_apple_script
change spotify to use applescript on OS X
2017-08-08 07:15:43 +03:00
Arslan Ablikim 5d8739b291
fix spotify track length 2017-08-08 12:08:37 +08:00
Arslan Ablikim 1b3456a449
fix spotify to use apple script 2017-08-08 11:45:46 +08:00
Nikolai Aleksandrovich Pavlov d0d0644e3c Merge pull request #1813 from chester755/develop
Adding elapsed time to dbus players
2017-08-05 00:47:20 +03:00
chester755 5a53cf9f93 Add elapsed time to Dbus players 2017-08-04 16:26:38 -05:00
chester755 8d85c4f73b Add elapsed time to dbus players. 2017-08-04 16:08:59 -05:00
chester755 9bff8a5660 Adding elapsed time to the dbus player. 2017-08-04 15:48:32 -05:00
Foo e627b29f76 Merge branch 'pr-1811' into develop 2017-08-02 15:06:58 +03:00
Foo e3ee79d976 Some style fixes 2017-08-02 15:05:35 +03:00
Jesús Rafael Sánchez 544556f145 Making code cleanup and enhancements suggested by @ZyX-I 2017-08-02 07:54:53 -04:00
Jesús Rafael Sánchez 8dd1188bc8 Removing some unnecesary lines 2017-08-01 08:10:09 -04:00
Jesús Rafael Sánchez 324432bd12 Avoiding more than 1 colon in strings for file name or song title, this
may break the player indicator
2017-07-31 17:19:57 -04:00
Jesús Rafael Sánchez 0595c89f21 Making code changes requested by @ZyX-I a day ago 2017-07-31 07:26:56 -04:00
Jesús Rafael Sánchez b82769ad4b Fixing some metadata and time calculation for mocp player 2017-07-30 03:13:21 -04:00
Jesús Rafael Sánchez 8a5310806f Adding information filtering conditional on list comprehension 2017-07-30 01:26:13 -04:00
Jesús Rafael Sánchez 338470c11f Adding Music On Console (mocp) support, requires >= 2.3.0 version 2017-07-30 01:06:52 -04:00
Foo f35c401b0f Merge branch 'pr-1803' into develop 2017-07-13 23:01:22 +03:00
Andreas Schneider 29ff2b99c4 Avoid a strlen() call 2017-07-13 22:58:07 +03:00
Andreas Schneider 924bbbe92b Make inline function also static
After compiling with GCC 7.1.0 it otherwise fails linking for some
reason, complaining about that non-static inline function being not
found.
2017-07-13 22:56:51 +03:00
Andreas Schneider 73244eb976 Make sure any positive integer fits into the buffer
Avoids GCC 7.1.0 -Wformat-truncation.
2017-07-13 22:55:27 +03:00
Nikolai Aleksandrovich Pavlov 8d577b5958 Merge pull request #1794 from vsimonian/1793-ref-correct-fonts-folder
Replace ~/.fonts with ~/.local/share/fonts in help
2017-07-02 07:37:39 +03:00
Vartan Christopher Simonian 34dc7f9f55 Replace ~/.fonts with ~/.local/share/fonts in help
`~/.fonts/` has been deprecated in favour of `~/.local/share/fonts/`.

References:
- https://github.com/behdad/fontconfig/blob/master/fonts.conf.in#L29
- https://lists.freedesktop.org/archives/fontconfig/2014-July/005270.html

Fixes #1793
2017-07-01 20:15:25 -07:00
Nikolai Aleksandrovich Pavlov 9cd66c0b2f Merge pull request #1792 from ZyX-I/argparse-dep
Specify argparse dependency
2017-07-01 13:58:02 +03:00
Foo 234091c95d Specify argparse dependency
Fixes #1791
2017-07-01 02:57:53 +03:00
Nikolai Aleksandrovich Pavlov 517f38c566 Merge pull request #1786 from WhitleyStriber/patch-1
Spelling Fix
2017-06-08 04:06:53 +03:00
Whitley e991b42c1b Spelling Fix 2017-06-07 20:57:01 -04:00
Nikolai Aleksandrovich Pavlov 90032f8d0c Merge pull request #1783 from ZyX-I/check-bash-has-pipestatus
Check that bash has (no) $PIPESTATUS support before using it
2017-06-03 23:36:29 +03:00
Nikolai Aleksandrovich Pavlov 4dc590bde7 Merge pull request #1785 from martingabelmann/fix-1784
add awesome4+ support, fixes #1784
2017-06-03 23:15:48 +03:00
Martin Gabelmann 7189f35cf0 add awesome4+ support, fixes #1784 2017-06-03 21:54:18 +02:00
Foo d3e5d99a20 Do not spawn jobs
With previous variant of code first call has spawned a job which was perfectly 
reproducibly visible in prompt at bash startup. In subsequent prompts job number 
segment disappeared because result was cached, but it still was not good.
2017-06-02 21:23:03 +03:00
Foo 3c49ed1e96 Check that bash has (no) $PIPESTATUS support before using it
Ref #1782
2017-06-02 21:12:14 +03:00
Nikolai Aleksandrovich Pavlov 3df98fc276 Merge pull request #1779 from ZyX-I/vterm-standard-tmpdir-fixes
Add some fixes for vterm tests
2017-05-21 16:30:41 +03:00
Foo 28faebe260 Do not provide make_test_root unneeded argument 2017-05-21 16:10:33 +03:00
Foo 8e94773791 Fix test_vim.sh: should use standard directory as well 2017-05-21 16:10:30 +03:00
Nikolai Aleksandrovich Pavlov 36dba1134f Merge pull request #1778 from ZyX-I/vterm-standard-tmpdir
Switch vterm tests to use “standard” temporary directory in tests/tmp
2017-05-21 03:06:26 +03:00
Foo 1151449a8c Switch vterm tests to use “standard” temporary directory in tests/tmp 2017-05-21 02:33:50 +03:00
Nikolai Aleksandrovich Pavlov abb0cab64f Merge pull request #1776 from phatblat/ben/fish-readme
✏️ Add fish to list of supported apps on readme
2017-05-18 00:58:45 +03:00
Ben Chatelain ef3b547558 ✏️ Add fish to list of supported apps on readme 2017-05-17 15:54:54 -06:00
Nikolai Aleksandrovich Pavlov b5fe29eff5 Merge pull request #1775 from ZyX-I/bash-pipestatus
Add support for pipestatus in bash
2017-05-16 20:07:58 +03:00
Foo b0d31181cd Make bash tests check for pipestatus 2017-05-16 19:34:28 +03:00
Foo 30acc6ed4c Make default_leftonly theme use last_pipe_status 2017-05-16 19:34:27 +03:00
Foo b1e2086fe3 Add some more troubleshooting information 2017-05-16 19:34:27 +03:00
Foo 443679d532 Make last_pipe_status fallback to last_exit_code 2017-05-16 19:34:26 +03:00
Foo de899c5fc5 Export pipe status in bash bindings 2017-05-16 19:34:26 +03:00
Nikolai Aleksandrovich Pavlov be5879379e Merge pull request #1770 from ZyX-I/fix-i3bar-i3ipc
Abstract away subscription to workspace event
2017-05-11 23:04:42 +03:00
Foo 8150d38bd2 Abstract away subscription to workspace event 2017-05-11 23:03:48 +03:00
Nikolai Aleksandrovich Pavlov da3a0fab68 Merge pull request #1769 from ZyX-I/fix-i3-bindings
Fix i3 bar bindings
2017-05-11 22:45:00 +03:00
Foo 1e6414d0e8 Fix i3 bar bindings
Specifically:

- Do not log exceptions to the same location data is output.
- Fix format, i3bar is no longer using “pseudo-JSON”, also not sure whether it 
  ever used format `[[right list], [left list]]`, but it definitely does not 
  now.
- i3bgbar branch is no longer available.
- Yet i3wm supports background color, just with the different key (`background` 
  vs `background_color`).
2017-05-11 21:09:10 +03:00
Foo f6bf7b4916 Merge branch 'release-2.6' into develop 2017-05-08 19:47:15 +03:00
Foo d23c17b7a0 Update base version 2017-05-08 19:47:15 +03:00
Nikolai Aleksandrovich Pavlov c9824da701 Merge pull request #1764 from ZyX-I/tmux-workaround
Break #… sequences inside `#()` in tmux status options
2017-05-06 21:44:36 +03:00
Foo 37cd44ae75 Break #… sequences inside `#()` in tmux status options 2017-05-06 00:33:01 +03:00
Nikolai Aleksandrovich Pavlov 5e46d3b1ef Merge pull request #1762 from ZyX-I/travis-folds
Use custom travis folds
2017-05-01 06:19:53 +03:00
Foo bf29fa9537 Save version to the proper location 2017-05-01 04:31:07 +03:00
Foo 8da977e0a1 Insert travim_fold calls to enter_suite and exit_suite 2017-05-01 04:31:06 +03:00
Nikolai Aleksandrovich Pavlov 9bad9b8375 Merge pull request #1761 from ZyX-I/vterm-vim-tests
Refactor test scripts and reenable shell tests
2017-05-01 03:17:54 +03:00
Foo 343b217cae Fix warncreateglobal warning from zsh_expand 2017-05-01 02:15:50 +03:00
Foo 2d877c9240 Move shell tests inputs and outputs to separate directories 2017-05-01 01:58:48 +03:00
Foo 65c6ed1cff Try setting LD_LIBRARY_PATH
Currently zpython test does not work: libzpython could not load libpython.
2017-05-01 01:45:07 +03:00
Foo 4c5b02d236 Remove “test x” nonsense 2017-05-01 01:28:44 +03:00
Foo 2fcbd89ef8 Trace checkout_cached_dir, use rev-parse in place of some hack 2017-05-01 01:17:09 +03:00
Foo 225ed1f230 Do not add fish and dash to $TEST_ROOT/path 2017-05-01 01:17:09 +03:00
Foo 5a3e19847e Refactor shells test code
Tests passing locally:

bash (no)daemon C
busybox (no)daemon C
fish (no)daemon C
mksh (no)daemon C
rc (no)daemon C
tcsh (no)daemon C
zsh (no)daemon C
zsh zpython
ipython
pdf module
pdf subclass

dash has problems with job control (bgscript.sh not finished by kill)
2017-05-01 00:28:25 +03:00
Foo 717ae5e428 Refactor make_tmp_dir to make_test_root
This fixes problem with `exit_suite --continue` wiping out tmp directory.
2017-04-30 22:55:20 +03:00
Foo 1303cd1b04 Move tests/run_*_tests.sh to tests/test_*/test.sh
Warning: this also makes shell tests run.
2017-04-30 22:40:43 +03:00
Foo 0fc96abce2 Move “library” tests/*.sh to tests/shlib 2017-04-30 18:20:30 +03:00
Foo f3bf749467 Move tests run by run_python_tests to tests/test_python 2017-04-30 18:20:30 +03:00
Foo 53a7d1046e Move messages.fail to a temporary directory 2017-04-30 18:20:30 +03:00
Foo 82ca32edc9 Move vim integration tests to test_vim 2017-04-30 18:20:29 +03:00
Foo c30383a194 Move Python tests.* modules to tests/modules, rename tests/path 2017-04-30 16:02:04 +03:00
Foo 2a1aef1bac Add blank vim+vterm tests 2017-04-30 14:44:26 +03:00
Foo cac99271ca Move lib variable to do_terminal_tests 2017-04-30 14:42:54 +03:00
Foo 255ff49def Define tests via dictionaries, do not hardcode row number 2017-04-30 14:36:50 +03:00
Foo 9d7366436b Move some env variables definition out of run_vim_tests.sh 2017-04-30 13:55:58 +03:00
Foo 96d83346a5 Be more explicit about what to link tmux executable to 2017-04-30 13:55:58 +03:00
Foo a05857e64e Move some code away of test_tmux.sh 2017-04-30 13:55:58 +03:00
Foo 65130ae6ff Hide test/vterm_tmux in env variable, use absolute paths 2017-04-30 13:55:57 +03:00
Foo 1b3aacb837 Move most of the vterm testing code to tests.lib.terminal 2017-04-30 13:18:50 +03:00
Nikolai Aleksandrovich Pavlov 1d602204b1 Merge pull request #1760 from ZyX-I/vterm-tests
Fix tmux vterm tests
2017-04-30 12:45:15 +03:00
Foo e34a372f10 Fix number of spaces 2017-04-30 12:21:46 +03:00
Foo e3d0649372 Always remove all tmux logs 2017-04-30 06:40:05 +03:00
Foo afb6b0995d Do not force MutableDimensions inherit from Dimensions 2017-04-30 06:36:29 +03:00
Foo a2bc59c020 Do not call Dimensions.__init__ 2017-04-30 06:06:52 +03:00
Foo 93cbeb92e9 Fix misplaced lines 2017-04-30 05:35:53 +03:00
Foo bbb9ae21f4 Move printing tmux logs out of test_expected_result 2017-04-30 05:34:19 +03:00
Foo 883aa73e9f Refactor vterm tests: move most of things out of the try 2017-04-30 05:31:14 +03:00
Foo 519f08541b Also move arguments list out of the try body 2017-04-30 05:07:25 +03:00
Foo 3d0f168806 Refactor try block in main and refactor specifying dimensions 2017-04-30 05:05:32 +03:00
Foo 3b769d2b98 Make sure window_flags always have at least one space 2017-04-30 05:05:31 +03:00
Foo 4c2583311c Do not make build successfull if only second test was successfull 2017-04-30 05:05:30 +03:00
Foo 32eec2f9f3 Rename expected_result_new to expected_result_1_8 2017-04-30 05:05:30 +03:00
Foo 756ea5bfab Still try to kill server, just now not allow exceptions to fail build 2017-04-30 05:05:29 +03:00
Foo 86f6943b08 Unlink in place of appending x 2017-04-30 05:05:29 +03:00
Foo b93ae8e8a2 Do not reuse existing socket paths 2017-04-30 05:05:28 +03:00
Foo e19feb9472 Use different socket for each attempt 2017-04-30 05:05:28 +03:00
Foo b71d5f2d44 Do not bother with issuing kill-server, simply -KILL tmux 2017-04-30 05:05:27 +03:00
Foo 36b9c966e0 Use absolute path for -S
It appears that using relative path for -S is not the best idea and yields tmux 
calls from powerline-config not working.
2017-04-30 05:05:26 +03:00
Foo 908d767ec0 Give a name to tmux default statusline color 2017-04-30 05:05:25 +03:00
Foo b7a46eb7a8 Give some colors names 2017-04-30 05:05:24 +03:00
Foo 4a3f098f22 Use powerline.conf as it is supposed to be used 2017-04-30 05:05:22 +03:00
Foo fb769d7297 Refactor environment and expected results 2017-04-30 05:04:35 +03:00
Foo 14982fc693 Make tmux tests more sane 2017-04-30 01:38:59 +03:00
Nikolai Aleksandrovich Pavlov ca8245b9e8 Merge pull request #1757 from ZyX-I/hglib-close
Do not forget to collect mercurial servers
2017-04-24 21:35:04 +03:00
Foo 0a2359848a Do not forget to collect mercurial servers
Current variant spawns way too many hg instances which are not collected until 
Vim exits.
2017-04-24 17:45:39 +03:00
Nikolai Aleksandrovich Pavlov d4d6bca2d0 Merge pull request #1746 from ZyX-I/mercurial-clean-status
Handle C file status
2017-04-24 17:22:01 +03:00
Nikolai Aleksandrovich Pavlov 5fa504118e Merge pull request #1642 from ZyX-I/wm-daemon
Use powerline daemon for running awesome bindings
2017-04-01 15:31:42 +03:00
Nikolai Aleksandrovich Pavlov 0eb2bae904 Merge pull request #1717 from teozkr/fix/fish-2.5.0-eval
Fish bindings: replace eval with source
2017-04-01 15:28:10 +03:00
Foo 05fa1da30a Handle C file status 2017-03-23 21:12:37 +03:00
Nikolai Aleksandrovich Pavlov 5a7c3e02ce Merge pull request #1741 from victor-o-silva/patch-1
Fix typo in package i3ipc in requirements list
2017-03-19 01:07:39 +03:00
Victor Oliveira da Silva 92c9a4f3e4 Fix typo in package i3ipc in requirements list 2017-03-18 16:27:14 -03:00
Nikolai Aleksandrovich Pavlov b4e9242807 Merge pull request #1735 from s-ol/tmux-git-fix
Assume latest tmux version if -V returns 'master'
2017-03-18 18:45:49 +03:00
s-ol d9f12a458e assume latest tmux version if -V returns 'master'
Close #1727
2017-03-18 16:32:23 +01:00
Nikolai Aleksandrovich Pavlov 0d31221f20 Merge pull request #1738 from fogine/fix-listers-doc
fix incorrect segment type `segments_list` - should be `segment_list`
2017-03-11 17:26:22 +03:00
fogine 0299dd132c fix incorrect segment type `segments_list` - should be `segment_list` 2017-03-11 09:21:40 -05:00
Foo 0caef54a85 Merge branch 'pr-1732' into develop
Closes #1732
2017-03-07 02:55:38 +03:00
Foo f1014e414f Clean space-only line 2017-03-07 02:54:33 +03:00
chester755@googlemail.com 340f73eff0 Add iTunes player segment
Squashed commits

- Fixed and redid itunes player
- change the player style
- Fix all the problems and removed the useless comments
- Fix all the problems and removed the useless comments
- Remove the truncation to the strings
- removed the .DS_Store
- correct the indentation I hate emacs now
- correct the indentations
2017-03-07 02:52:25 +03:00
Nikolai Aleksandrovich Pavlov 4c68f773aa Merge pull request #1729 from thomwiggers/fix-divide-bat-by-zero
Prevent divide by zero battery capacity
2017-02-26 01:27:44 +03:00
Thom Wiggers faf452e8eb
Prevent divide by zero battery capacity 2017-02-25 22:50:00 +01:00
Nikolai Aleksandrovich Pavlov 3aad562087 Merge pull request #1720 from welwood08/feature/optional-outer-padding
Make length of `output_padding` in renderer controllable
2017-02-19 15:00:54 +03:00
William Elwood 063a45672f Make length of `output_padding` in renderer controllable
Defaults to previous behaviour (length 1).
2017-02-19 11:43:46 +00:00
Nikolai Aleksandrovich Pavlov c417395ee8 Merge pull request #1723 from ZyX-I/disable-failing-tests
Temporary disable tmux and shell tests so that do not fail CI
2017-02-14 12:16:05 +03:00
Foo dd707cc0a6 Temporary disable tmux and shell tests so that do not fail CI 2017-02-14 11:03:42 +03:00
Nikolai Aleksandrovich Pavlov 64c9761c65 Merge pull request #1722 from incertia/vim-completion
Fix #1719
2017-02-14 11:00:40 +03:00
Will Song e2e0d73b2c
Add default colors and mode text for vim completion modes `ic`, `ix`, `Rc`, and `Rx`.
This fixes #1719.
2017-02-13 17:57:22 -06:00
Nikolai Aleksandrovich Pavlov 01d28baf72 Merge pull request #1716 from ZyX-I/support-more-vim-modes
Support more vim modes
2017-02-13 20:33:03 +03:00
Teo Klestrup Röijezon 55928a72bc Fish bindings: replace eval with source
For some reason, fish 2.5.0 freaks out under certain circumstances if
your `config.fish` calls `eval` at any point. For equally mysterious
reasons, replacing `eval` with `source` makes things work again.

See fish-shell/fish-shell#3809 for more details.
2017-02-08 10:37:08 +01:00
Foo 09821d98f8 Add support for new Vim modes
Fixes #1715
2017-02-06 16:46:21 +03:00
Foo 19659189da Add support for unknown modes in Vim
Closes #1715
2017-02-06 16:32:45 +03:00
Foo 8e0bed9677 Merge branch 'release-2.5.2' into develop 2017-02-05 13:44:42 +03:00
Foo 4189862b85 Update base version 2017-02-05 13:44:42 +03:00
Foo 908c575223 Merge branch 'fix-ipython' into develop 2017-02-05 13:43:35 +03:00
Foo 5b9487e27b Make it work with ipython-5.2.2
Fixes #1709
2017-02-05 13:43:15 +03:00
Foo 0240643071 Merge branch 'release-2.5.1' into develop 2017-02-05 13:25:11 +03:00
Foo e578b8af27 Update base version 2017-02-05 13:25:11 +03:00
Foo 8286674bf7 Merge branch 'pr-1706' into develop
Closes #1706
2017-01-22 03:38:39 +03:00
Benny Powers da4f5137f6 Added note about laststatus
Users may be confused when installing powerline as it does not appear by
default in single-window mode. This change alerts users that they should
not expect to see the status line and points them to the help documents
for laststatus so that they can activate it in all cases if they want.
2017-01-22 03:38:18 +03:00
Foo d53695a3fd Merge branch 'doc-remove-args' into develop 2017-01-06 21:24:09 +03:00
Foo 12bd79729e Improve removing arguments from documentation
Examples of issues where user used arguments which should not be present in 
documentation, but actually were present: #1699 (cpu_load_percent: 
shutdown_event), #1700 (weather: key, after_update, shutdown_event).
2017-01-06 21:23:42 +03:00
Foo b7d030a72a Merge commit '21ea62d' into HEAD
Closes #1702
2017-01-06 09:04:50 +03:00
Foo 21ea62db56 Move -- function command arguments after function name
Fish 2.4.0-231-gd885f00 cannot handle current variant and fish 2.2.0 is still 
fine with new variant.
2016-12-14 22:24:25 +03:00
Nikolai Aleksandrovich Pavlov 69a72dbf69 Merge pull request #1690 from yangby/develop
Fix filenames for linux power supply class in battery segment.
2016-12-14 21:00:41 +03:00
YangBy 51fabca257
Fix filenames for linux power supply class in battery segment.
Both "charge" (µAh) and "energy" (µWh) represents "capacity"
of battery in linux.

More details can find here:
https://github.com/torvalds/linux/blob/master/Documentation/power/power_supply_class.txt

Fixes #1605.
2016-12-01 12:58:30 +08:00
Nikolai Aleksandrovich Pavlov bfd50a5a7a Merge pull request #1676 from QuLogic/hglib
Use hglib instead of mercurial directly.
2016-11-01 23:42:12 +03:00
Elliott Sales de Andrade 6f32ca001c Use hglib instead of mercurial directly.
This wrapper uses the command server without tying it to the mercurial
internals, which means it can support Python 3 and use a more liberal
license.
2016-11-01 15:22:24 -04:00
Nikolai Aleksandrovich Pavlov fb9f7dd8ef Merge pull request #1673 from ZyX-I/other-default
Provide another default theme with less troublesome characters
2016-10-29 19:43:14 +03:00
Foo 64d96c833e Fix shell tests 2016-10-29 19:00:59 +03:00
Foo 19f9885825 Fix python tests by abstracting away default theme name 2016-10-29 15:58:53 +03:00
Foo 23f663f228 Also modify ….visual_range segment’s symbols in other unicode themes 2016-10-29 15:41:12 +03:00
Foo 373952684a Provide another default theme with less troublesome characters
Ref #1652
2016-10-29 15:37:23 +03:00
Nikolai Aleksandrovich Pavlov cdea113722 Merge pull request #1669 from harrissAvalon/patch-1
Fixed grammar
2016-10-29 00:42:19 +03:00
Stephon 18192db3da Fixed grammar 2016-10-28 11:06:18 -04:00
Nikolai Aleksandrovich Pavlov 4705aa666e Merge pull request #1665 from AcidScorpion/feature-by-acid
Fixed colors gradients in default and solarized
2016-10-26 03:57:00 +03:00
Dmitry Petrich f67ea65057 Tab alignments replaced by spaces 2016-10-26 03:07:47 +03:00
Dmitry Petrich 32b24593d2 Fixed colors gradients in default and solarized 2016-10-25 15:23:07 +03:00
Nikolai Aleksandrovich Pavlov cdd0cdbfee Merge pull request #1648 from ZyX-I/zsh-var-scope
Provide explicit scope information in powerline.zsh
2016-09-17 19:32:55 +03:00
Foo be762da476 Provide explicit scope information in powerline.zsh
Fixes #1647
2016-09-17 18:24:47 +03:00
Foo 25657089db Remove mutable global variables from daemon script 2016-08-20 21:03:24 +03:00
Foo 03e63fc8d2 Also provide WM threads with common shutdown event and config loader 2016-08-20 21:03:24 +03:00
Foo 5784c0cbc6 Use powerline daemon for running awesome bindings
Also adds functional tests for awesome bindings.

Replaces #1641
2016-08-20 21:03:24 +03:00
Foo 4b8798f192 Use $TMUX_PANE if it is defined
Also closes #1637 in most cases
2016-08-20 21:03:23 +03:00
Nikolai Aleksandrovich Pavlov 72572c8695 Merge pull request #1638 from ZyX-I/use-TMUX_PANE
Use $TMUX_PANE if it is defined
2016-08-18 18:52:37 +03:00
Foo 70246c38e7 Use $TMUX_PANE if it is defined
Also closes #1637 in most cases
2016-08-17 22:27:37 +03:00
Foo d135631e67 Merge branch 'update-documentation' into develop 2016-07-14 01:26:19 +03:00
Foo ead3ff33f3 Add warning regarding segments that use cwd to tmux usage docs 2016-07-14 01:25:10 +03:00
Foo dd58d5f4cd Fix underline of “i3wm listers” section 2016-07-14 01:05:00 +03:00
Foo 08137c52c7 Update documentation regarding IPython 2016-07-14 01:04:26 +03:00
Foo 31fd9e6c04 Merge branch 'release-2.5' into develop 2016-07-14 00:43:25 +03:00
Foo 29cdd7f3dc Update base version 2016-07-14 00:43:25 +03:00
Nikolai Aleksandrovich Pavlov a3b14de0f5 Merge pull request #1614 from QuLogic/1613-fix-trailing-whitespace-py3k
Fix trailing whitespace segment on Python 3.
2016-07-10 03:02:09 +03:00
Elliott Sales de Andrade ed69b983b2 Fix trailing whitespace segment on Python 3.
Using str() on a bytestring produces the repr on Python 3, not some
implicitly decoded string. So cast a literal instead.

Fixes #1613.
2016-07-09 19:43:22 -04:00
Nikolai Aleksandrovich Pavlov f71d1c1fee Merge pull request #1618 from ZyX-I/fix-ipython-5
Add support for IPython-5
2016-07-10 01:40:11 +03:00
Foo 0fc01e07be Allow ipython tests to fail 2016-07-09 16:53:39 +03:00
Foo 66c6de34ee Slow down IPython tests 2016-07-09 16:53:39 +03:00
Nikolai Aleksandrovich Pavlov 44db0ac860 Merge pull request #1616 from mc10/patch-1
README: Use the svg Travis image
2016-07-09 16:19:51 +03:00
Foo d89e7909d9 Fix tests 2016-07-08 22:04:54 +03:00
Foo 5b16efa6ec Switch how IPython is configured
Now user is expected to use

    from powerline.bindings.ipython.since_5 import PowerlinePrompts
    c.TerminalInteractiveShell.prompts_class = PowerlinePrompts

Note: still using hacks, now different ones. Main problem is that I cannot just 
register a powerline pygments style, user needs to specify his own style in 
order to change highlighting of non-powerline tokens (i.e. of everything, but 
prompt).
2016-07-08 21:57:25 +03:00
Foo 2954c83330 Add support for IPython-5
Fixes #1617
2016-07-08 20:24:38 +03:00
Kevin Ji 897751838c README: Use the svg Travis image 2016-07-08 00:52:06 -07:00
Nikolai Aleksandrovich Pavlov d816de054a Merge pull request #1561 from iblis17/backlog
Increase socket backlog number for `powerline-daemon`
2016-05-29 03:49:44 +03:00
Iblis Lin 436be7dacb Increase socket backlog number for `powerline-daemon` 2016-05-28 14:25:54 +08:00
Foo 2a4e818ab6 Merge branch 'pr-1598' into develop
Closes #1596
2016-05-15 13:53:22 +03:00
Phil Thomas 41a50fe5b2 Use different query to retrieve weather
Also switches geoip service.

Credit for fix to @gsusrafael

Fixes #1571
2016-05-15 13:42:53 +03:00
Nikolai Aleksandrovich Pavlov d115012b3b Merge pull request #1585 from ZyX-I/fix-tmux-2.1
Fix left segments support in tmux-2.1

Fixes #1583
2016-04-30 22:48:30 +03:00
Foo 4a688a7467 Fix left segments support in tmux-2.1 2016-04-30 16:39:51 +03:00
Nikolai Aleksandrovich Pavlov 23e1edd484 Merge pull request #1579 from dffischer/feature/stash
provide a VCS stash segment
2016-04-27 22:13:09 +03:00
XZS f4cbeaff9b test Vim variant of stash segment 2016-04-27 16:54:36 +02:00
XZS e027c5ed47 expose stash to Vim
It needs the same modifications as the branch segment to correctly
function.
2016-04-27 16:54:36 +02:00
XZS 72053f688f include stash in default shell layout
As it only shows up when any stash is present, only relevant users will
see it.

The priority was chosen slightly lower than the branch name, as the
branch name is more relevant to check upon often in between repository
work while the stashes are more likely only checked between task chunks.
2016-04-27 16:54:36 +02:00
XZS fd54f63347 indicate stash with symbols
Like already in place for the branch, Unicode symbols or letter
indicators make it easier to tell the stash counter apart from other
segments.
2016-04-27 16:54:36 +02:00
XZS c91bcd9ba1 colorize stash segment
As the stash represents unfinished work, it uses the same colors as
dirty branches and copies the respective divider colorization.
2016-04-27 16:54:36 +02:00
XZS a8f3d016a7 test git stash backend 2016-04-27 16:54:36 +02:00
XZS 4d62732ed5 implement stash backend for git 2016-04-27 16:54:36 +02:00
XZS 802791e979 test stash segment 2016-04-27 16:54:35 +02:00
XZS c9ca8e06d1 provide stash counter
Some version control systems have an area where changes can be stored as
temporary work in progress instead publishing them to the history.

This segment is intended to display their count, reminding the developer
about open ends in the current repository.

The underlying implementation is VCS-specific and has to be provided by
the respective library module.
2016-04-22 14:55:45 +02:00
Nikolai Aleksandrovich Pavlov 3bcd0ec547 Merge pull request #1578 from ReadmeCritic/develop
Update README URLs based on HTTP redirects
2016-04-21 22:36:43 +03:00
ReadmeCritic 87476e41e9 Update README URLs based on HTTP redirects 2016-04-21 09:27:16 -07:00
219 changed files with 6233 additions and 2896 deletions

46
.github/workflows/main.yaml vendored Normal file
View File

@ -0,0 +1,46 @@
name: Build and Publish to PyPI
on:
push:
branches:
- master
- develop
- feature/actions
pull_request:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, 3.11, 3.12]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Build
run: |
python setup.py sdist bdist_wheel
- name: Publish
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages_dir: dist/

5
.gitignore vendored
View File

@ -10,4 +10,7 @@ build
message.fail
client/powerline
/client/powerline
/tests/tmp
/tests/status

View File

@ -1,4 +1,5 @@
sudo: false
dist: trusty
cache:
directories:
- $HOME/.cache/pip
@ -17,19 +18,15 @@ addons:
language: python
install: tests/install.sh
script: tests/test.sh
matrix:
jobs:
include:
- python: "2.6"
- python: "2.7"
- python: "3.2"
- python: "3.3"
- python: "3.4"
- python: "3.5"
- python: "pypy"
- stage: PyPy
python: "pypy"
- python: "pypy3"
- python: "2.7"
env: >-
USE_UCS2_PYTHON=1
UCS2_PYTHON_VARIANT="2.7"
- stage: Latest Python
python: "3.6"
- stage: Intermediate versions
python: "3.5"
- python: "3.4"
# vim: et

View File

@ -5,3 +5,4 @@ recursive-include powerline/dist *.*
recursive-include client *.*
recursive-include docs/source *.rst *.py
include docs/Makefile
include LICENSE

View File

@ -1,24 +1,19 @@
Powerline
=========
:Author: Kim Silkebækken (kim.silkebaekken+vim@gmail.com)
:Source: https://github.com/powerline/powerline
:Version: beta
**Powerline is a statusline plugin for vim, and provides statuslines and
prompts for several other applications, including zsh, bash, tmux, IPython,
Awesome, i3 and Qtile.**
prompts for several other applications, including zsh, bash, fish, tmux,
IPython, Awesome, i3 and Qtile.**
* `Support forum`_ (powerline-support@googlegroups.com)
* `Development discussion`_ (powerline-dev@googlegroups.com)
+---------+---------------------------------------------------+
| Author | Kim Silkebækken (kim.silkebaekken+vim@gmail.com) |
+---------+---------------------------------------------------+
| Source | https://github.com/powerline/powerline |
+---------+---------------------------------------------------+
| Version | beta |
+---------+---------------------------------------------------+
.. image:: https://api.travis-ci.org/powerline/powerline.png?branch=develop
:target: `travis-build-status`_
:alt: Build status
.. _travis-build-status: https://travis-ci.org/powerline/powerline
.. _`Support forum`: https://groups.google.com/forum/#!forum/powerline-support
.. _`Development discussion`: https://groups.google.com/forum/#!forum/powerline-dev
**Powerline does not support python2 anymore and powerline will stop working with python2 in the near future.**
Features
--------
@ -29,8 +24,7 @@ Features
config files, and a structured, object-oriented codebase with no mandatory
third-party dependencies other than a Python interpreter.
* **Stable and testable code base.** Using Python has allowed unit testing
of all the project code. The code is tested to work in Python 2.6+ and
Python 3.
of all the project code. The code is tested to work in Python 3.6+.
* **Support for prompts and statuslines in many applications.** Originally
created exclusively for vim statuslines, the project has evolved to
provide statuslines in tmux and several WMs, and prompts for shells like
@ -51,14 +45,40 @@ Features
hassle for me / what happened to the original vim-powerline project / …*
You should check out some of the Powerline derivatives. The most lightweight
and feature-rich alternative is currently Bailey Lings `vim-airline
<https://github.com/bling/vim-airline>`_ project.
and feature-rich alternative is currently the `vim-airline
<https://github.com/vim-airline/vim-airline>`_ project.
------
Configuration
-------------
* Consult the `documentation
<https://powerline.readthedocs.org/en/latest/>`_ for more information and
installation instructions.
Basic powerline configuration is done via `JSON` files located at `.config/powerline/`. It is a good idea to start by copying the default configuration located at `powerline_root/powerline/config_files/` to `.config/powerline/`.
If you installed the powerline from the AUR or via pip, `powerline_root` should be `/usr/lib/python3.6/site-packages/` or something similar, depending on your python version.
If you installed powerline via apt-get 'powerline_root' should be '/usr/share/powerline/'.
This should yield you the following directory structure:
::
.config/powerline/
├── colorschemes
│   ├── ...
│   └── wm
|      └── default.json // Your configuration goes here
├── colors.json
├── config.json
└── themes
├── ...
└── wm
└── default.json // Your configuration goes here
The files in the subdirectories of `themes` are used to specify which segments shall be shown; the files in subdirectories of `colorschemes` are used to specify which colors (as defined in `colors.json`) shall be used to display a segment.
Note that your local configuration only overrides the global configuration, it does not replace it, i.e. if you don't configure something locally, the global default will be used instead.
* Consult the `documentation <https://powerline.readthedocs.org/en/latest/configuration.html#quick-setup-guide>`_ for more details. See also the `segment reference <https://powerline.readthedocs.org/en/latest/configuration/segments.html>`_ for available segments and their configuration.
* Check out `powerline-fonts <https://github.com/powerline/fonts>`_ for
pre-patched versions of popular, open source coding fonts.
@ -92,4 +112,4 @@ Vim statusline
The font in the screenshots is `Pragmata Pro`_ by Fabrizio Schiavi.
.. _`Pragmata Pro`: http://www.fsd.it/fonts/pragmatapro.htm
.. _`Pragmata Pro`: http://www.fsd.it/shop/fonts/pragmatapro

View File

@ -42,7 +42,7 @@ void do_write(int sd, const char *raw, size_t len) {
}
}
inline size_t true_sun_len(const struct sockaddr_un *ptr) {
static inline size_t true_sun_len(const struct sockaddr_un *ptr) {
#ifdef __linux__
/* Because SUN_LEN uses strlen and abstract namespace paths begin
* with a null byte, SUN_LEN is broken for these. Passing the full
@ -71,7 +71,7 @@ inline size_t true_sun_len(const struct sockaddr_un *ptr) {
#endif
#define ADDRESS_SIZE sizeof(ADDRESS_TEMPLATE) + (sizeof(uid_t) * 4)
#define NUM_ARGS_SIZE (sizeof(int) * 2)
#define NUM_ARGS_SIZE (sizeof(int) * 2 + 1)
#define BUF_SIZE 4096
#define NEW_ARGV_SIZE 200
@ -88,6 +88,7 @@ int main(int argc, char *argv[]) {
char *wd = NULL;
char **envp;
const char *address;
int len;
if (argc < 2) {
printf("Must provide at least one argument.\n");
@ -122,8 +123,8 @@ int main(int argc, char *argv[]) {
execvp("powerline-render", newargv);
}
snprintf(num_args, NUM_ARGS_SIZE, "%x", argc - 1);
do_write(sd, num_args, strlen(num_args));
len = snprintf(num_args, NUM_ARGS_SIZE, "%x", argc - 1);
do_write(sd, num_args, len);
do_write(sd, eof, 1);
for (i = 1; i < argc; i++) {

View File

@ -10,7 +10,7 @@ if test -n "$OSTYPE" ; then
elif test "${OSTYPE#darwin}" ; then
darwin=1
fi
elif which uname >/dev/null ; then
elif command -v uname >/dev/null ; then
if uname -o | grep -iqF linux ; then
use_filesystem=
elif uname -o | grep -iqF darwin ; then

View File

@ -117,10 +117,14 @@ segments that you may want to customize right away:
so unless youre on a VPN you probably wont have to change the location
query.
It is using OpenWeatherMap as a provider, which can be configured with a
personal API key. These can be generated `here
<https://home.openweathermap.org/api_keys>`_
If you want to change the location query or the temperature unit youll
have to update the segment arguments. Open a theme file, scroll down to
the weather segment and update it to include unit/location query
arguments:
the weather segment and update it to include unit, location query or
api key arguments:
.. code-block:: javascript
@ -129,7 +133,8 @@ segments that you may want to customize right away:
"priority": 50,
"args": {
"unit": "F",
"location_query": "oslo, norway"
"location_query": "oslo, norway",
"weather_api_key": "your_api_key"
}
},

View File

@ -29,7 +29,7 @@ Pdb listers
:members:
i3wm listers
----------
------------
.. automodule:: powerline.listers.i3wm
:members:

View File

@ -53,7 +53,7 @@ Common configuration is a subdictionary that is a value of ``common`` key in
``ambiwidth``
Tells powerline what to do with characters with East Asian Width Class
Ambigious (such as Euro, Registered Sign, Copyright Sign, Greek
Ambiguous (such as Euro, Registered Sign, Copyright Sign, Greek
letters, Cyrillic letters). Valid values: any positive integer; it is
suggested that this option is only set it to 1 (default) or 2.
@ -132,7 +132,7 @@ Common configuration is a subdictionary that is a value of ``common`` key in
``interval``
Number, determines time (in seconds) between checks for changed
configuration. Checks are done in a seprate thread. Use ``null`` to check
configuration. Checks are done in a separate thread. Use ``null`` to check
for configuration changes on ``.render()`` call in main thread.
Defaults to ``None``.
@ -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
--------------------------------
@ -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
@ -213,6 +215,13 @@ Common configuration is a subdictionary that is a value of ``ext`` key in
All components are enabled by default.
.. _config-ext-update_interval:
``update_interval``
Determines how often WM status bars need to be updated, in seconds. Only
valid for WM extensions which use ``powerline-daemon``. Defaults to
2 seconds.
.. _config-colors:
Color definitions
@ -236,7 +245,7 @@ Color definitions
gradient, and the value is a list containing one or two items, second item
is optional:
* A list of cterm color indicies.
* A list of cterm color indices.
* A list of hex color strings.
It is expected that gradients are defined from least alert color to most
@ -329,6 +338,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
========================== ====================================================
@ -358,6 +368,10 @@ ascii Theme without any unicode characters at all
is set in the local themes it will be ignored. This option may also be
ignored in some bindings.
``outer_padding``
Defines number of spaces at the end of output (on the right side) or at
the start of output (on the left side). Defaults to ``1``.
``dividers``
Defines the dividers used in all Powerline extensions.
@ -374,7 +388,7 @@ ascii Theme without any unicode characters at all
``cursor_columns``
Space reserved for user input in shell bindings. Unlike :ref:`cursor_space
<config-themes-cursor_space>` it is measured in absolute amout of columns.
<config-themes-cursor_space>` it is measured in absolute amount of columns.
.. _config-themes-segment_data:
@ -388,7 +402,7 @@ ascii Theme without any unicode characters at all
:ref:`display <config-themes-seg-display>`.
Key :ref:`args <config-themes-seg-args>` (only for function and
segments_list segments) is handled specially: unlike other values it is
segment_list segments) is handled specially: unlike other values it is
merged with all other values, except that a single ``{module}.{function}``
key if found prevents merging all ``{function}`` values.
@ -425,7 +439,7 @@ ascii Theme without any unicode characters at all
``type``
The segment type. Can be one of ``function`` (default), ``string`` or
``segments_list``:
``segment_list``:
``function``
The segment contents is the return value of the function defined in
@ -440,7 +454,7 @@ ascii Theme without any unicode characters at all
highlighting group is defined in the :ref:`highlight_groups option
<config-themes-seg-highlight_groups>`.
``segments_list``
``segment_list``
Sub-list of segments. This list only allows :ref:`function
<config-themes-seg-function>`, :ref:`segments
<config-themes-seg-segments>` and :ref:`args
@ -455,7 +469,7 @@ ascii Theme without any unicode characters at all
Segment name. If present allows referring to this segment in
:ref:`segment_data <config-themes-segment_data>` dictionary by this
name. If not ``string`` segments may not be referred there at all and
``function`` and ``segments_list`` segments may be referred there using
``function`` and ``segment_list`` segments may be referred there using
either ``{module}.{function_name}`` or ``{function_name}``, whichever
will be found first. Function name is taken from :ref:`function key
<config-themes-seg-function>`.

View File

@ -9,6 +9,12 @@ Vim segments
Plugin-specific segments
========================
Asynchronous Linter Engine (ALE) segments
-----------------------------------------
.. automodule:: powerline.segments.vim.plugin.ale
:members:
Syntastic segments
------------------

View File

@ -528,10 +528,10 @@ i3wm
in lemonbar bindings.
``workspace``
dictionary containing the workspace name under the key ``"name"`` and
boolean values for the ``"visible"``, ``"urgent"`` and ``"focused"``
keys, indicating the state of the workspace. Currently only provided by
the :py:func:`powerline.listers.i3wm.workspace_lister` lister.
the `i3-ipc` workspace object corresponding to this workspace.
Contains string attributes ``name`` and ``output``, as well as boolean
attributes for ``visible``, ``urgent`` and ``focused``. Currently only
provided by the :py:func:`powerline.listers.i3wm.workspace_lister` lister.
Segment class
=============

View File

@ -22,26 +22,26 @@ 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
with bazaar repositories.
* ``pyuv`` python package. Required for :ref:`libuv-based watcher
<config-common-watcher>` to work.
* ``i3-ipc`` python package. Required for i3wm bindings and segments.
* ``i3ipc`` python package. Required for i3wm bindings and segments.
* ``xrandr`` program. Required for the multi-monitor lemonbar binding and the
: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:
.. note::
When using ``pip`` ``{repository_root}`` directory referenced in
When using ``pip``, the ``{repository_root}`` directory referenced in
documentation may be found using ``pip show powerline-status``. In the output
of ``pip show`` there is a line like ``Location: {path}``, that ``{path}`` is
``{repository_root}``. Unless it is ``--editable`` installation this is only
@ -54,7 +54,7 @@ Generic requirements
Pip installation
================
Due to a naming conflict with an unrelated project powerline is available on
Due to a naming conflict with an unrelated project, powerline is available on
PyPI under the ``powerline-status`` name:
.. code-block:: sh
@ -66,7 +66,7 @@ development version
.. code-block:: sh
pip install --user git+git://github.com/powerline/powerline
pip install --user git+https://github.com/powerline/powerline
may be used. If powerline was already checked out into some directory
@ -85,17 +85,16 @@ will have to be done (:file:`~/.local/bin` should be replaced with some path
present in ``$PATH``).
.. note::
If ISP blocks git protocol for some reason github also provides ``ssh``
(``git+ssh://git@github.com/powerline/powerline``) and ``https``
(``git+https://github.com/powerline/powerline``) protocols. ``git`` protocol
should be the fastest, but least secure one though.
We can use either ``https``(``git+ssh://git@github.com/powerline/powerline``)
or ``https``(``git+https://github.com/powerline/powerline``) protocols.
``git`` protocol is deprecated by Github.
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

View File

@ -29,7 +29,7 @@ should be followed:
.. code-block:: sh
pip install --user git+git://github.com/powerline/powerline
pip install --user git+https://github.com/powerline/powerline
will get the latest development version.
@ -60,12 +60,12 @@ with any coding font.
#. Move the symbol font to a valid X font path. Valid font paths can be
listed with ``xset q``::
mv PowerlineSymbols.otf ~/.fonts/
mv PowerlineSymbols.otf ~/.local/share/fonts/
#. Update font cache for the path the font was moved to (root priveleges may be
#. Update font cache for the path the font was moved to (root privileges may be
needed to update cache for the system-wide paths)::
fc-cache -vf ~/.fonts/
fc-cache -vf ~/.local/share/fonts/
#. Install the fontconfig file. For newer versions of fontconfig the config
path is ``~/.config/fontconfig/conf.d/``, for older versions its
@ -92,12 +92,12 @@ After downloading font the following should be done:
#. Move the patched font to a valid X font path. Valid font paths can be
listed with ``xset q``::
mv 'SomeFont for Powerline.otf' ~/.fonts/
mv 'SomeFont for Powerline.otf' ~/.local/share/fonts/
#. Update font cache for the path the font was moved to (root priveleges may be
#. Update font cache for the path the font was moved to (root privileges may be
needed for updating font cache for some paths)::
fc-cache -vf ~/.fonts/
fc-cache -vf ~/.local/share/fonts/
After installing patched font terminal emulator, GVim or whatever application
powerline should work with must be configured to use the patched font. The

View File

@ -16,9 +16,13 @@ Python package
brew install python
.. note::
In case :file:`powerline.sh` as a client ``socat`` and ``coreutils`` need
to be installed. ``coreutils`` may be installed using ``brew install
coreutils``.
There are three variants of the powerline client. The fastest is
written in C and will be compiled if the compiler and libraries are
detected during installation. The second fastest option is
:file:`powerline.sh` which requires ``socat`` and ``coreutils``.
``coreutils`` may be installed using ``brew install
coreutils``. If neither of these are viable, then Powerline will
utilize a fallback client written in Python.
2. Install Powerline using one of the following commands:
@ -30,7 +34,7 @@ Python package
.. code-block:: sh
pip install --user git+git://github.com/powerline/powerline
pip install --user git+https://github.com/powerline/powerline
will get latest development version.

View File

@ -37,8 +37,8 @@ Features
hassle for me / what happened to the original vim-powerline project / …*
You should check out some of the Powerline derivatives. The most lightweight
and feature-rich alternative is currently Bailey Lings `vim-airline
<https://github.com/bling/vim-airline>`_ project.
and feature-rich alternative is currently the `vim-airline
<https://github.com/vim-airline/vim-airline>`_ project.
Screenshots
-----------

View File

@ -3,11 +3,9 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
import os
from inspect import formatargspec
from sphinx.ext import autodoc
from powerline.lint.inspect import getconfigargspec
from powerline.lint.inspect import formatconfigargspec, getconfigargspec
from powerline.segments import Segment
from powerline.lib.unicode import unicode
@ -28,7 +26,7 @@ class ThreadedDocumenter(autodoc.FunctionDocumenter):
def format_args(self):
argspec = getconfigargspec(self.object)
return formatargspec(*argspec, formatvalue=formatvalue).replace('\\', '\\\\')
return formatconfigargspec(*argspec, formatvalue=formatvalue).replace('\\', '\\\\')
class Repr(object):

View File

@ -17,6 +17,22 @@ statusline:
set showtabline=2 " Always display the tabline, even if there is only one tab
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
.. _tips-and-tricks-vscode:
VS-Code
=======
Useful settings
---------------
To make powerline work in the internal terminal, add the following settings;
where the shell command needs to be adjusted according to your preferred shell.
.. code-block:: json
"terminal.integrated.shell.linux": "/bin/bash"
"terminal.integrated.inheritEnv": true
.. _tips-and-tricks-urxvt:
Rxvt-unicode

View File

@ -53,7 +53,7 @@ diagnose this problem you may do the following:
startup or, at least, that it was cleaned after update. While different
``$POWERLINE_COMMAND`` variable should not cause any troubles most of time
(and when it will cause troubles are rather trivial) spoiled
``$PROMPT_COMMAND`` may lead to strange error messages or absense of exit
``$PROMPT_COMMAND`` may lead to strange error messages or absence of exit
code reporting.
These are the sources which may keep outdated environment variables:
@ -143,6 +143,40 @@ started from.*
Shell issues
============
Pipe status segment displays only last value in bash
----------------------------------------------------
Make sure that powerline command that sets prompt appears the very first in
``$PROMPT_COMMAND``. To do this ``powerline.sh`` needs to be sourced the very
last, after all other users of ``$PROMPT_COMMAND``.
Bash prompt stopped updating
----------------------------
Make sure that powerline commands appear in ``$PROMPT_COMMAND``: some users of
``$PROMPT_COMMAND`` have a habit of overwriting the value instead of
prepending/appending to it. All powerline commands start with ``_powerline`` or
``powerline``, e.g. ``_powerline_set_prompt``.
Bash prompt does not show last exit code
----------------------------------------
There are two possibilities here:
* You are using ``default`` theme in place of ``default_leftonly``. Unlike
``default_leftonly`` ``default`` theme was designed for shells with right
prompt support (e.g. zsh, tcsh, fish) and status in question is supposed to be
shown on the right side which bash cannot display.
* There is some other user of ``$PROMPT_COMMAND`` which prepended to this
variable, but did not bother keeping the exit code. For the best experience
powerline must appear first in ``$PROMPT_COMMAND`` which may be achieved by
sourcing powerline bindings the last.
.. note::
Resourcing bash bindings will not resolve the problem unless you clear
powerline commands from ``$PROMPT_COMMAND`` first.
When sourcing shell bindings it complains about missing command or file
-----------------------------------------------------------------------
@ -159,8 +193,12 @@ I am suffering bad lags before displaying shell prompt
To get rid of these lags there currently are two options:
* Run ``powerline-daemon``. Powerline does not automatically start it for you.
See installation instructions for more details.
* Compile and install ``libzpython`` module that lives in
https://bitbucket.org/ZyX_I/zpython. This variant is zsh-specific.
* If you are a python package manager, be sure to set ``POWERLINE_COMMAND``
to your Powerline command. See installation instructions for details.
Prompt is spoiled after completing files in ksh
-----------------------------------------------

View File

@ -27,7 +27,7 @@ The colors look weird in iTerm2!
* The arrows may have the wrong colors if you have changed the “minimum
contrast” slider in the color tab of your OS X settings.
* Please disable background transparency to resolve this issue.
* If you're using transparency, check “Keep background colors opaque”.
Statusline is getting wrapped to the next line in iTerm2
--------------------------------------------------------

View File

@ -8,7 +8,7 @@ Application-specific requirements
Vim plugin requirements
^^^^^^^^^^^^^^^^^^^^^^^
The vim plugin requires a vim version with Python support compiled in. Presense
The vim plugin requires a vim version with Python support compiled in. Presence
of Python support in Vim can be checked by running ``vim --version | grep
+python``.

View File

@ -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`:
@ -100,9 +104,72 @@ 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
==============
For IPython>=7.0, add the following line to
:file:`~/.ipython/profile_default/ipython_config.py` file in the used profile:
.. code-block:: Python
from powerline.bindings.ipython.since_7 import PowerlinePrompts
c.TerminalInteractiveShell.prompts_class = PowerlinePrompts
.. note::
If certain graphical/colored elements are not showing, make sure `c.TerminalInteractiveShell.simple_prompt`
is set to `False` in your config.
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 ``simple_prompt`` is set to ``False`` by default and IPython
is not very useful without it.
For IPython>=5.0 and <7.0 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
For IPython>=5.0 and <7.0 you may use the below set up, but it is deprecated.
For IPython>=0.11 add the following line to
:file:`~/.ipython/profile_default/ipython_config.py` file in the used profile:
.. code-block:: Python
c = get_config()
c.InteractiveShellApp.extensions = [
'powerline.bindings.ipython.post_0_11'
]
For IPython<0.11 add the following lines to :file:`.ipython/ipy_user_conf.py`:
.. code-block:: Python
@ -114,15 +181,6 @@ For IPython<0.11 add the following lines to :file:`.ipython/ipy_user_conf.py`:
# create skeleton ipy_user_conf.py file):
powerline_setup()
For IPython>=0.11 add the following line to
:file:`~/.ipython/profile_default/ipython_config.py` file in the used profile:
.. code-block:: Python
c = get_config()
c.InteractiveShellApp.extensions = [
'powerline.bindings.ipython.post_0_11'
]
IPython=0.11* is not supported and does not work. IPython<0.10 was not
tested (not installable by pip).

View File

@ -1,10 +1,13 @@
.. _usage-shell:
*************
Shell prompts
*************
.. note::
Powerline daemon is not run automatically by any of my bindings. It is
advised to add
Powerline can operate without a background daemon, but the shell performance
can be very slow. The Powerline daemon improves this performance
significantly, but must be started separately. It is advised to add
.. code-block:: bash
@ -109,7 +112,7 @@ following in ``~/.profile``:
.. code-block:: bash
if test "x$0" != "x${0#dash}" ; then
if test "$0" != "${0#dash}" ; then
export ENV={repository_root}/powerline/bindings/shell/powerline.sh
fi
@ -140,3 +143,19 @@ following in ``~/.profile``:
.. warning::
Busybox has two shells: ``ash`` and ``hush``. Second is known to segfault in
busybox 1.22.1 when using :file:`powerline.sh` script.
Python Virtual Environments (conda, pyenv)
==========================================
If your system uses virtual environments to manage different Python versions,
such as pyenv or anaconda, these tools will add a performance delay to every
shell prompt. This delay can be bypassed by explicitly specifying your command
path.
.. code-block:: bash
export POWERLINE_COMMAND={path_to_powerline}
where ``{path_to_powerline}`` is the full filepath for powerline. If you
installed Powerline within an environment, you can find this path for pyenv
with ``pyenv which powerline`` or for conda with ``which powerline``.

View File

@ -5,7 +5,7 @@ Window manager widgets
Awesome widget
==============
.. note:: Powerline currently only supports awesome 3.5.
.. note:: Powerline currently only supports awesome 3.5 and 4+.
.. note:: The Powerline widget will spawn a shell script that runs in the
background and updates the statusline with ``awesome-client``.
@ -23,7 +23,17 @@ Then add the ``powerline_widget`` to ``wibox``:
.. code-block:: lua
-- awesome3.5
right_layout:add(powerline_widget)
-- awesome4+
s.mywibox:setup {
...
{ -- Right widgets
...
powerline_widget,
},
}
Qtile widget
============
@ -67,8 +77,7 @@ to run with i3, simply ``exec`` this in the i3 config file and set the ``--i3``
exec python /path/to/powerline/bindings/lemonbar/powerline-lemonbar.py --i3
Running the binding in i3-mode will require `i3ipc <https://github.com/acrisci/i3ipc-python>`_
(or the outdated `i3-py <https://github.com/ziberna/i3-py>`_).
Running the binding in i3-mode will require `i3ipc <https://github.com/acrisci/i3ipc-python>`_.
See the `lemonbar documentation <https://github.com/LemonBoy/bar>`_ for more
information and options.
@ -82,20 +91,11 @@ All ``powerline-lemonbar.py`` arguments:
I3 bar
======
.. note::
As the patch to include background-colors in i3bar is likely not to be
merged, it is recommended to instead run ``bar`` (see above). The source for
i3bgbar is however still available `here
<https://github.com/S0lll0s/i3bgbar>`_.
Add the following to :file:`~/.i3/config`::
Add the following to :file:`~/.config/i3/config`::
bar {
i3bar_command i3bgbar
status_command python /path/to/powerline/bindings/i3/powerline-i3.py
font pango:PowerlineFont 12
}
where ``i3bgbar`` may be replaced with the path to the custom i3bar binary and
``PowerlineFont`` is any system font with powerline support.
where ``PowerlineFont`` is any system font with powerline support.

View File

@ -78,6 +78,10 @@
<family>Ubuntu Mono</family>
<prefer><family>PowerlineSymbols</family></prefer>
</alias>
<alias>
<family>Ubuntu Sans Mono</family>
<prefer><family>PowerlineSymbols</family></prefer>
</alias>
<alias>
<family>Meslo LG L</family>
<prefer><family>PowerlineSymbols</family></prefer>

View File

@ -14,7 +14,7 @@ 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
from powerline.version import __version__
class NotInterceptedError(BaseException):
pass
@ -55,8 +55,8 @@ class PowerlineLogger(object):
``{message}``
is the original message passed to one of the logging methods.
Each of the methods (``critical``, ``exception``, ``info``, ``error``,
``warn``, ``debug``) expects to receive message in an ``str.format`` format,
Each of the methods (``critical``, ``exception``, ``info``, ``error``,
``warn``, ``debug``) expects to receive message in an ``str.format`` format,
not in printf-like format.
Log is saved to the location :ref:`specified by user <config-common-log>`.
@ -159,11 +159,11 @@ def generate_config_finder(get_config_paths=get_config_paths):
This function will find .json file given its path.
:param function get_config_paths:
Function that being called with no arguments will return a list of paths
Function that being called with no arguments will return a list of paths
that should be searched for configuration files.
:return:
Function that being given configuration file name will return full path
Function that being given configuration file name will return full path
to it or raise IOError if it failed to find the file.
'''
config_paths = get_config_paths()
@ -178,12 +178,12 @@ def load_config(cfg_path, find_config_files, config_loader, loader_callback=None
:param str cfg_path:
Path for configuration file that should be loaded.
:param function find_config_files:
Function that finds configuration file. Check out the description of
Function that finds configuration file. Check out the description of
the return value of ``generate_config_finder`` function.
:param ConfigLoader config_loader:
Configuration file loader class instance.
:param function loader_callback:
Function that will be called by config_loader when change to
Function that will be called by config_loader when change to
configuration file is detected.
:return: Configuration file contents.
@ -210,7 +210,7 @@ def _set_log_handlers(common_config, logger, get_module_attr, stream=None):
:param func get_module_attr:
:py:func:`gen_module_attr_getter` output.
:param file stream:
Stream to use by default for :py:class:`logging.StreamHandler` in place
Stream to use by default for :py:class:`logging.StreamHandler` in place
of :py:attr:`sys.stderr`. May be ``None``.
'''
log_targets = common_config['log_file']
@ -266,16 +266,16 @@ def create_logger(common_config, use_daemon_threads=True, ext='__unknown__',
:param dict common_config:
Common configuration, from :py:func:`finish_common_config`.
:param bool use_daemon_threads:
Whether daemon threads should be used. Argument to
Whether daemon threads should be used. Argument to
:py:class:`PowerlineLogger` constructor.
:param str ext:
Used extension. Argument to :py:class:`PowerlineLogger` constructor.
:param set imported_modules:
Set where imported modules are saved. Argument to
:py:func:`gen_module_attr_getter`. May be ``None``, in this case new
Set where imported modules are saved. Argument to
:py:func:`gen_module_attr_getter`. May be ``None``, in this case new
empty set is used.
:param file stream:
Stream to use by default for :py:class:`logging.StreamHandler` in place
Stream to use by default for :py:class:`logging.StreamHandler` in place
of :py:attr:`sys.stderr`. May be ``None``.
:return: Three objects:
@ -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
@ -305,14 +317,12 @@ def finish_common_config(encoding, common_config):
Common configuration, as it was just loaded.
:return:
Copy of common configuration with all configuration keys and expanded
Copy of common configuration with all configuration keys and expanded
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)
@ -365,13 +375,13 @@ def gen_module_attr_getter(pl, import_paths, imported_modules):
:param str module:
Module name, will be passed as first argument to ``__import__``.
:param str attr:
Module attribute, will be passed to ``__import__`` as the only value
Module attribute, will be passed to ``__import__`` as the only value
in ``fromlist`` tuple.
:return:
Attribute value or ``None``. Note: there is no way to distinguish
between successfull import of attribute equal to ``None`` and
unsuccessfull import.
Attribute value or ``None``. Note: there is no way to distinguish
between successful import of attribute equal to ``None`` and
unsuccessful import.
'''
oldpath = sys.path
sys.path = import_paths + sys.path
@ -401,7 +411,7 @@ def _get_log_keys(common_config):
Common configuration.
:return:
:py:class:`dict` instance which has only keys from
:py:class:`dict` instance which has only keys from
:py:attr:`powerline.LOG_KEYS` left.
'''
return dict((
@ -409,30 +419,35 @@ def _get_log_keys(common_config):
))
DEFAULT_UPDATE_INTERVAL = 2
'''Default value for :ref:`update_interval <config-ext-update_interval>`
'''
class Powerline(object):
'''Main powerline class, entrance point for all powerline uses. Sets
'''Main powerline class, entrance point for all powerline uses. Sets
powerline up and loads the configuration.
:param str ext:
extension used. Determines where configuration files will
searched and what renderer module will be used. Affected: used ``ext``
dictionary from :file:`powerline/config.json`, location of themes and
extension used. Determines where configuration files will
searched and what renderer module will be used. Affected: used ``ext``
dictionary from :file:`powerline/config.json`, location of themes and
colorschemes, render module (``powerline.renders.{ext}``).
:param str renderer_module:
Overrides renderer module (defaults to ``ext``). Should be the name of
the package imported like this: ``powerline.renderers.{render_module}``.
If this parameter contains a dot ``powerline.renderers.`` is not
prepended. There is also a special case for renderers defined in
toplevel modules: ``foo.`` (note: dot at the end) tries to get renderer
from module ``foo`` (because ``foo`` (without dot) tries to get renderer
from module ``powerline.renderers.foo``). When ``.foo`` (with leading
dot) variant is used ``renderer_module`` will be
Overrides renderer module (defaults to ``ext``). Should be the name of
the package imported like this: ``powerline.renderers.{render_module}``.
If this parameter contains a dot ``powerline.renderers.`` is not
prepended. There is also a special case for renderers defined in
toplevel modules: ``foo.`` (note: dot at the end) tries to get renderer
from module ``foo`` (because ``foo`` (without dot) tries to get renderer
from module ``powerline.renderers.foo``). When ``.foo`` (with leading
dot) variant is used ``renderer_module`` will be
``powerline.renderers.{ext}{renderer_module}``.
:param bool run_once:
Determines whether :py:meth:`render` method will be run only once
Determines whether :py:meth:`render` method will be run only once
during python session.
:param Logger logger:
If present no new logger will be created and the provided logger will be
If present no new logger will be created and the provided logger will be
used.
:param bool use_daemon_threads:
When creating threads make them daemon ones.
@ -456,10 +471,10 @@ class Powerline(object):
config_loader=None):
'''Do actual initialization.
__init__ function only stores the arguments and runs this function. This
function exists for powerline to be able to reload itself: it is easier
to make ``__init__`` store arguments and call overriddable ``init`` than
tell developers that each time they override Powerline.__init__ in
__init__ function only stores the arguments and runs this function. This
function exists for powerline to be able to reload itself: it is easier
to make ``__init__`` store arguments and call overridable ``init`` than
tell developers that each time they override Powerline.__init__ in
subclasses they must store actual arguments.
'''
self.ext = ext
@ -504,6 +519,7 @@ class Powerline(object):
self.setup_args = ()
self.setup_kwargs = {}
self.imported_modules = set()
self.update_interval = DEFAULT_UPDATE_INTERVAL
get_encoding = staticmethod(get_preferred_output_encoding)
'''Get encoding used by the current application
@ -514,7 +530,7 @@ class Powerline(object):
def create_logger(self):
'''Create logger
This function is used to create logger unless it was already specified
This function is used to create logger unless it was already specified
at initialization.
:return: Three objects:
@ -532,18 +548,18 @@ class Powerline(object):
)
def create_renderer(self, load_main=False, load_colors=False, load_colorscheme=False, load_theme=False):
'''(Re)create renderer object. Can be used after Powerline object was
successfully initialized. If any of the below parameters except
'''(Re)create renderer object. Can be used after Powerline object was
successfully initialized. If any of the below parameters except
``load_main`` is True renderer object will be recreated.
:param bool load_main:
Determines whether main configuration file (:file:`config.json`)
should be loaded. If appropriate configuration changes implies
``load_colorscheme`` and ``load_theme`` and recreation of renderer
object. Wont trigger recreation if only unrelated configuration
Determines whether main configuration file (:file:`config.json`)
should be loaded. If appropriate configuration changes implies
``load_colorscheme`` and ``load_theme`` and recreation of renderer
object. Wont trigger recreation if only unrelated configuration
changed.
:param bool load_colors:
Determines whether colors configuration from :file:`colors.json`
Determines whether colors configuration from :file:`colors.json`
should be (re)loaded.
:param bool load_colorscheme:
Determines whether colorscheme configuration should be (re)loaded.
@ -628,6 +644,7 @@ class Powerline(object):
or self.ext_config.get('local_themes') != self.prev_ext_config.get('local_themes')
):
self.renderer_options['local_themes'] = self.get_local_themes(self.ext_config.get('local_themes'))
self.update_interval = self.ext_config.get('update_interval', 2)
load_colorscheme = (
load_colorscheme
or not self.prev_ext_config
@ -665,8 +682,8 @@ class Powerline(object):
else:
raise ImportError('Failed to obtain renderer')
# Renderer updates configuration file via segments .startup thus it
# should be locked to prevent state when configuration was updated,
# Renderer updates configuration file via segments .startup thus it
# should be locked to prevent state when configuration was updated,
# but .render still uses old renderer.
try:
renderer = Renderer(**self.renderer_options)
@ -680,8 +697,8 @@ class Powerline(object):
default_log_stream = sys.stdout
'''Default stream for default log handler
Usually it is ``sys.stderr``, but there is sometimes a reason to prefer
``sys.stdout`` or a custom file-like object. It is not supposed to be used
Usually it is ``sys.stderr``, but there is sometimes a reason to prefer
``sys.stdout`` or a custom file-like object. It is not supposed to be used
to write to some file.
'''
@ -689,7 +706,7 @@ class Powerline(object):
'''Run component-specific setup
:param set components:
Set of the enabled componets or None.
Set of the enabled components or None.
Should be overridden by subclasses.
'''
@ -699,7 +716,7 @@ class Powerline(object):
def get_config_paths():
'''Get configuration paths.
Should be overridden in subclasses in order to provide a way to override
Should be overridden in subclasses in order to provide a way to override
used paths.
:return: list of paths
@ -710,10 +727,10 @@ class Powerline(object):
'''Load configuration and setup watches
:param str cfg_path:
Path to the configuration file without any powerline configuration
Path to the configuration file without any powerline configuration
directory or ``.json`` suffix.
:param str cfg_type:
Configuration type. May be one of ``main`` (for ``config.json``
Configuration type. May be one of ``main`` (for ``config.json``
file), ``colors``, ``colorscheme``, ``theme``.
:return: dictionary with loaded configuration.
@ -741,15 +758,15 @@ class Powerline(object):
'''Load and merge multiple configuration files
:param str cfg_type:
Type of the loaded configuration files (e.g. ``colorscheme``,
Type of the loaded configuration files (e.g. ``colorscheme``,
``theme``).
:param list levels:
Configuration names resembling levels in hierarchy, sorted by
priority. Configuration file names with higher priority should go
Configuration names resembling levels in hierarchy, sorted by
priority. Configuration file names with higher priority should go
last.
:param set ignore_levels:
If only files listed in this variable are present then configuration
file is considered not loaded: at least one file on the level not
If only files listed in this variable are present then configuration
file is considered not loaded: at least one file on the level not
listed in this variable must be present.
'''
config = {}
@ -815,16 +832,16 @@ class Powerline(object):
@staticmethod
def get_local_themes(local_themes):
'''Get local themes. No-op here, to be overridden in subclasses if
'''Get local themes. No-op here, to be overridden in subclasses if
required.
:param dict local_themes:
Usually accepts ``{matcher_name : theme_name}``. May also receive
Usually accepts ``{matcher_name : theme_name}``. May also receive
None in case there is no local_themes configuration.
:return:
anything accepted by ``self.renderer.get_theme`` and processable by
``self.renderer.add_local_theme``. Renderer module is determined by
anything accepted by ``self.renderer.get_theme`` and processable by
``self.renderer.add_local_theme``. Renderer module is determined by
``__init__`` arguments, refer to its documentation.
'''
return None
@ -852,7 +869,7 @@ class Powerline(object):
self.cr_kwargs.clear()
def render(self, *args, **kwargs):
'''Update/create renderer if needed and pass all arguments further to
'''Update/create renderer if needed and pass all arguments further to
``self.renderer.render()``.
'''
try:
@ -887,7 +904,7 @@ class Powerline(object):
def setup(self, *args, **kwargs):
'''Setup the environment to use powerline.
Must not be overridden by subclasses. This one only saves setup
Must not be overridden by subclasses. This one only saves setup
arguments for :py:meth:`reload` method and calls :py:meth:`do_setup`.
'''
self.shutdown_event.clear()
@ -899,7 +916,7 @@ class Powerline(object):
def do_setup():
'''Function that does initialization
Should be overridden by subclasses. May accept any number of regular or
Should be overridden by subclasses. May accept any number of regular or
keyword arguments.
'''
pass
@ -909,12 +926,12 @@ class Powerline(object):
Should handle most (but not all) powerline updates.
Purges out all powerline modules and modules imported by powerline for
segment and matcher functions. Requires defining ``setup`` function that
Purges out all powerline modules and modules imported by powerline for
segment and matcher functions. Requires defining ``setup`` function that
updates reference to main powerline object.
.. warning::
Not guaranteed to work properly, use it at your own risk. It
Not guaranteed to work properly, use it at your own risk. It
may break your python code.
'''
import sys
@ -922,7 +939,7 @@ class Powerline(object):
modules_holder = []
for module in modules:
try:
# Needs to hold module to prevent garbage collecting until they
# Needs to hold module to prevent garbage collecting until they
# are all reloaded.
modules_holder.append(sys.modules.pop(module))
except KeyError:
@ -937,12 +954,12 @@ class Powerline(object):
'''Shut down all background threads.
:param bool set_event:
Set ``shutdown_event`` and call ``renderer.shutdown`` which should
shut down all threads. Set it to False unless you are exiting an
Set ``shutdown_event`` and call ``renderer.shutdown`` which should
shut down all threads. Set it to False unless you are exiting an
application.
If set to False this does nothing more then resolving reference
cycle ``powerline config_loader bound methods powerline`` by
If set to False this does nothing more then resolving reference
cycle ``powerline config_loader bound methods powerline`` by
unsubscribing from config_loader events.
'''
if set_event:

View File

@ -4,38 +4,17 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
import sys
from time import sleep
from subprocess import Popen, PIPE
from powerline import Powerline
from powerline.lib.monotonic import monotonic
powerline = Powerline('wm', renderer_module='pango_markup')
powerline.update_renderer()
try:
interval = float(sys.argv[1])
except IndexError:
interval = 2
from powerline.bindings.wm import DEFAULT_UPDATE_INTERVAL
from powerline.bindings.wm.awesome import run
def read_to_log(pl, client):
for line in client.stdout:
if line:
pl.info(line, prefix='awesome-client')
for line in client.stderr:
if line:
pl.error(line, prefix='awesome-client')
if client.wait():
pl.error('Client exited with {0}', client.returncode, prefix='awesome')
def main():
try:
interval = float(sys.argv[1])
except IndexError:
interval = DEFAULT_UPDATE_INTERVAL
run(interval=interval)
while True:
start_time = monotonic()
s = powerline.render(side='right')
request = 'powerline_widget:set_markup(\'' + s.replace('\\', '\\\\').replace('\'', '\\\'') + '\')\n'
client = Popen(['awesome-client'], shell=False, stdout=PIPE, stderr=PIPE, stdin=PIPE)
client.stdin.write(request.encode('utf-8'))
client.stdin.close()
read_to_log(powerline.pl, client)
sleep(max(interval - (monotonic() - start_time), 0.1))
if __name__ == '__main__':
main()

View File

@ -6,6 +6,10 @@ powerline_widget:set_align('right')
function powerline(mode, widget) end
bindings_path = string.gsub(debug.getinfo(1).source:match('@(.*)$'), '/[^/]+$', '')
powerline_cmd = bindings_path .. '/powerline-awesome.py'
awful.util.spawn_with_shell('ps -C powerline-awesome.py || ' .. powerline_cmd)
if string.find(awesome.version, 'v4') then
awful.spawn.with_shell('powerline-daemon -q')
awful.spawn.with_shell('powerline wm.awesome')
else
awful.util.spawn_with_shell('powerline-daemon -q')
awful.util.spawn_with_shell('powerline wm.awesome')
end

View File

@ -11,6 +11,7 @@ from argparse import ArgumentParser
from powerline.lemonbar import LemonbarPowerline
from powerline.lib.encoding import get_unicode_writer
from powerline.bindings.wm import DEFAULT_UPDATE_INTERVAL
if __name__ == '__main__':
@ -29,7 +30,7 @@ if __name__ == '__main__':
def render(reschedule=False):
if reschedule:
Timer(0.5, render, kwargs={'reschedule': True}).start()
Timer(DEFAULT_UPDATE_INTERVAL, render, kwargs={'reschedule': True}).start()
global lock
with lock:

View File

@ -1,5 +1,5 @@
_powerline_columns_fallback() {
if which stty &>/dev/null ; then
if command -v stty &>/dev/null ; then
local cols="$(stty size 2>/dev/null)"
if ! test -z "$cols" ; then
echo "${cols#* }"
@ -10,18 +10,60 @@ _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
}
_powerline_tmux_set_pwd() {
if test "x$_POWERLINE_SAVED_PWD" != "x$PWD" ; then
if test "$_POWERLINE_SAVED_PWD" != "$PWD" ; then
_POWERLINE_SAVED_PWD="$PWD"
_powerline_tmux_setenv PWD "$PWD"
fi
}
_powerline_return() {
return $1
}
_POWERLINE_HAS_PIPESTATUS="$(
_powerline_return 0 | _powerline_return 43
test "${PIPESTATUS[*]}" = "0 43"
echo "$?"
)"
_powerline_has_pipestatus() {
return $_POWERLINE_HAS_PIPESTATUS
}
_powerline_status_wrapper() {
local last_exit_code=$? last_pipe_status=( "${PIPESTATUS[@]}" )
if ! _powerline_has_pipestatus \
|| test "${#last_pipe_status[@]}" -eq "0" \
|| test "$last_exit_code" != "${last_pipe_status[$(( ${#last_pipe_status[@]} - 1 ))]}" ; then
last_pipe_status=()
fi
"$@" $last_exit_code "${last_pipe_status[*]}"
return $last_exit_code
}
_powerline_add_status_wrapped_command() {
local action="$1" ; shift
local cmd="$1" ; shift
full_cmd="_powerline_status_wrapper $cmd"
if test "$action" = "append" ; then
PROMPT_COMMAND="$PROMPT_COMMAND"$'\n'"$full_cmd"
else
PROMPT_COMMAND="$full_cmd"$'\n'"$PROMPT_COMMAND"
fi
}
_powerline_tmux_set_columns() {
_powerline_tmux_setenv COLUMNS "${COLUMNS:-`_powerline_columns_fallback`}"
}
@ -34,42 +76,54 @@ _powerline_init_tmux_support() {
trap '_powerline_tmux_set_columns' WINCH
_powerline_tmux_set_columns
test "x$PROMPT_COMMAND" != "x${PROMPT_COMMAND/_powerline_tmux_set_pwd}" ||
PROMPT_COMMAND="${PROMPT_COMMAND}"$'\n_powerline_tmux_set_pwd'
test "$PROMPT_COMMAND" != "${PROMPT_COMMAND/_powerline_tmux_set_pwd}" \
|| _powerline_add_status_wrapped_command append _powerline_tmux_set_pwd
fi
}
_powerline_local_prompt() {
# Arguments: side, renderer_module arg, last_exit_code, jobnum, local theme
# Arguments:
# 1: side
# 2: renderer_module arg
# 3: last_exit_code
# 4: last_pipe_status
# 5: jobnum
# 6: local theme
"$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
$2 \
--last-exit-code=$3 \
--jobnum=$4 \
--last-pipe-status="$4" \
--jobnum=$5 \
--renderer-arg="client_id=$$" \
--renderer-arg="local_theme=$5"
--renderer-arg="local_theme=$6"
}
_powerline_prompt() {
# Arguments: side, last_exit_code, jobnum
# Arguments:
# 1: side
# 2: last_exit_code
# 3: last_pipe_status
# 4: jobnum
"$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS shell $1 \
--width="${COLUMNS:-$(_powerline_columns_fallback)}" \
-r.bash \
--last-exit-code=$2 \
--jobnum=$3 \
--last-pipe-status="$3" \
--jobnum=$4 \
--renderer-arg="client_id=$$"
}
_powerline_set_prompt() {
local last_exit_code=$?
local last_exit_code=$1 ; shift
local last_pipe_status=$1 ; shift
local jobnum="$(jobs -p|wc -l)"
PS1="$(_powerline_prompt aboveleft $last_exit_code $jobnum)"
PS1="$(_powerline_prompt aboveleft $last_exit_code "$last_pipe_status" $jobnum)"
if test -n "$POWERLINE_SHELL_CONTINUATION$POWERLINE_BASH_CONTINUATION" ; then
PS2="$(_powerline_local_prompt left -r.bash $last_exit_code $jobnum continuation)"
PS2="$(_powerline_local_prompt left -r.bash $last_exit_code "$last_pipe_status" $jobnum continuation)"
fi
if test -n "$POWERLINE_SHELL_SELECT$POWERLINE_BASH_SELECT" ; then
PS3="$(_powerline_local_prompt left '' $last_exit_code $jobnum select)"
PS3="$(_powerline_local_prompt left '' $last_exit_code "$last_pipe_status" $jobnum select)"
fi
return $last_exit_code
}
_powerline_setup_prompt() {
@ -77,14 +131,14 @@ _powerline_setup_prompt() {
if test -z "${POWERLINE_COMMAND}" ; then
POWERLINE_COMMAND="$("$POWERLINE_CONFIG_COMMAND" shell command)"
fi
test "x$PROMPT_COMMAND" != "x${PROMPT_COMMAND%_powerline_set_prompt*}" ||
PROMPT_COMMAND=$'_powerline_set_prompt\n'"${PROMPT_COMMAND}"
PS2="$(_powerline_local_prompt left -r.bash 0 0 continuation)"
PS3="$(_powerline_local_prompt left '' 0 0 select)"
test "$PROMPT_COMMAND" != "${PROMPT_COMMAND%_powerline_set_prompt*}" \
|| _powerline_add_status_wrapped_command prepend _powerline_set_prompt
PS2="$(_powerline_local_prompt left -r.bash 0 0 0 continuation)"
PS3="$(_powerline_local_prompt left '' 0 0 0 select)"
}
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
if which powerline-config >/dev/null ; then
if command -v powerline-config >/dev/null ; then
POWERLINE_CONFIG_COMMAND=powerline-config
else
POWERLINE_CONFIG_COMMAND="$(dirname "$BASH_SOURCE")/../../../scripts/powerline-config"

View File

@ -99,7 +99,7 @@ class EmptyArgs(object):
def init_tmux_environment(pl, args, set_tmux_environment=set_tmux_environment):
'''Initialize tmux environment from tmux configuration
'''
powerline = ShellPowerline(finish_args(os.environ, EmptyArgs('tmux', args.config_path)))
powerline = ShellPowerline(finish_args(None, os.environ, EmptyArgs('tmux', args.config_path)))
# TODO Move configuration files loading out of Powerline object and use it
# directly
powerline.update_renderer()
@ -164,7 +164,10 @@ def init_tmux_environment(pl, args, set_tmux_environment=set_tmux_environment):
# But it does not support empty attributes as well.
or 'none'))
else:
set_tmux_environment(varname, 'colour' + str(get_highlighting(group)[attr][0]))
if powerline.common_config['term_truecolor']:
set_tmux_environment(varname, '#{0:06x}'.format(get_highlighting(group)[attr][1]))
else:
set_tmux_environment(varname, 'colour' + str(get_highlighting(group)[attr][0]))
left_dividers = powerline.renderer.theme.dividers['left']
set_tmux_environment('_POWERLINE_LEFT_HARD_DIVIDER', left_dividers['hard'])
@ -173,7 +176,7 @@ def init_tmux_environment(pl, args, set_tmux_environment=set_tmux_environment):
' ' * powerline.renderer.strwidth(left_dividers['hard'])))
TMUX_VAR_RE = re.compile('\$(_POWERLINE_\w+)')
TMUX_VAR_RE = re.compile(r'\$(_POWERLINE_\w+)')
def tmux_setup(pl, args):

View File

@ -1,5 +1,5 @@
function powerline-setup
function _powerline_columns_fallback
function _powerline_columns
if which stty >/dev/null
if stty size >/dev/null
stty size | cut -d' ' -f2
@ -10,17 +10,6 @@ function powerline-setup
return 0
end
function _powerline_columns
# Hack: `test "" -eq 0` is true, as well as `test 0 -eq 0`
# Note: at fish startup `$COLUMNS` is equal to zero, meaning that it may
# not be used.
if test "$COLUMNS" -eq 0
_powerline_columns_fallback
else
echo "$COLUMNS"
end
end
if test -z "$POWERLINE_CONFIG_COMMAND"
if which powerline-config >/dev/null
set -g POWERLINE_CONFIG_COMMAND powerline-config
@ -33,18 +22,18 @@ 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
if test x$fish_key_bindings != xfish_vi_key_bindings
function _powerline_set_default_mode --on-variable fish_key_bindings
if test $fish_key_bindings != fish_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)"
# One random value has an 1/32767 = 0.0031% probability of having
# One random value has an 1/32767 = 0.0031% probability of having
# the same value in two shells
set -l addargs "$addargs --renderer-arg=client_id="(random)
set -l addargs "$addargs --width=\$_POWERLINE_COLUMNS"
@ -62,7 +51,7 @@ function powerline-setup
set rpromptpast
set columnsexpr '(_powerline_columns)'
end
eval "
echo "
function fish_prompt
env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell $promptside $addargs
end
@ -70,10 +59,12 @@ function powerline-setup
env \$POWERLINE_COMMAND $POWERLINE_COMMAND_ARGS shell right $addargs
$rpromptpast
end
function --on-signal WINCH _powerline_set_columns
function fish_mode_prompt
end
function _powerline_set_columns --on-signal WINCH
set -g _POWERLINE_COLUMNS $columnsexpr
end
"
" | source
_powerline_set_columns
end
_powerline_set_default_mode
@ -82,14 +73,22 @@ function powerline-setup
if env $POWERLINE_CONFIG_COMMAND shell --shell=fish uses tmux
if test -n "$TMUX"
if tmux refresh -S ^/dev/null
function _powerline_tmux_setenv
tmux setenv -g TMUX_$argv[1]_(tmux display -p "#D" | tr -d "%") "$argv[2]"
tmux refresh -S
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 --on-variable PWD _powerline_tmux_set_pwd
function _powerline_tmux_setenv
env TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_$argv[1]_(_powerline_tmux_pane) "$argv[2]"
env TMUX="$_POWERLINE_TMUX" tmux refresh -S
end
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

View File

@ -7,37 +7,44 @@ import time
from threading import Lock
import i3
from powerline.bindings.wm import get_i3_connection, i3_subscribe
from powerline import Powerline
from powerline.lib.monotonic import monotonic
class I3Powerline(Powerline):
'''Powerline child for i3bar
Currently only changes the default log target.
'''
default_log_stream = sys.stderr
if __name__ == '__main__':
name = 'wm'
if len(sys.argv) > 1:
name = sys.argv[1]
powerline = Powerline(name, renderer_module='i3bar')
powerline = I3Powerline(name, renderer_module='i3bar')
powerline.update_renderer()
interval = 0.5
print ('{"version": 1, "custom_workspace": true}')
print ('{"version": 1}')
print ('[')
print ('\t[[],[]]')
print ('[]')
lock = Lock()
def render(event=None, data=None, sub=None):
global lock
with lock:
s = '[\n' + powerline.render(side='right')[:-2] + '\n]\n'
s += ',[\n' + powerline.render(side='left')[:-2] + '\n]'
print (',[\n' + s + '\n]')
print (',[' + powerline.render()[:-1] + ']')
sys.stdout.flush()
sub = i3.Subscription(render, 'workspace')
i3 = get_i3_connection()
i3_subscribe(i3, 'workspace', render)
while True:
start_time = monotonic()

View File

@ -1,12 +1,21 @@
# 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)
from weakref import ref
from warnings import warn
from IPython.core.prompts import PromptManager
try:
from IPython.core.prompts import PromptManager
has_prompt_manager = True
except ImportError:
has_prompt_manager = False
from IPython.core.magic import Magics, magics_class, line_magic
from powerline.ipython import IPythonPowerline, RewriteResult
from powerline.ipython import IPythonPowerline, IPythonInfo
if has_prompt_manager:
from powerline.ipython import RewriteResult
@magics_class
@ -23,41 +32,13 @@ class PowerlineMagics(Magics):
raise ValueError('Expected `reload`, but got {0}'.format(line))
class IPythonInfo(object):
def __init__(self, shell):
self._shell = shell
@property
def prompt_count(self):
return self._shell.execution_count
class PowerlinePromptManager(PromptManager):
def __init__(self, powerline, shell):
self.powerline = powerline
self.powerline_segment_info = IPythonInfo(shell)
self.shell = shell
def render(self, name, color=True, *args, **kwargs):
res = self.powerline.render(
is_prompt=name.startswith('in'),
side='left',
output_width=True,
output_raw=not color,
matcher_info=name,
segment_info=self.powerline_segment_info,
)
self.txtwidth = res[-1]
self.width = res[-1]
ret = res[0] if color else res[1]
if name == 'rewrite':
return RewriteResult(ret)
else:
return ret
old_prompt_manager = None
class ShutdownHook(object):
powerline = lambda: None
def __init__(self, ip):
self.powerline = lambda: None
ip.hooks.shutdown_hook.add(self)
def __call__(self):
from IPython.core.hooks import TryNext
@ -67,40 +48,79 @@ class ShutdownHook(object):
raise TryNext()
class ConfigurableIPythonPowerline(IPythonPowerline):
def init(self, ip):
config = ip.config.Powerline
self.config_overrides = config.get('config_overrides')
self.theme_overrides = config.get('theme_overrides', {})
self.config_paths = config.get('config_paths')
super(ConfigurableIPythonPowerline, self).init()
if has_prompt_manager:
class PowerlinePromptManager(PromptManager):
def __init__(self, powerline, shell):
self.powerline = powerline
self.powerline_segment_info = IPythonInfo(shell)
self.shell = shell
def do_setup(self, ip, shutdown_hook):
prompt_manager = PowerlinePromptManager(
powerline=self,
shell=ip.prompt_manager.shell,
)
magics = PowerlineMagics(ip, self)
shutdown_hook.powerline = ref(self)
def render(self, name, color=True, *args, **kwargs):
res = self.powerline.render(
is_prompt=name.startswith('in'),
side='left',
output_width=True,
output_raw=not color,
matcher_info=name,
segment_info=self.powerline_segment_info,
)
self.txtwidth = res[-1]
self.width = res[-1]
ret = res[0] if color else res[1]
if name == 'rewrite':
return RewriteResult(ret)
else:
return ret
ip.prompt_manager = prompt_manager
ip.register_magics(magics)
class ConfigurableIPythonPowerline(IPythonPowerline):
def init(self, ip):
config = ip.config.Powerline
self.config_overrides = config.get('config_overrides')
self.theme_overrides = config.get('theme_overrides', {})
self.config_paths = config.get('config_paths')
if has_prompt_manager:
renderer_module = '.pre_5'
else:
renderer_module = '.since_7'
super(ConfigurableIPythonPowerline, self).init(
renderer_module=renderer_module)
def do_setup(self, ip, shutdown_hook):
global old_prompt_manager
old_prompt_manager = None
if old_prompt_manager is None:
old_prompt_manager = ip.prompt_manager
prompt_manager = PowerlinePromptManager(
powerline=self,
shell=ip.prompt_manager.shell,
)
ip.prompt_manager = prompt_manager
magics = PowerlineMagics(ip, self)
shutdown_hook.powerline = ref(self)
ip.register_magics(magics)
def load_ipython_extension(ip):
global old_prompt_manager
old_prompt_manager = ip.prompt_manager
powerline = ConfigurableIPythonPowerline(ip)
shutdown_hook = ShutdownHook()
powerline.setup(ip, shutdown_hook)
ip.hooks.shutdown_hook.add(shutdown_hook)
if has_prompt_manager:
shutdown_hook = ShutdownHook(ip)
powerline = ConfigurableIPythonPowerline(ip)
powerline.setup(ip, shutdown_hook)
else:
from powerline.bindings.ipython.since_7 import PowerlinePrompts
ip.prompts_class = PowerlinePrompts
ip.prompts = PowerlinePrompts(ip)
warn(DeprecationWarning(
'post_0_11 extension is deprecated since IPython 5, use\n'
' from powerline.bindings.ipython.since_7 import PowerlinePrompts\n'
' c.TerminalInteractiveShell.prompts_class = PowerlinePrompts\n'
'or check: \n'
'https://powerline.readthedocs.io/en/master/usage/other.html\n'
))
def unload_ipython_extension(ip):
ip.prompt_manager = old_prompt_manager
global old_prompt_manager
if old_prompt_manager is not None:
ip.prompt_manager = old_prompt_manager
old_prompt_manager = None

View File

@ -99,7 +99,7 @@ class ConfigurableIPythonPowerline(IPythonPowerline):
self.config_overrides = config_overrides
self.theme_overrides = theme_overrides
self.config_paths = config_paths
super(ConfigurableIPythonPowerline, self).init()
super(ConfigurableIPythonPowerline, self).init(renderer_module='.pre_5')
def ipython_magic(self, ip, parameter_s=''):
if parameter_s == 'reload':

View File

@ -0,0 +1,81 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from weakref import ref
from IPython.terminal.prompts import Prompts
from pygments.token import Token # NOQA
from powerline.ipython import IPythonPowerline
from powerline.renderers.ipython.since_5 import PowerlinePromptStyle
from powerline.bindings.ipython.post_0_11 import PowerlineMagics, ShutdownHook
class ConfigurableIPythonPowerline(IPythonPowerline):
def init(self, ip):
config = ip.config.Powerline
self.config_overrides = config.get('config_overrides')
self.theme_overrides = config.get('theme_overrides', {})
self.config_paths = config.get('config_paths')
super(ConfigurableIPythonPowerline, self).init(
renderer_module='.since_5')
def do_setup(self, ip, prompts, shutdown_hook):
prompts.powerline = self
msfn_missing = ()
saved_msfn = getattr(ip, '_make_style_from_name', msfn_missing)
if hasattr(saved_msfn, 'powerline_original'):
saved_msfn = saved_msfn.powerline_original
def _make_style_from_name(ip, name):
prev_style = saved_msfn(name)
new_style = PowerlinePromptStyle(lambda: prev_style)
return new_style
_make_style_from_name.powerline_original = saved_msfn
if not isinstance(ip._style, PowerlinePromptStyle):
prev_style = ip._style
ip._style = PowerlinePromptStyle(lambda: prev_style)
if not isinstance(saved_msfn, type(self.init)):
_saved_msfn = saved_msfn
saved_msfn = lambda: _saved_msfn(ip)
if saved_msfn is not msfn_missing:
ip._make_style_from_name = _make_style_from_name
magics = PowerlineMagics(ip, self)
ip.register_magics(magics)
if shutdown_hook:
shutdown_hook.powerline = ref(self)
class PowerlinePrompts(Prompts):
'''Class that returns powerline prompts
'''
def __init__(self, shell):
shutdown_hook = ShutdownHook(shell)
powerline = ConfigurableIPythonPowerline(shell)
self.shell = shell
powerline.do_setup(shell, self, shutdown_hook)
self.last_output_count = None
self.last_output = {}
for prompt in ('in', 'continuation', 'rewrite', 'out'):
exec((
'def {0}_prompt_tokens(self, *args, **kwargs):\n'
' if self.last_output_count != self.shell.execution_count:\n'
' self.last_output.clear()\n'
' self.last_output_count = self.shell.execution_count\n'
' if "{0}" not in self.last_output:\n'
' self.last_output["{0}"] = self.powerline.render('
' side="left",'
' matcher_info="{1}",'
' segment_info=self.shell,'
' ) + [(Token.Generic.Prompt, " ")]\n'
' return self.last_output["{0}"]'
).format(prompt, 'in2' if prompt == 'continuation' else prompt))

View File

@ -0,0 +1,78 @@
# vim:fileencoding=utf-8:noet
from weakref import ref
from atexit import register as atexit
from IPython.terminal.prompts import Prompts
from pygments.token import Token # NOQA
from powerline.ipython import IPythonPowerline
from powerline.renderers.ipython.since_7 import PowerlinePromptStyle
from powerline.bindings.ipython.post_0_11 import PowerlineMagics
class ConfigurableIPythonPowerline(IPythonPowerline):
def init(self, ip):
config = ip.config.Powerline
self.config_overrides = config.get('config_overrides')
self.theme_overrides = config.get('theme_overrides', {})
self.config_paths = config.get('config_paths')
super(ConfigurableIPythonPowerline, self).init(
renderer_module='.since_7')
def do_setup(self, ip, prompts):
prompts.powerline = self
msfn_missing = ()
saved_msfn = getattr(ip, '_make_style_from_name', msfn_missing)
if hasattr(saved_msfn, 'powerline_original'):
saved_msfn = saved_msfn.powerline_original
def _make_style_from_name(ip, name):
prev_style = saved_msfn(name)
new_style = PowerlinePromptStyle(lambda: prev_style)
return new_style
_make_style_from_name.powerline_original = saved_msfn
if not isinstance(ip._style, PowerlinePromptStyle):
prev_style = ip._style
ip._style = PowerlinePromptStyle(lambda: prev_style)
if not isinstance(saved_msfn, type(self.init)):
_saved_msfn = saved_msfn
saved_msfn = lambda: _saved_msfn(ip)
if saved_msfn is not msfn_missing:
ip._make_style_from_name = _make_style_from_name
magics = PowerlineMagics(ip, self)
ip.register_magics(magics)
atexit(self.shutdown)
class PowerlinePrompts(Prompts):
'''Class that returns powerline prompts
'''
def __init__(self, shell):
powerline = ConfigurableIPythonPowerline(shell)
self.shell = shell
powerline.do_setup(shell, self)
self.last_output_count = None
self.last_output = {}
for prompt in ('in', 'continuation', 'rewrite', 'out'):
exec((
'def {0}_prompt_tokens(self, *args, **kwargs):\n'
' if self.last_output_count != self.shell.execution_count:\n'
' self.last_output.clear()\n'
' self.last_output_count = self.shell.execution_count\n'
' if "{0}" not in self.last_output:\n'
' self.last_output["{0}"] = self.powerline.render('
' side="left",'
' matcher_info="{1}",'
' segment_info=self.shell,'
' ) + [(Token.Generic.Prompt, " ")]\n'
' return self.last_output["{0}"]'
).format(prompt, 'in2' if prompt == 'continuation' else prompt))

View File

@ -22,7 +22,7 @@ if __name__ == '__main__':
bars = []
for screen in get_connected_xrandr_outputs(powerline.pl):
command = [args.bar_command, '-g', '{0}x{1}+{2}'.format(screen['width'], args.height, screen['x'])] + args.args[1:]
command = [args.bar_command, '-g', '{0}x{1}+{2}+{3}'.format(screen['width'], args.height, screen['x'], screen['y'])] + args.args[1:]
process = subprocess.Popen(command, stdin=subprocess.PIPE)
bars.append((screen['name'], process, int(screen['width']) / 5))

View File

@ -36,6 +36,14 @@ fn _powerline_common_setup {
_POWERLINE_SAVED_PWD = ''
}
fn _powerline_tmux_pane {
if (test -n $TMUX_PANE) {
echo $TMUX_PANE | tr -d ' %'
} else {
TMUX=$_POWERLINE_TMUX tmux display -p '#D' | tr -d ' %'
}
}
fn _powerline_tmux_setenv {
}
@ -46,9 +54,9 @@ if (test -z $POWERLINE_CONFIG_COMMAND) {
echo powerline-config executable not found, unable to proceed >[2=1]
}
}
if (test x$POWERLINE_CONFIG_COMMAND '!=' x) {
if (test -n $POWERLINE_CONFIG_COMMAND) {
if ($POWERLINE_CONFIG_COMMAND shell --shell rcsh uses prompt) {
if (test x$POWERLINE_COMMAND_ARGS '!=' x) {
if (test -n $POWERLINE_COMMAND_ARGS) {
# Perform splitting
POWERLINE_COMMAND_ARGS=( `{echo $POWERLINE_COMMAND_ARGS} )
}
@ -67,13 +75,13 @@ if (test x$POWERLINE_CONFIG_COMMAND '!=' x) {
}
_powerline_common_setup
}
if (test x$TMUX '!=' x) {
if (test -n $TMUX) {
if ($POWERLINE_CONFIG_COMMAND shell --shell rcsh uses tmux) {
_POWERLINE_TMUX=$TMUX
fn _powerline_tmux_setenv {
if (test x$2 '!=' x) {
if (test -n $2) {
TMUX=$_POWERLINE_TMUX tmux setenv -g TMUX_$1^_`{
TMUX=$_POWERLINE_TMUX tmux display -p '#D' | tr -d %
_powerline_tmux_pane
} $2
}
}

View File

@ -1,6 +1,6 @@
_POWERLINE_SOURCED="$_"
_powerline_columns_fallback() {
if which stty >/dev/null ; then
if command -v stty >/dev/null ; then
# Ksh does not have “local” built-in
_powerline_cols="$(stty size 2>/dev/null)"
if ! test -z "$_powerline_cols" ; then
@ -104,13 +104,18 @@ _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
}
_powerline_tmux_set_pwd() {
if test "x$_POWERLINE_SAVED_PWD" != "x$PWD" ; then
if test "$_POWERLINE_SAVED_PWD" != "$PWD" ; then
_POWERLINE_SAVED_PWD="$PWD"
_powerline_tmux_setenv PWD "$PWD"
fi
@ -215,7 +220,7 @@ _powerline_init_tmux_support() {
}
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
if which powerline-config >/dev/null ; then
if command -v powerline-config >/dev/null ; then
POWERLINE_CONFIG_COMMAND=powerline-config
else
POWERLINE_CONFIG_COMMAND="$(dirname "$_POWERLINE_SOURCED")/../../../scripts/powerline-config"

View File

@ -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

View File

@ -76,7 +76,10 @@ def get_tmux_version(pl):
version_string = get_tmux_output(pl, '-V')
_, version_string = version_string.split(' ')
version_string = version_string.strip()
if version_string == 'master':
return TmuxVersionInfo(float('inf'), 0, version_string)
major, minor = version_string.split('.')
major = NON_DIGITS.subn('', major)[0]
suffix = DIGITS.subn('', minor)[0] or None
minor = NON_DIGITS.subn('', minor)[0]
return TmuxVersionInfo(int(major), int(minor), suffix)

View File

@ -1,11 +1,11 @@
set -g status on
set -g status-interval 2
set -g status-left-length 20
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id=\"`tmux display -p "#D"`\")'
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id=#{pane_id})'
set -g status-right-length 150
set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I#F #[$_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#F $_POWERLINE_LEFT_SOFT_DIVIDER#[$_POWERLINE_WINDOW_NAME_COLOR]#W #[$_POWERLINE_WINDOW_CURRENT_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER"
# Legacy status-left definition to be overwritten for tmux Versions 1.8+
set -g status-left "#[$_POWERLINE_SESSION_COLOR] #S #[$_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#(env \"\$POWERLINE_COMMAND\" tmux left -R pane_id=\"`tmux display -p '#D'`\")"
set -g status-left "#[$_POWERLINE_SESSION_COLOR] #S #[$_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#(env \"\$POWERLINE_COMMAND\" tmux left -R pane_id=#{pane_id})"
# vim: ft=tmux

View File

@ -1,3 +1,3 @@
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id="`tmux display -p "#D"`" --width=`tmux display -p "#{client_width}"` -R width_adjust=`tmux show-options -g status-left-length | cut -d" " -f 2`)'
set -g status-left "#[$_POWERLINE_SESSION_COLOR] #S #[$_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#(env \"\$POWERLINE_COMMAND\" tmux left --width=`tmux display -p '#{client_width}'` -R width_adjust=`tmux show-options -g status-right-length | cut -d' ' -f2` -R pane_id=\"`tmux display -p '#D'`\")"
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right -R pane_id=#{pane_id} --width=#{client_width} -R width_adjust=#{status-left-length})'
set -g status-left "#[$_POWERLINE_SESSION_COLOR] #S #[$_POWERLINE_SESSION_HARD_DIVIDER_NEXT_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER#(env \"\$POWERLINE_COMMAND\" tmux left --width=#{client_width} -R width_adjust=#{status-right-length} -R pane_id=#{pane_id})"
# vim: ft=tmux

View File

@ -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#(env \$POWERLINE_COMMAND \$POWERLINE_COMMAND_ARGS tmux left --width=`tmux display -p '#{client_width}'` -R width_adjust=`tmux show-options -g status-right-length | cut -d' ' -f2` -R pane_id=\"`tmux display -p '#D'`\")"
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 --width=#{client_width} -R width_adjust=#{status-right-length} -R pane_id=#{pane_id})"
# vim: ft=tmux

View File

@ -5,4 +5,5 @@ set-option -qg window-status-last-style "$_POWERLINE_ACTIVE_WINDOW_STATUS_COLOR"
set-window-option -qg window-status-style "$_POWERLINE_WINDOW_STATUS_COLOR"
set-window-option -qg window-status-activity-style "$_POWERLINE_ACTIVITY_STATUS_COLOR"
set-window-option -qg window-status-bell-style "$_POWERLINE_BELL_STATUS_COLOR"
set -g status-right '#(env "$POWERLINE_COMMAND" $POWERLINE_COMMAND_ARGS tmux right --width=#{client_width} -R width_adjust=#{status-left-length} -R pane_id=#{pane_id} -R pane_current_path=#{q:pane_current_path})'
# vim: ft=tmux

View File

@ -0,0 +1,3 @@
# Starting from tmux-2.1 escaping of dollar signs inside #() is harmful
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 --width=#{client_width} -R width_adjust=#{status-right-length} -R pane_id=#{pane_id} -R pane_current_path=#{q:pane_current_path})"
set -g window-status-format "#[$_POWERLINE_WINDOW_COLOR]$_POWERLINE_LEFT_HARD_DIVIDER_SPACES#I#{?window_flags,#F, } #[$_POWERLINE_WINDOW_DIVIDER_COLOR]$_POWERLINE_LEFT_SOFT_DIVIDER#[default]#W $_POWERLINE_LEFT_HARD_DIVIDER_SPACES"

View File

@ -26,14 +26,14 @@ if exists('g:powerline_pycmd')
let s:pyeval = g:powerline_pyeval
let s:has_python = 1
endif
elseif has('python')
let s:has_python = 1
let s:pycmd = 'py'
let s:pyeval = get(g:, 'powerline_pyeval', 'pyeval')
elseif has('python3')
let s:has_python = 1
let s:pycmd = 'py3'
let s:pyeval = get(g:, 'powerline_pyeval', 'py3eval')
elseif has('python')
let s:has_python = 1
let s:pycmd = 'py'
let s:pyeval = get(g:, 'powerline_pyeval', 'pyeval')
else
let s:has_python = 0
endif

View File

@ -5,22 +5,51 @@ import re
from powerline.theme import requires_segment_info
from powerline.lib.shell import run_cmd
from powerline.bindings.wm.awesome import AwesomeThread
DEFAULT_UPDATE_INTERVAL = 0.5
conn = None
def i3_subscribe(conn, event, callback):
'''Subscribe to i3 workspace event
:param conn:
Connection returned by :py:func:`get_i3_connection`.
:param str event:
Event to subscribe to, e.g. ``'workspace'``.
:param func callback:
Function to run on event.
'''
conn.on(event, callback)
from threading import Thread
class I3Thread(Thread):
daemon = True
def __init__(self, conn):
super(I3Thread, self).__init__()
self.__conn = conn
def run(self):
self.__conn.main()
thread = I3Thread(conn=conn)
thread.start()
def get_i3_connection():
'''Return a valid, cached i3 Connection instance
'''
global conn
if not conn:
try:
import i3ipc
except ImportError:
import i3 as conn
else:
conn = i3ipc.Connection()
import i3ipc
conn = i3ipc.Connection()
return conn
@ -36,3 +65,8 @@ def get_connected_xrandr_outputs(pl):
return (match.groupdict() for match in XRANDR_OUTPUT_RE.finditer(
run_cmd(pl, ['xrandr', '-q'])
))
wm_threads = {
'awesome': AwesomeThread,
}

View File

@ -0,0 +1,59 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import sys
from threading import Thread, Event
from time import sleep
from subprocess import Popen, PIPE
from powerline import Powerline
from powerline.lib.monotonic import monotonic
def read_to_log(pl, client):
for line in client.stdout:
if line:
pl.info(line, prefix='awesome-client')
for line in client.stderr:
if line:
pl.error(line, prefix='awesome-client')
if client.wait():
pl.error('Client exited with {0}', client.returncode, prefix='awesome')
def run(thread_shutdown_event=None, pl_shutdown_event=None, pl_config_loader=None,
interval=None):
powerline = Powerline(
'wm',
renderer_module='pango_markup',
shutdown_event=pl_shutdown_event,
config_loader=pl_config_loader,
)
powerline.update_renderer()
if not thread_shutdown_event:
thread_shutdown_event = powerline.shutdown_event
while not thread_shutdown_event.is_set():
# powerline.update_interval may change over time
used_interval = interval or powerline.update_interval
start_time = monotonic()
s = powerline.render(side='right')
request = 'powerline_widget:set_markup(\'' + s.translate({'\'': '\\\'', '\\': '\\\\'}) + '\')\n'
client = Popen(['awesome-client'], shell=False, stdout=PIPE, stderr=PIPE, stdin=PIPE)
client.stdin.write(request.encode('utf-8'))
client.stdin.close()
read_to_log(powerline.pl, client)
thread_shutdown_event.wait(max(used_interval - (monotonic() - start_time), 0.1))
class AwesomeThread(Thread):
__slots__ = ('powerline_shutdown_event',)
def __init__(self, **kwargs):
super(AwesomeThread, self).__init__()
self.powerline_run_kwargs = kwargs
def run(self):
run(**self.powerline_run_kwargs)

View File

@ -101,17 +101,14 @@ class Environment(object):
return False
if hasattr(getattr(zsh, 'environ', None), '__contains__'):
environ = zsh.environ
else:
environ = Environment()
environ = Environment()
if hasattr(zsh, 'expand') and zsh.expand('${:-}') == '':
zsh_expand = zsh.expand
else:
def zsh_expand(s):
zsh.eval('_POWERLINE_REPLY="' + s + '"')
zsh.eval('local _POWERLINE_REPLY="' + s + '"')
ret = zsh.getvalue('_POWERLINE_REPLY')
zsh.setvalue('_POWERLINE_REPLY', None)
return ret

View File

@ -1,4 +1,4 @@
_POWERLINE_SOURCED="$0:A"
local _POWERLINE_SOURCED="$0:A"
_powerline_columns_fallback() {
if which stty &>/dev/null ; then
@ -18,7 +18,17 @@ _powerline_append_precmd_function() {
fi
}
integer _POWERLINE_JOBNUM
integer -g _POWERLINE_JOBNUM=0
_powerline_tmux_pane() {
local -x TMUX="$_POWERLINE_TMUX"
echo "${TMUX_PANE:-`tmux display -p "#D"`}" | tr -d ' %'
}
_powerline_tmux_pane() {
local -x TMUX="$_POWERLINE_TMUX"
echo "${TMUX_PANE:-`tmux display -p "#D"`}" | tr -d ' %'
}
_powerline_init_tmux_support() {
emulate -L zsh
@ -29,7 +39,7 @@ _powerline_init_tmux_support() {
function -g _powerline_tmux_setenv() {
emulate -L zsh
local -x TMUX="$_POWERLINE_TMUX"
tmux setenv -g TMUX_"$1"_$(tmux display -p "#D" | tr -d %) "$2"
tmux setenv -g TMUX_"$1"_$(_powerline_tmux_pane) "$2"
tmux refresh -S
}
@ -53,11 +63,11 @@ _powerline_init_modes_support() {
test -z "$ZSH_VERSION" && return 0
typeset -ga VS
VS=( ${(s:.:)ZSH_VERSION} )
local -a vs
vs=( ${(s:.:)ZSH_VERSION} )
# Mode support requires >=zsh-4.3.11
if (( VS[1] < 4 || (VS[1] == 4 && (VS[2] < 3 || (VS[2] == 3 && VS[3] < 11))) )) ; then
if (( vs[1] < 4 || (vs[1] == 4 && (vs[2] < 3 || (vs[2] == 3 && vs[3] < 11))) )) ; then
return 0
fi
@ -66,7 +76,7 @@ _powerline_init_modes_support() {
}
function -g _powerline_set_true_keymap_name() {
_POWERLINE_MODE="${1}"
typeset -g _POWERLINE_MODE="${1}"
local plm_bk="$(bindkey -lL ${_POWERLINE_MODE})"
if [[ $plm_bk = 'bindkey -A'* ]] ; then
_powerline_set_true_keymap_name ${(Q)${${(z)plm_bk}[3]}}
@ -89,7 +99,7 @@ _powerline_init_modes_support() {
_powerline_set_main_keymap_name
if [[ "$_POWERLINE_MODE" != vi* ]] ; then
_POWERLINE_DEFAULT_MODE="$_POWERLINE_MODE"
typeset -g _POWERLINE_DEFAULT_MODE="$_POWERLINE_MODE"
fi
_powerline_append_precmd_function _powerline_set_main_keymap_name
@ -106,7 +116,7 @@ _powerline_set_jobnum() {
# ([ is in first column). You see: any line counting thingie will return
# wrong number of jobs. You need to filter the lines first. Or not use
# jobs built-in at all.
_POWERLINE_JOBNUM=${(%):-%j}
integer -g _POWERLINE_JOBNUM=${(%):-%j}
}
_powerline_update_counter() {
@ -118,7 +128,7 @@ _powerline_setup_prompt() {
_powerline_append_precmd_function _powerline_set_jobnum
VIRTUAL_ENV_DISABLE_PROMPT=1
typeset -g VIRTUAL_ENV_DISABLE_PROMPT=1
if test -z "${POWERLINE_NO_ZSH_ZPYTHON}" && { zmodload libzpython || zmodload zsh/zpython } &>/dev/null ; then
_powerline_append_precmd_function _powerline_update_counter
@ -137,7 +147,7 @@ _powerline_setup_prompt() {
}
else
if test -z "${POWERLINE_COMMAND}" ; then
POWERLINE_COMMAND="$($POWERLINE_CONFIG_COMMAND shell command)"
typeset -g POWERLINE_COMMAND="$($POWERLINE_CONFIG_COMMAND shell command)"
fi
local add_args='-r .zsh'
@ -154,11 +164,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" $=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')'
typeset -g PS1='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell aboveleft '$add_args')'
typeset -g RPS1='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell right '$add_args')'
typeset -g PS2='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell left '$add_args_2')'
typeset -g RPS2='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell right '$add_args_r2')'
typeset -g PS3='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell left '$add_args_3')'
fi
}
@ -182,15 +192,15 @@ _powerline_add_widget() {
eval "function $save_widget() { emulate -L zsh; $widget \$@ }"
eval "${old_widget_command/$widget/$save_widget}"
zle -N $widget $function
_POWERLINE_SAVE_WIDGET="$save_widget"
typeset -g _POWERLINE_SAVE_WIDGET="$save_widget"
fi
}
if test -z "${POWERLINE_CONFIG_COMMAND}" ; then
if which powerline-config >/dev/null ; then
POWERLINE_CONFIG_COMMAND=powerline-config
if which powerline-config >/dev/null 2>/dev/null ; then
typeset -g POWERLINE_CONFIG_COMMAND=powerline-config
else
POWERLINE_CONFIG_COMMAND="$_POWERLINE_SOURCED:h:h:h:h/scripts/powerline-config"
typeset -g POWERLINE_CONFIG_COMMAND="${_POWERLINE_SOURCED:h:h:h:h}/scripts/powerline-config"
fi
fi

View File

@ -47,7 +47,7 @@ def get_argparser(ArgumentParser=ConfigArgParser):
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. '
'then configuration files will only be sought in the provided path. '
'May be provided multiple times to search in a list of directories.'
)
subparsers = parser.add_subparsers()

View File

@ -11,6 +11,7 @@ from powerline.lib.overrides import parsedotval, parse_override_var
from powerline.lib.dict import mergeargs
from powerline.lib.encoding import get_preferred_arguments_encoding
from powerline.lib.unicode import u, unicode
from powerline.bindings.wm import wm_threads
if sys.version_info < (3,):
@ -23,7 +24,7 @@ else:
return s
def finish_args(environ, args):
def finish_args(parser, environ, args, is_daemon=False):
'''Do some final transformations
Transforms ``*_override`` arguments into dictionaries, adding overrides from
@ -61,7 +62,13 @@ def finish_args(environ, args):
[path for path in environ.get('POWERLINE_CONFIG_PATHS', '').split(':') if path]
+ (args.config_path or [])
)
args.side = args.side[0]
if args.ext[0].startswith('wm.'):
if not is_daemon:
parser.error('WM bindings must be used with daemon only')
elif args.ext[0][3:] not in wm_threads:
parser.error('WM binding not found')
elif not args.side:
parser.error('expected one argument')
return args
@ -77,15 +84,16 @@ def get_argparser(ArgumentParser=argparse.ArgumentParser):
parser.add_argument(
'ext', nargs=1,
help='Extension: application for which powerline command is launched '
'(usually `shell\' or `tmux\').'
'(usually `shell\' or `tmux\'). Also supports `wm.\' extensions: '
+ ', '.join(('`wm.' + key + '\'' for key in wm_threads.keys())) + '.'
)
parser.add_argument(
'side', nargs=1, choices=('left', 'right', 'above', 'aboveleft'),
'side', nargs='?', choices=('left', 'right', 'above', 'aboveleft'),
help='Side: `left\' and `right\' represent left and right side '
'respectively, `above\' emits lines that are supposed to be printed '
'just above the prompt and `aboveleft\' is like concatenating '
'`above\' with `left\' with the exception that only one Python '
'instance is used in this case.'
'instance is used in this case. May be omitted for `wm.*\' extensions.'
)
parser.add_argument(
'-r', '--renderer-module', metavar='MODULE', type=str,
@ -138,13 +146,13 @@ def get_argparser(ArgumentParser=argparse.ArgumentParser):
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\' '
'`--renderer-arg\' for historical reasons: `--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. '
'configuration files will only be sought in the provided path. '
'May be provided multiple times to search in a list of directories.'
)
parser.add_argument(

View File

@ -1,52 +1,57 @@
{
"name": "Default",
"groups": {
"information:additional": { "fg": "gray9", "bg": "gray4", "attrs": [] },
"information:regular": { "fg": "gray10", "bg": "gray4", "attrs": ["bold"] },
"information:highlighted": { "fg": "white", "bg": "gray4", "attrs": [] },
"information:priority": { "fg": "brightyellow", "bg": "mediumorange", "attrs": [] },
"warning:regular": { "fg": "white", "bg": "brightred", "attrs": ["bold"] },
"critical:failure": { "fg": "white", "bg": "darkestred", "attrs": [] },
"critical:success": { "fg": "white", "bg": "darkestgreen", "attrs": [] },
"background": { "fg": "white", "bg": "gray0", "attrs": [] },
"background:divider": { "fg": "gray5", "bg": "gray0", "attrs": [] },
"session": { "fg": "black", "bg": "gray10", "attrs": ["bold"] },
"date": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"time": { "fg": "gray10", "bg": "gray2", "attrs": ["bold"] },
"time:divider": { "fg": "gray5", "bg": "gray2", "attrs": [] },
"email_alert": "warning:regular",
"email_alert_gradient": { "fg": "white", "bg": "yellow_orange_red", "attrs": ["bold"] },
"hostname": { "fg": "black", "bg": "gray10", "attrs": ["bold"] },
"weather": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"weather_temp_gradient": { "fg": "blue_red", "bg": "gray0", "attrs": [] },
"weather_condition_hot": { "fg": "khaki1", "bg": "gray0", "attrs": [] },
"weather_condition_snowy": { "fg": "skyblue1", "bg": "gray0", "attrs": [] },
"weather_condition_rainy": { "fg": "skyblue1", "bg": "gray0", "attrs": [] },
"uptime": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"external_ip": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"internal_ip": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"network_load": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"network_load_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
"network_load:divider": "background:divider",
"system_load": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"system_load_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
"environment": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"cpu_load_percent": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"cpu_load_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
"battery": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"battery_gradient": { "fg": "white_red", "bg": "gray0", "attrs": [] },
"battery_full": { "fg": "red", "bg": "gray0", "attrs": [] },
"battery_empty": { "fg": "white", "bg": "gray0", "attrs": [] },
"player": { "fg": "gray10", "bg": "black", "attrs": [] },
"user": { "fg": "white", "bg": "darkblue", "attrs": ["bold"] },
"branch": { "fg": "gray9", "bg": "gray2", "attrs": [] },
"branch_dirty": { "fg": "brightyellow", "bg": "gray2", "attrs": [] },
"branch_clean": { "fg": "gray9", "bg": "gray2", "attrs": [] },
"branch:divider": { "fg": "gray7", "bg": "gray2", "attrs": [] },
"cwd": "information:additional",
"cwd:current_folder": "information:regular",
"cwd:divider": { "fg": "gray7", "bg": "gray4", "attrs": [] },
"virtualenv": { "fg": "white", "bg": "darkcyan", "attrs": [] },
"attached_clients": { "fg": "gray8", "bg": "gray0", "attrs": [] }
"information:additional": { "fg": "gray9", "bg": "gray4", "attrs": [] },
"information:regular": { "fg": "gray10", "bg": "gray4", "attrs": ["bold"] },
"information:highlighted": { "fg": "white", "bg": "gray4", "attrs": [] },
"information:priority": { "fg": "brightyellow", "bg": "mediumorange", "attrs": [] },
"warning:regular": { "fg": "white", "bg": "brightred", "attrs": ["bold"] },
"critical:failure": { "fg": "white", "bg": "darkestred", "attrs": [] },
"critical:success": { "fg": "white", "bg": "darkestgreen", "attrs": [] },
"background": { "fg": "white", "bg": "gray0", "attrs": [] },
"background:divider": { "fg": "gray5", "bg": "gray0", "attrs": [] },
"session": { "fg": "black", "bg": "gray10", "attrs": ["bold"] },
"date": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"time": { "fg": "gray10", "bg": "gray2", "attrs": ["bold"] },
"time:divider": { "fg": "gray5", "bg": "gray2", "attrs": [] },
"email_alert": "warning:regular",
"email_alert_gradient": { "fg": "white", "bg": "yellow_orange_red", "attrs": ["bold"] },
"hostname": { "fg": "black", "bg": "gray10", "attrs": ["bold"] },
"weather": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"weather_temp_gradient": { "fg": "blue_red", "bg": "gray0", "attrs": [] },
"weather_condition_hot": { "fg": "khaki1", "bg": "gray0", "attrs": [] },
"weather_condition_snowy": { "fg": "skyblue1", "bg": "gray0", "attrs": [] },
"weather_condition_rainy": { "fg": "skyblue1", "bg": "gray0", "attrs": [] },
"uptime": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"external_ip": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"internal_ip": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"network_load": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"network_load_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
"network_load_sent_gradient": "network_load_gradient",
"network_load_recv_gradient": "network_load_gradient",
"network_load:divider": "background:divider",
"system_load": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"system_load_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
"environment": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"cpu_load_percent": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"cpu_load_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
"battery": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"battery_gradient": { "fg": "white_red", "bg": "gray0", "attrs": [] },
"battery_full": { "fg": "red", "bg": "gray0", "attrs": [] },
"battery_empty": { "fg": "white", "bg": "gray0", "attrs": [] },
"player": { "fg": "gray10", "bg": "black", "attrs": [] },
"user": { "fg": "white", "bg": "darkblue", "attrs": ["bold"] },
"branch": { "fg": "gray9", "bg": "gray2", "attrs": [] },
"branch_dirty": { "fg": "brightyellow", "bg": "gray2", "attrs": [] },
"branch_clean": { "fg": "gray9", "bg": "gray2", "attrs": [] },
"branch:divider": { "fg": "gray7", "bg": "gray2", "attrs": [] },
"stash": "branch_dirty",
"stash:divider": "branch:divider",
"cwd": "information:additional",
"cwd:current_folder": "information:regular",
"cwd:divider": { "fg": "gray7", "bg": "gray4", "attrs": [] },
"virtualenv": { "fg": "white", "bg": "darkcyan", "attrs": [] },
"attached_clients": { "fg": "gray8", "bg": "gray0", "attrs": [] },
"workspace": "information:regular"
}
}

View File

@ -1,36 +1,40 @@
{
"name": "Solarized dark",
"groups": {
"information:additional": { "fg": "solarized:base2", "bg": "solarized:base01", "attrs": [] },
"information:regular": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": ["bold"] },
"information:highlighted": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": ["bold"]},
"information:priority": { "fg": "solarized:base3", "bg": "solarized:yellow", "attrs": [] },
"warning:regular": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": [] },
"critical:failure": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": [] },
"critical:success": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
"background": { "fg": "solarized:base3", "bg": "solarized:base02", "attrs": [] },
"background:divider": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
"user": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] },
"virtualenv": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
"branch": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
"branch_dirty": { "fg": "solarized:yellow", "bg": "solarized:base02", "attrs": [] },
"branch_clean": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
"email_alert_gradient": { "fg": "solarized:base3", "bg": "yellow_orange_red", "attrs": [] },
"email_alert": "warning:regular",
"cwd": "information:additional",
"cwd:current_folder": "information:regular",
"cwd:divider": { "fg": "solarized:base1", "bg": "solarized:base01", "attrs": [] },
"network_load": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] },
"network_load:divider": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] },
"hostname": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": [] },
"environment": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
"attached_clients": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
"date": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
"time": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": ["bold"] },
"time:divider": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
"system_load": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] },
"weather_temp_gradient": { "fg": "blue_red", "bg": "solarized:base03", "attrs": [] },
"weather": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] },
"uptime": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] }
"information:additional": { "fg": "solarized:base2", "bg": "solarized:base01", "attrs": [] },
"information:regular": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": ["bold"] },
"information:highlighted": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": ["bold"]},
"information:priority": { "fg": "solarized:base3", "bg": "solarized:yellow", "attrs": [] },
"warning:regular": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": [] },
"critical:failure": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": [] },
"critical:success": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
"background": { "fg": "solarized:base3", "bg": "solarized:base02", "attrs": [] },
"background:divider": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] },
"user": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] },
"virtualenv": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
"branch": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
"branch_dirty": { "fg": "solarized:yellow", "bg": "solarized:base02", "attrs": [] },
"branch_clean": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
"stash": "branch_dirty",
"email_alert_gradient": { "fg": "solarized:base3", "bg": "yellow_orange_red", "attrs": [] },
"email_alert": "warning:regular",
"cwd": "information:additional",
"cwd:current_folder": "information:regular",
"cwd:divider": { "fg": "solarized:base1", "bg": "solarized:base01", "attrs": [] },
"network_load": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] },
"network_load:divider": "network_load",
"network_load_gradient": { "fg": "green_yellow_orange_red", "bg": "solarized:base03", "attrs": [] },
"network_load_sent_gradient": "network_load_gradient",
"network_load_recv_gradient": "network_load_gradient",
"hostname": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": [] },
"environment": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
"attached_clients": { "fg": "solarized:base3", "bg": "solarized:green", "attrs": [] },
"date": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
"time": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": ["bold"] },
"time:divider": { "fg": "solarized:base1", "bg": "solarized:base02", "attrs": [] },
"system_load": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] },
"weather_temp_gradient": { "fg": "blue_red", "bg": "solarized:base03", "attrs": [] },
"weather": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] },
"uptime": { "fg": "solarized:base1", "bg": "solarized:base03", "attrs": [] }
}
}

View File

@ -5,6 +5,7 @@
"file_size": "information:unimportant",
"file_format": "information:unimportant",
"file_encoding": "file_format",
"file_bom": "file_format",
"file_type": "file_format",
"branch": "information:additional",
"file_scheme": "file_name",

View File

@ -76,6 +76,50 @@
"branch:divider": { "fg": "darkcyan", "bg": "darkblue", "attrs": [] }
}
},
"ic": {
"colors": {
"gray0": "darkestblue",
"gray1": "darkestblue",
"gray2": "darkestblue",
"gray3": "darkblue",
"gray4": "darkblue",
"gray5": "darkestcyan",
"gray6": "darkestcyan",
"gray7": "darkestcyan",
"gray8": "mediumcyan",
"gray9": "mediumcyan",
"gray10": "mediumcyan",
"green_yellow_red": "gray5",
"dark_green_gray": "light_green_gray"
},
"groups": {
"mode": { "fg": "darkestcyan", "bg": "white", "attrs": ["bold"] },
"background:divider": { "fg": "darkcyan", "bg": "darkestblue", "attrs": [] },
"branch:divider": { "fg": "darkcyan", "bg": "darkblue", "attrs": [] }
}
},
"ix": {
"colors": {
"gray0": "darkestblue",
"gray1": "darkestblue",
"gray2": "darkestblue",
"gray3": "darkblue",
"gray4": "darkblue",
"gray5": "darkestcyan",
"gray6": "darkestcyan",
"gray7": "darkestcyan",
"gray8": "mediumcyan",
"gray9": "mediumcyan",
"gray10": "mediumcyan",
"green_yellow_red": "gray5",
"dark_green_gray": "light_green_gray"
},
"groups": {
"mode": { "fg": "darkestcyan", "bg": "white", "attrs": ["bold"] },
"background:divider": { "fg": "darkcyan", "bg": "darkestblue", "attrs": [] },
"branch:divider": { "fg": "darkcyan", "bg": "darkblue", "attrs": [] }
}
},
"v": {
"groups": {
"mode": { "fg": "darkorange", "bg": "brightestorange", "attrs": ["bold"] }
@ -95,6 +139,16 @@
"groups": {
"mode": { "fg": "white", "bg": "brightred", "attrs": ["bold"] }
}
},
"Rc": {
"groups": {
"mode": { "fg": "white", "bg": "brightred", "attrs": ["bold"] }
}
},
"Rx": {
"groups": {
"mode": { "fg": "white", "bg": "brightred", "attrs": ["bold"] }
}
}
}
}

View File

@ -12,6 +12,7 @@
"readonly_indicator": { "fg": "solarized:red", "bg": "solarized:base01", "attrs": [] },
"branch_dirty": { "fg": "solarized:yellow", "bg": "solarized:base01", "attrs": [] },
"branch:divider": { "fg": "solarized:base1", "bg": "solarized:base01", "attrs": [] },
"stash:divider": "branch:divider",
"file_name": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": ["bold"] },
"window_title": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": [] },
"file_name_no_file": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": ["bold"] },
@ -72,6 +73,20 @@
"col_current": { "fg": "solarized:base0", "bg": "solarized:base3", "attrs": [] }
}
},
"ic": {
"groups": {
"background": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": [] },
"background:divider": { "fg": "solarized:base2", "bg": "solarized:base01", "attrs": [] },
"mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] }
}
},
"ix": {
"groups": {
"background": { "fg": "solarized:base3", "bg": "solarized:base01", "attrs": [] },
"background:divider": { "fg": "solarized:base2", "bg": "solarized:base01", "attrs": [] },
"mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] }
}
},
"v": {
"groups": {
"mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] }
@ -91,6 +106,16 @@
"groups": {
"mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] }
}
},
"Rc": {
"groups": {
"mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] }
}
},
"Rx": {
"groups": {
"mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] }
}
}
}
}

View File

@ -12,6 +12,8 @@
"readonly_indicator": { "fg": "solarized:red", "bg": "solarized:base2", "attrs": [] },
"branch_dirty": { "fg": "solarized:yellow", "bg": "solarized:base2", "attrs": [] },
"branch:divider": { "fg": "solarized:base1", "bg": "solarized:base2", "attrs": [] },
"stash": "branch_dirty",
"stash:divider": "branch:divider",
"file_name": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": ["bold"] },
"window_title": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": [] },
"file_size": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": [] },
@ -72,6 +74,20 @@
"col_current": { "fg": "solarized:base00", "bg": "solarized:base03", "attrs": [] }
}
},
"ic": {
"groups": {
"background": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": [] },
"background:divider": { "fg": "solarized:base02", "bg": "solarized:base2", "attrs": [] },
"mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] }
}
},
"ix": {
"groups": {
"background": { "fg": "solarized:base03", "bg": "solarized:base2", "attrs": [] },
"background:divider": { "fg": "solarized:base02", "bg": "solarized:base2", "attrs": [] },
"mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attrs": ["bold"] }
}
},
"v": {
"groups": {
"mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attrs": ["bold"] }
@ -91,6 +107,16 @@
"groups": {
"mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] }
}
},
"Rc": {
"groups": {
"mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] }
}
},
"Rx": {
"groups": {
"mode": { "fg": "solarized:base3", "bg": "solarized:red", "attrs": ["bold"] }
}
}
}
}

View File

@ -46,7 +46,8 @@
},
"wm": {
"colorscheme": "default",
"theme": "default"
"theme": "default",
"update_interval": 2
}
}
}

View File

@ -15,6 +15,9 @@
"branch": {
"before": "BR "
},
"stash": {
"before": "ST "
},
"cwd": {
"args": {
"ellipsis": "..."
@ -102,15 +105,20 @@
"S": "S-LINE",
"^S": "S-BLCK",
"i": "INSERT",
"ic": "I-COMP",
"ix": "I-C_X ",
"R": "RPLACE",
"Rv": "V-RPLC",
"Rc": "R-COMP",
"Rx": "R-C_X ",
"c": "COMMND",
"cv": "VIM-EX",
"ce": "NRM-EX",
"r": "PROMPT",
"rm": "-MORE-",
"r?": "CNFIRM",
"!": "!SHELL"
"!": "!SHELL",
"t": "TERM "
}
}
},

View File

@ -14,6 +14,9 @@
"branch": {
"before": " "
},
"stash": {
"before": "⌆ "
},
"cwd": {
"args": {
"ellipsis": "⋯"
@ -100,24 +103,29 @@
"S": "S·LINE",
"^S": "S·BLCK",
"i": "INSERT",
"ic": "I·COMP",
"ix": "I·C-X ",
"R": "RPLACE",
"Rv": "V·RPLC",
"Rc": "R·COMP",
"Rx": "R·C-X ",
"c": "COMMND",
"cv": "VIM·EX",
"ce": "NRM·EX",
"r": "PROMPT",
"rm": "-MORE-",
"r?": "CNFIRM",
"!": "!SHELL"
"!": "!SHELL",
"t": "TERM "
}
}
},
"powerline.segments.vim.visual_range": {
"args": {
"CTRL_V_text": "{rows} × {vcols}",
"v_text_oneline": "C:{vcols}",
"v_text_multiline": "L:{rows}",
"V_text": "L:{rows}"
"CTRL_V_text": "↕{rows} ↔{vcols}",
"v_text_oneline": "{vcols}",
"v_text_multiline": "{rows}",
"V_text": "{rows}"
}
},
"powerline.segments.vim.readonly_indicator": {

View File

@ -0,0 +1,151 @@
{
"dividers": {
"left": {
"hard": " ",
"soft": " "
},
"right": {
"hard": " ",
"soft": " "
}
},
"spaces": 1,
"segment_data": {
"branch": {
"before": " "
},
"stash": {
"before": "ST "
},
"cwd": {
"args": {
"ellipsis": "…"
}
},
"line_current_symbol": {
"contents": " "
},
"player": {
"args": {
"state_symbols": {
"fallback": "♫",
"play": "▶",
"pause": "▮▮",
"stop": "■"
}
}
},
"time": {
"before": ""
},
"powerline.segments.common.net.network_load": {
"args": {
"recv_format": "⇓ {value:>8}",
"sent_format": "⇑ {value:>8}"
}
},
"powerline.segments.common.net.hostname": {
"before": " "
},
"powerline.segments.common.bat.battery": {
"args": {
"full_heart": "♥",
"empty_heart": "♥",
"online": "⚡︎",
"offline": " "
}
},
"powerline.segments.common.sys.uptime": {
"before": "↑ "
},
"powerline.segments.common.mail.email_imap_alert": {
"before": "MAIL "
},
"powerline.segments.common.env.virtualenv": {
"before": "(e) "
},
"powerline.segments.common.wthr.weather": {
"args": {
"icons": {
"day": "DAY",
"blustery": "WIND",
"rainy": "RAIN",
"cloudy": "CLOUDS",
"snowy": "SNOW",
"stormy": "STORM",
"foggy": "FOG",
"sunny": "SUN",
"night": "NIGHT",
"windy": "WINDY",
"not_available": "NA",
"unknown": "UKN"
}
}
},
"powerline.segments.common.time.fuzzy_time": {
"args": {
"unicode_text": true
}
},
"powerline.segments.vim.mode": {
"args": {
"override": {
"n": "NORMAL",
"no": "N·OPER",
"v": "VISUAL",
"V": "V·LINE",
"^V": "V·BLCK",
"s": "SELECT",
"S": "S·LINE",
"^S": "S·BLCK",
"i": "INSERT",
"ic": "I·COMP",
"ix": "I·C-X ",
"R": "RPLACE",
"Rv": "V·RPLC",
"Rc": "R·COMP",
"Rx": "R·C-X ",
"c": "COMMND",
"cv": "VIM·EX",
"ce": "NRM·EX",
"r": "PROMPT",
"rm": "-MORE-",
"r?": "CNFIRM",
"!": "!SHELL",
"t": "TERM "
}
}
},
"powerline.segments.vim.visual_range": {
"args": {
"CTRL_V_text": "↕{rows} ↔{vcols}",
"v_text_oneline": "↔{vcols}",
"v_text_multiline": "↕{rows}",
"V_text": "⇕{rows}"
}
},
"powerline.segments.vim.readonly_indicator": {
"args": {
"text": ""
}
},
"powerline.segments.vim.modified_indicator": {
"args": {
"text": "+"
}
},
"powerline.segments.i3wm.scratchpad": {
"args": {
"icons": {
"fresh": "●",
"changed": "○"
}
}
}
}
}

View File

@ -14,6 +14,9 @@
"branch": {
"before": "🔀 "
},
"stash": {
"before": "📝"
},
"cwd": {
"args": {
"ellipsis": "⋯"
@ -114,24 +117,29 @@
"S": "S·LINE",
"^S": "S·BLCK",
"i": "INSERT",
"ic": "I·COMP",
"ix": "I·C-X ",
"R": "RPLACE",
"Rv": "V·RPLC",
"Rc": "R·COMP",
"Rx": "R·C-X ",
"c": "COMMND",
"cv": "VIM·EX",
"ce": "NRM·EX",
"r": "PROMPT",
"rm": "-MORE-",
"r?": "CNFIRM",
"!": "!SHELL"
"!": "!SHELL",
"t": "TERM "
}
}
},
"powerline.segments.vim.visual_range": {
"args": {
"CTRL_V_text": "{rows} × {vcols}",
"v_text_oneline": "C:{vcols}",
"v_text_multiline": "L:{rows}",
"V_text": "L:{rows}"
"CTRL_V_text": "↕{rows} ↔{vcols}",
"v_text_oneline": "{vcols}",
"v_text_multiline": "{rows}",
"V_text": "{rows}"
}
},
"powerline.segments.vim.readonly_indicator": {

View File

@ -30,6 +30,10 @@
"function": "powerline.segments.shell.last_pipe_status",
"priority": 10
},
{
"function": "powerline.segments.common.vcs.stash",
"priority": 50
},
{
"function": "powerline.segments.common.vcs.branch",
"priority": 40

View File

@ -26,7 +26,7 @@
"priority": 20
},
{
"function": "powerline.segments.shell.last_status",
"function": "powerline.segments.shell.last_pipe_status",
"priority": 10
}
]

View File

@ -14,6 +14,9 @@
"branch": {
"before": "⎇ "
},
"stash": {
"before": "⌆"
},
"cwd": {
"args": {
"ellipsis": "⋯"
@ -100,24 +103,29 @@
"S": "S·LINE",
"^S": "S·BLCK",
"i": "INSERT",
"ic": "I·COMP",
"ix": "I·C-X ",
"R": "RPLACE",
"Rv": "V·RPLC",
"Rc": "R·COMP",
"Rx": "R·C-X ",
"c": "COMMND",
"cv": "VIM·EX",
"ce": "NRM·EX",
"r": "PROMPT",
"rm": "-MORE-",
"r?": "CNFIRM",
"!": "!SHELL"
"!": "!SHELL",
"t": "TERM "
}
}
},
"powerline.segments.vim.visual_range": {
"args": {
"CTRL_V_text": "{rows} × {vcols}",
"v_text_oneline": "C:{vcols}",
"v_text_multiline": "L:{rows}",
"V_text": "L:{rows}"
"CTRL_V_text": "↕{rows} ↔{vcols}",
"v_text_oneline": "{vcols}",
"v_text_multiline": "{rows}",
"V_text": "{rows}"
}
},
"powerline.segments.vim.readonly_indicator": {

View File

@ -14,6 +14,9 @@
"branch": {
"before": "BR "
},
"stash": {
"before": "ST "
},
"cwd": {
"args": {
"ellipsis": "…"
@ -100,15 +103,20 @@
"S": "S·LINE",
"^S": "S·BLCK",
"i": "INSERT",
"ic": "I·COMP",
"ix": "I·C-X ",
"R": "RPLACE",
"Rv": "V·RPLC",
"Rc": "R·COMP",
"Rx": "R·C-X ",
"c": "COMMND",
"cv": "VIM·EX",
"ce": "NRM·EX",
"r": "PROMPT",
"rm": "-MORE-",
"r?": "CNFIRM",
"!": "!SHELL"
"!": "!SHELL",
"t": "TERM "
}
}
},

View File

@ -14,6 +14,9 @@
"branch": {
"before": "B "
},
"stash": {
"before": "S "
},
"cwd": {
"args": {
"use_path_separator": true,
@ -101,8 +104,12 @@
"S": "SLN",
"^S": "SBL",
"i": "INS",
"ic": "I-C",
"ix": "I^X",
"R": "REP",
"Rv": "VRP",
"Rc": "R-C",
"Rx": "R^X",
"c": "CMD",
"cv": "VEX",
"ce": " EX",
@ -116,9 +123,9 @@
"powerline.segments.vim.visual_range": {
"args": {
"CTRL_V_text": "{rows}×{vcols}",
"v_text_oneline": "C:{vcols}",
"v_text_multiline": "L:{rows}",
"V_text": "L:{rows}"
"v_text_oneline": "{vcols}",
"v_text_multiline": "{rows}",
"V_text": "{rows}"
}
},
"powerline.segments.vim.readonly_indicator": {

View File

@ -1,10 +1,6 @@
{
"segments": {
"right": [
{
"function": "powerline.segments.common.wthr.weather",
"priority": 50
},
{
"function": "powerline.segments.common.time.date"
},
@ -15,14 +11,6 @@
"format": "%H:%M",
"istime": true
}
},
{
"function": "powerline.segments.common.mail.email_imap_alert",
"priority": 10,
"args": {
"username": "",
"password": ""
}
}
]
}

View File

@ -6,6 +6,15 @@ from powerline.lib.dict import mergedicts
from powerline.lib.unicode import string
class IPythonInfo(object):
def __init__(self, shell):
self._shell = shell
@property
def prompt_count(self):
return self._shell.execution_count
# HACK: ipython tries to only leave us with plain ASCII
class RewriteResult(object):
def __init__(self, prompt):

View File

@ -46,12 +46,12 @@ def get_preferred_output_encoding():
if hasattr(locale, 'LC_MESSAGES'):
return (
locale.getlocale(locale.LC_MESSAGES)[1]
or locale.getdefaultlocale()[1]
or locale.getlocale()[1]
or 'ascii'
)
return (
locale.getdefaultlocale()[1]
locale.getlocale()[1]
or 'ascii'
)
@ -66,12 +66,12 @@ def get_preferred_input_encoding():
if hasattr(locale, 'LC_MESSAGES'):
return (
locale.getlocale(locale.LC_MESSAGES)[1]
or locale.getdefaultlocale()[1]
or locale.getlocale()[1]
or 'latin1'
)
return (
locale.getdefaultlocale()[1]
locale.getlocale()[1]
or 'latin1'
)
@ -86,7 +86,7 @@ def get_preferred_arguments_encoding():
a problem.
'''
return (
locale.getdefaultlocale()[1]
locale.getlocale()[1]
or 'latin1'
)

View File

@ -158,17 +158,16 @@ class ThreadedSegment(Segment, MultiRunnedThread):
def additional_args(self):
return (('interval', self.interval),)
_omitted_args = {
'render': (0,),
'set_state': ('shutdown_event',),
}
def omitted_args(self, name, method):
ret = self._omitted_args.get(name, ())
if isinstance(getattr(self, name, None), MethodType):
omitted_indexes = (0,)
else:
omitted_indexes = ()
if name.startswith('render'):
if omitted_indexes:
omitted_indexes += (1,)
else:
omitted_indexes = (0,)
return omitted_indexes
ret = tuple((i + 1 if isinstance(i, int) else i for i in ret))
return ret
class KwThreadedSegment(ThreadedSegment):
@ -255,3 +254,9 @@ class KwThreadedSegment(ThreadedSegment):
@staticmethod
def render_one(update_state, **kwargs):
return update_state
_omitted_args = {
'render': ('update_value', 'key', 'after_update'),
'set_state': ('shutdown_event',),
'render_one': (0,),
}

View File

@ -227,7 +227,7 @@ _strwidth_documentation = (
character sets because they have explicit fullwidth or wide
counterparts. All of ASCII is an example of East Asian
Narrow characters.
A 1 or 2 Ambigious: characters that may sometimes be wide and
A 1 or 2 Ambiguous: characters that may sometimes be wide and
sometimes narrow. Ambiguous characters require additional
information not contained in the character code to further
resolve their width. This information is usually defined in

View File

@ -154,7 +154,7 @@ def get_file_status(directory, dirstate_file, file_path, ignore_file_name, get_f
except OSError as e:
if getattr(e, 'errno', None) != errno.ENOENT:
raise
# Do not call get_func again for a non-existant file
# Do not call get_func again for a non-existent file
if keypath not in file_status_cache:
file_status_cache[keypath] = get_func(directory, file_path)
return file_status_cache[keypath]

View File

@ -102,6 +102,13 @@ try:
def ignore_event(path, name):
return False
def stash(self):
try:
stashref = git.Repository(git_directory(self.directory)).lookup_reference('refs/stash')
except KeyError:
return 0
return sum(1 for _ in stashref.log())
def do_status(self, directory, path):
if path:
try:
@ -164,24 +171,27 @@ except ImportError:
@staticmethod
def ignore_event(path, name):
# Ignore changes to the index.lock file, since they happen
# frequently and dont indicate an actual change in the working tree
# frequently and don't indicate an actual change in the working tree
# status
return path.endswith('.git') and name == 'index.lock'
def _gitcmd(self, directory, *args):
return readlines(('git',) + args, directory)
def stash(self):
return sum(1 for _ in self._gitcmd(self.directory, '--no-optional-locks', 'stash', 'list'))
def do_status(self, directory, path):
if path:
try:
return next(self._gitcmd(directory, 'status', '--porcelain', '--ignored', '--', path))[:2]
return next(self._gitcmd(directory, '--no-optional-locks', 'status', '--porcelain', '--ignored', '--', path))[:2]
except StopIteration:
return None
else:
wt_column = ' '
index_column = ' '
untracked_column = ' '
for line in self._gitcmd(directory, 'status', '--porcelain'):
for line in self._gitcmd(directory, '--no-optional-locks', 'status', '--porcelain'):
if line[0] == '?':
untracked_column = 'U'
continue

View File

@ -3,7 +3,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
import os
from mercurial import hg, ui, match
import hglib
from powerline.lib.vcs import get_branch_name, get_file_status
from powerline.lib.path import join
@ -20,21 +20,23 @@ def branch_name_from_config_file(directory, config_file):
class Repository(object):
__slots__ = ('directory', 'ui', 'create_watcher')
__slots__ = ('directory', 'create_watcher')
statuses = 'MARDUI'
repo_statuses = (1, 1, 1, 1, 2)
# hg status -> (powerline file status, repo status flag)
statuses = {
b'M': ('M', 1), b'A': ('A', 1), b'R': ('R', 1), b'!': ('D', 1),
b'?': ('U', 2), b'I': ('I', 0), b'C': ('', 0),
}
repo_statuses_str = (None, 'D ', ' U', 'DU')
def __init__(self, directory, create_watcher):
self.directory = os.path.abspath(directory)
self.ui = ui.ui()
self.create_watcher = create_watcher
def _repo(self, directory):
# Cannot create this object once and use always: when repository updates
# functions emit invalid results
return hg.repository(self.ui, directory)
return hglib.open(directory)
def status(self, path=None):
'''Return status of repository or file.
@ -61,20 +63,20 @@ class Repository(object):
return self.do_status(self.directory, path)
def do_status(self, directory, path):
repo = self._repo(directory)
if path:
m = match.match(None, None, [path], exact=True)
statuses = repo.status(match=m, unknown=True, ignored=True)
for status, paths in zip(self.statuses, statuses):
if paths:
return status
return None
else:
resulting_status = 0
for status, paths in zip(self.repo_statuses, repo.status(unknown=True)):
if paths:
resulting_status |= status
return self.repo_statuses_str[resulting_status]
with self._repo(directory) as repo:
if path:
path = os.path.join(directory, path)
statuses = repo.status(include=path, all=True)
for status, paths in statuses:
if paths:
return self.statuses[status][0]
return None
else:
resulting_status = 0
for status, paths in repo.status(all=True):
if paths:
resulting_status |= self.statuses[status][1]
return self.repo_statuses_str[resulting_status]
def branch(self):
config_file = join(self.directory, '.hg', 'branch')

View File

@ -29,7 +29,7 @@ class INotifyFileWatcher(INotify):
def process_event(self, wd, mask, cookie, name):
if wd == -1 and (mask & self.Q_OVERFLOW):
# We missed some INOTIFY events, so we dont
# We missed some INOTIFY events, so we don't
# know the state of any tracked files.
for path in tuple(self.modified):
if os.path.exists(path):
@ -114,7 +114,7 @@ class INotifyFileWatcher(INotify):
self.expire_watches()
if path not in self.watches:
# Try to re-add the watch, it will fail if the file does not
# exist/you dont have permission
# exist/you don't have permission
self.watch(path)
return True
self.read(get_name=False)
@ -187,7 +187,7 @@ class INotifyTreeWatcher(INotify):
raise NoSuchDir('The dir {0} does not exist'.format(base))
return
if e.errno == errno.EACCES:
# We silently ignore entries for which we dont have permission,
# We silently ignore entries for which we don't have permission,
# unless they are the top level dir
if top_level:
raise NoSuchDir('You do not have permission to monitor {0}'.format(base))
@ -235,7 +235,7 @@ class INotifyTreeWatcher(INotify):
def process_event(self, wd, mask, cookie, name):
if wd == -1 and (mask & self.Q_OVERFLOW):
# We missed some INOTIFY events, so we dont
# We missed some INOTIFY events, so we don't
# know the state of any tracked dirs.
self.watch_tree()
self.modified = True

View File

@ -41,7 +41,7 @@ def generate_json_config_loader(lhadproblem):
return load_json_config
function_name_re = '^(\w+\.)*[a-zA-Z_]\w*$'
function_name_re = r'^(\w+\.)*[a-zA-Z_]\w*$'
divider_spec = Spec().printable().len(
@ -130,7 +130,8 @@ main_spec = (Spec(
local_themes=Spec().unknown_spec(
Spec().re('^[0-9A-Za-z-]+$'),
ext_theme_spec()
).optional()
).optional(),
update_interval=Spec().cmp('gt', 0.0).optional(),
).optional(),
).unknown_spec(
check_ext,
@ -204,7 +205,7 @@ vim_colorscheme_spec = (Spec(
mode_translations_value_spec(),
).optional().context_message('Error while loading mode translations (key {key})'),
).context_message('Error while loading vim colorscheme'))
shell_mode_spec = Spec().re('^(?:[\w\-]+|\.safe)$').copy
shell_mode_spec = Spec().re(r'^(?:[\w\-]+|\.safe)$').copy
shell_colorscheme_spec = (Spec(
name=name_spec(),
groups=groups_spec(),
@ -222,7 +223,7 @@ args_spec = Spec(
segment_module_spec = Spec().type(unicode).func(check_segment_module).optional().copy
exinclude_spec = Spec().re(function_name_re).func(check_exinclude_function).copy
segment_spec_base = Spec(
name=Spec().re('^[a-zA-Z_]\w*$').optional(),
name=Spec().re(r'^[a-zA-Z_]\w*$').optional(),
function=Spec().re(function_name_re).func(check_segment_function).optional(),
exclude_modes=Spec().list(vim_mode_spec()).optional(),
include_modes=Spec().list(vim_mode_spec()).optional(),

View File

@ -401,7 +401,7 @@ def check_segment_function(function_name, data, context, echoerr):
context='Error while checking theme (key {key})'.format(key=context.key),
context_mark=function_name.mark,
problem=(
'found highlight group definition in addition to sentense stating that '
'found highlight group definition in addition to sentence stating that '
'no highlight groups are used'
),
problem_mark=mark,
@ -425,7 +425,7 @@ def check_segment_function(function_name, data, context, echoerr):
context='Error while checking theme (key {key})'.format(key=context.key),
context_mark=function_name.mark,
problem=(
'found sentense stating that no highlight groups are used '
'found sentence stating that no highlight groups are used '
'in addition to highlight group definition'
),
problem_mark=mark,

View File

@ -1,7 +1,8 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from inspect import ArgSpec, getargspec
from inspect import FullArgSpec, getfullargspec
from itertools import zip_longest
from powerline.segments import Segment
@ -33,13 +34,15 @@ def getconfigargspec(obj):
requires_filesystem_watcher = hasattr(obj, 'powerline_requires_filesystem_watcher')
for name, method in argspecobjs:
argspec = getargspec(method)
argspec = getfullargspec(method)
omitted_args = get_omitted_args(name, method)
largs = len(argspec.args)
for i, arg in enumerate(reversed(argspec.args)):
if (
largs - (i + 1) in omitted_args
or arg in omitted_args
or arg == 'pl'
or arg == 'self'
or (arg == 'create_watcher' and requires_filesystem_watcher)
or (arg == 'segment_info' and requires_segment_info)
):
@ -58,4 +61,31 @@ def getconfigargspec(obj):
if arg not in args:
args.insert(0, arg)
return ArgSpec(args=args, varargs=None, keywords=None, defaults=tuple(defaults))
return FullArgSpec(args=args, varargs=None, varkw=None, defaults=tuple(defaults), kwonlyargs=(), kwonlydefaults={}, annotations={})
def formatconfigargspec(args, varargs=None, varkw=None, defaults=None,
kwonlyargs=(), kwonlydefaults={}, annotations={},
formatvalue=lambda value: '=' + repr(value)):
'''Format an argument spec from the values returned by getconfigargspec.
This is a specialized replacement for inspect.formatargspec, which has been
deprecated since Python 3.5 and was removed in Python 3.11. It supports
valid values for args, defaults and formatvalue; all other parameters are
expected to be either empty or None.
'''
assert varargs is None
assert varkw is None
assert not kwonlyargs
assert not kwonlydefaults
assert not annotations
specs = []
if defaults:
firstdefault = len(args) - len(defaults)
for i, arg in enumerate(args):
spec = arg
if defaults and i >= firstdefault:
spec += formatvalue(defaults[i - firstdefault])
specs.append(spec)
return '(' + ', '.join(specs) + ')'

View File

@ -122,7 +122,7 @@ class BaseConstructor:
mapping = {}
for key_node, value_node in node.value:
key = self.construct_object(key_node, deep=deep)
if not isinstance(key, collections.Hashable):
if not isinstance(key, collections.abc.Hashable):
self.echoerr(
'While constructing a mapping', node.start_mark,
'found unhashable key', key_node.start_mark

View File

@ -34,7 +34,7 @@ class Spec(object):
.. note::
Methods that create the specifications return ``self``, so calls to them
may be chained: ``Spec().type(unicode).re('^\w+$')``. This does not
may be chained: ``Spec().type(unicode).re('^\\w+$')``. This does not
apply to functions that *apply* specification like :py:meth`Spec.match`.
.. note::
@ -163,7 +163,7 @@ class Spec(object):
'''Define message which will be used when unknown key was found
Unknown is a key that was not provided at the initialization and via
:py:meth:`Spec.update` and did not match any ``keyfunc`` proided via
:py:meth:`Spec.update` and did not match any ``keyfunc`` provided via
:py:meth:`Spec.unknown_spec`.
:param msgfunc:
@ -264,7 +264,7 @@ class Spec(object):
:param func msg_func:
Callable like ``msg_func`` from :py:meth:`Spec.check_func`. Should
accept one problematic item and is not used for :py:class:`Spec`
object indicies in ``item_func`` method.
object indices in ``item_func`` method.
:return: proceed, hadproblem.
'''
@ -515,7 +515,7 @@ class Spec(object):
optional. Each element in this list describes element with the same
index in the checked value. Check out :py:meth:`Spec.check_tuple`
for more details, but note that there list of specifications is
replaced with start and end indicies in ``self.specs``.
replaced with start and end indices in ``self.specs``.
:return: self.
'''
@ -585,7 +585,7 @@ class Spec(object):
msg_func
or (lambda value: 'String "{0}" is not an alphanumeric/underscore colon-separated identifier'.format(value))
)
return self.re('^\w+(?::\w+)?$', msg_func)
return self.re(r'^\w+(?::\w+)?$', msg_func)
def oneof(self, collection, msg_func=None):
'''Describe value that is equal to one of the value in the collection
@ -633,7 +633,7 @@ class Spec(object):
Check out :py:meth:`Spec.check_either` method documentation for more
details, but note that there a list of specs was replaced by start and
end indicies in ``self.specs``.
end indices in ``self.specs``.
:return: self.
'''

View File

@ -26,20 +26,20 @@ def output_lister(pl, segment_info):
def workspace_lister(pl, segment_info, only_show=None, output=None):
'''List all workspaces in segment_info format
Sets the segment info values of ``workspace`` and ``output`` to the name of
Sets the segment info values of ``workspace`` and ``output`` to the name of
the i3 workspace and the ``xrandr`` output respectively and the keys
``"visible"``, ``"urgent"`` and ``"focused"`` to a boolean indicating these
states.
:param list only_show:
Specifies which workspaces to list. Valid entries are ``"visible"``,
``"urgent"`` and ``"focused"``. If omitted or ``null`` all workspaces
Specifies which workspaces to list. Valid entries are ``"visible"``,
``"urgent"`` and ``"focused"``. If omitted or ``null`` all workspaces
are listed.
:param str output:
May be set to the name of an X output. If specified, only workspaces
on that output are listed. Overrides automatic output detection by
the lemonbar renderer and bindings. Set to ``false`` to force
May be set to the name of an X output. If specified, only workspaces
on that output are listed. Overrides automatic output detection by
the lemonbar renderer and bindings. Set to ``false`` to force
all workspaces to be shown.
'''
@ -50,19 +50,14 @@ def workspace_lister(pl, segment_info, only_show=None, output=None):
(
updated(
segment_info,
output=w['output'],
workspace={
'name': w['name'],
'visible': w['visible'],
'urgent': w['urgent'],
'focused': w['focused'],
},
output=w.output,
workspace=w,
),
{
'draw_inner_divider': None
}
)
for w in get_i3_connection().get_workspaces()
if (((not only_show or any(w[typ] for typ in only_show))
and (not output or w['output'] == output)))
if (((not only_show or any(getattr(w, typ) for typ in only_show))
and (not output or w.output == output)))
)

View File

@ -4,6 +4,7 @@ from __future__ import (unicode_literals, division, absolute_import, print_funct
import sys
import os
import re
import operator
from itertools import chain
@ -20,25 +21,25 @@ np_control_character_translations = dict((
))
'''Control character translations
Dictionary that maps characters in range 0x000x1F (inclusive) to strings
Dictionary that maps characters in range 0x000x1F (inclusive) to strings
``'^@'``, ``'^A'`` and so on.
.. note: maps tab to ``^I`` and newline to ``^J``.
'''
np_invalid_character_translations = dict((
# Invalid unicode characters obtained using 'surrogateescape' error
# Invalid unicode characters obtained using 'surrogateescape' error
# handler.
(i2, '<{0:02x}>'.format(i2 - 0xDC00)) for i2 in range(0xDC80, 0xDD00)
))
'''Invalid unicode character translations
When using ``surrogateescape`` encoding error handling method characters in
range 0x800xFF (inclusive) are transformed into unpaired surrogate escape
unicode codepoints 0xDC800xDD00. This dictionary maps such characters to
``<80>``, ``<81>``, and so on: in Python-3 they cannot be printed or
converted to UTF-8 because UTF-8 standard does not allow surrogate escape
characters, not even paired ones. Python-2 contains a bug that allows such
When using ``surrogateescape`` encoding error handling method characters in
range 0x800xFF (inclusive) are transformed into unpaired surrogate escape
unicode codepoints 0xDC800xDD00. This dictionary maps such characters to
``<80>``, ``<81>``, and so on: in Python-3 they cannot be printed or
converted to UTF-8 because UTF-8 standard does not allow surrogate escape
characters, not even paired ones. Python-2 contains a bug that allows such
action, but printing them in any case makes no sense.
'''
@ -46,20 +47,20 @@ action, but printing them in any case makes no sense.
np_invalid_character_re = re.compile('(?<![\uD800-\uDBFF])[\uDC80-\uDD00]')
'''Regex that finds unpaired surrogate escape characters
Search is only limited to the ones obtained from ``surrogateescape`` error
handling method. This regex is only used for UCS-2 Python variants because
in this case characters above 0xFFFF are represented as surrogate escapes
characters and are thus subject to partial transformation if
Search is only limited to the ones obtained from ``surrogateescape`` error
handling method. This regex is only used for UCS-2 Python variants because
in this case characters above 0xFFFF are represented as surrogate escapes
characters and are thus subject to partial transformation if
``np_invalid_character_translations`` translation table is used.
'''
np_character_translations = np_control_character_translations.copy()
'''Dictionary that contains non-printable character translations
In UCS-4 versions of Python this is a union of
``np_invalid_character_translations`` and ``np_control_character_translations``
dictionaries. In UCS-2 for technical reasons ``np_invalid_character_re`` is used
instead and this dictionary only contains items from
In UCS-4 versions of Python this is a union of
``np_invalid_character_translations`` and ``np_control_character_translations``
dictionaries. In UCS-2 for technical reasons ``np_invalid_character_re`` is used
instead and this dictionary only contains items from
``np_control_character_translations``.
'''
@ -80,10 +81,10 @@ translate_np = (
)
'''Function that translates non-printable characters into printable strings
Is used to translate control characters and surrogate escape characters
obtained from ``surrogateescape`` encoding errors handling method into some
printable sequences. See documentation for
``np_invalid_character_translations`` and
Is used to translate control characters and surrogate escape characters
obtained from ``surrogateescape`` encoding errors handling method into some
printable sequences. See documentation for
``np_invalid_character_translations`` and
``np_control_character_translations`` for more details.
'''
@ -105,17 +106,17 @@ class Renderer(object):
:param dict theme_config:
Main theme configuration.
:param local_themes:
Local themes. Is to be used by subclasses from ``.get_theme()`` method,
Local themes. Is to be used by subclasses from ``.get_theme()`` method,
base class only records this parameter to a ``.local_themes`` attribute.
:param dict theme_kwargs:
Keyword arguments for ``Theme`` class constructor.
:param PowerlineLogger pl:
Object used for logging.
:param int ambiwidth:
Width of the characters with east asian width unicode attribute equal to
``A`` (Ambigious).
Width of the characters with east asian width unicode attribute equal to
``A`` (Ambiguous).
:param dict options:
Various options. Are normally not used by base renderer, but all options
Various options. Are normally not used by base renderer, but all options
are recorded as attributes.
'''
@ -126,23 +127,23 @@ class Renderer(object):
}
'''Basic segment info
Is merged with local segment information by :py:meth:`get_segment_info`
Is merged with local segment information by :py:meth:`get_segment_info`
method. Keys:
``environ``
Object containing environment variables. Must define at least the
following methods: ``.__getitem__(var)`` that raises ``KeyError`` in
case requested environment variable is not present, ``.get(var,
default=None)`` that works like ``dict.get`` and be able to be passed to
Object containing environment variables. Must define at least the
following methods: ``.__getitem__(var)`` that raises ``KeyError`` in
case requested environment variable is not present, ``.get(var,
default=None)`` that works like ``dict.get`` and be able to be passed to
``Popen``.
``getcwd``
Function that returns current working directory. Will be called without
any arguments, should return ``unicode`` or (in python-2) regular
Function that returns current working directory. Will be called without
any arguments, should return ``unicode`` or (in python-2) regular
string.
``home``
String containing path to home directory. Should be ``unicode`` or (in
String containing path to home directory. Should be ``unicode`` or (in
python-2) regular string or ``None``.
'''
@ -172,7 +173,7 @@ class Renderer(object):
self.width_data = {
'N': 1, # Neutral
'Na': 1, # Narrow
'A': ambiwidth, # Ambigious
'A': ambiwidth, # Ambiguous
'H': 1, # Half-width
'W': 2, # Wide
'F': 2, # Fullwidth
@ -184,8 +185,8 @@ class Renderer(object):
)
'''Function that returns string width.
Is used to calculate the place given string occupies when handling
``width`` argument to ``.render()`` method. Must take east asian width
Is used to calculate the place given string occupies when handling
``width`` argument to ``.render()`` method. Must take east asian width
into account.
:param unicode string:
@ -197,18 +198,18 @@ class Renderer(object):
def get_theme(self, matcher_info):
'''Get Theme object.
Is to be overridden by subclasses to support local themes, this variant
Is to be overridden by subclasses to support local themes, this variant
only returns ``.theme`` attribute.
:param matcher_info:
Parameter ``matcher_info`` that ``.render()`` method received.
Parameter ``matcher_info`` that ``.render()`` method received.
Unused.
'''
return self.theme
def shutdown(self):
'''Prepare for interpreter shutdown. The only job it is supposed to do
is calling ``.shutdown()`` method for all theme objects. Should be
'''Prepare for interpreter shutdown. The only job it is supposed to do
is calling ``.shutdown()`` method for all theme objects. Should be
overridden by subclasses in case they support local themes.
'''
self.theme.shutdown()
@ -216,12 +217,12 @@ class Renderer(object):
def get_segment_info(self, segment_info, mode):
'''Get segment information.
Must return a dictionary containing at least ``home``, ``environ`` and
``getcwd`` keys (see documentation for ``segment_info`` attribute). This
implementation merges ``segment_info`` dictionary passed to
``.render()`` method with ``.segment_info`` attribute, preferring keys
from the former. It also replaces ``getcwd`` key with function returning
``segment_info['environ']['PWD']`` in case ``PWD`` variable is
Must return a dictionary containing at least ``home``, ``environ`` and
``getcwd`` keys (see documentation for ``segment_info`` attribute). This
implementation merges ``segment_info`` dictionary passed to
``.render()`` method with ``.segment_info`` attribute, preferring keys
from the former. It also replaces ``getcwd`` key with function returning
``segment_info['environ']['PWD']`` in case ``PWD`` variable is
available.
:param dict segment_info:
@ -240,7 +241,7 @@ class Renderer(object):
def render_above_lines(self, **kwargs):
'''Render all segments in the {theme}/segments/above list
Rendering happens in the reversed order. Parameters are the same as in
Rendering happens in the reversed order. Parameters are the same as in
.render() method.
:yield: rendered line.
@ -250,41 +251,46 @@ class Renderer(object):
for line in range(theme.get_line_number() - 1, 0, -1):
yield self.render(side=None, line=line, **kwargs)
def render(self, mode=None, width=None, side=None, line=0, output_raw=False, output_width=False, segment_info=None, matcher_info=None):
def render(self, mode=None, width=None, side=None, line=0, output_raw=False, output_width=False, segment_info=None, matcher_info=None, hl_args=None):
'''Render all segments.
When a width is provided, low-priority segments are dropped one at
a time until the line is shorter than the width, or only segments
with a negative priority are left. If one or more segments with
``"width": "auto"`` are provided they will fill the remaining space
When a width is provided, low-priority segments are dropped one at
a time until the line is shorter than the width, or only segments
with a negative priority are left. If one or more segments with
``"width": "auto"`` are provided they will fill the remaining space
until the desired width is reached.
:param str mode:
Mode string. Affects contents (colors and the set of segments) of
Mode string. Affects contents (colors and the set of segments) of
rendered string.
:param int width:
Maximum width text can occupy. May be exceeded if there are too much
Maximum width text can occupy. May be exceeded if there are too much
non-removable segments.
:param str side:
One of ``left``, ``right``. Determines which side will be rendered.
One of ``left``, ``right``. Determines which side will be rendered.
If not present all sides are rendered.
:param int line:
Line number for which segments should be obtained. Is counted from
Line number for which segments should be obtained. Is counted from
zero (botmost line).
:param bool output_raw:
Changes the output: if this parameter is ``True`` then in place of
one string this method outputs a pair ``(colored_string,
Changes the output: if this parameter is ``True`` then in place of
one string this method outputs a pair ``(colored_string,
colorless_string)``.
:param bool output_width:
Changes the output: if this parameter is ``True`` then in place of
one string this method outputs a pair ``(colored_string,
string_width)``. Returns a three-tuple if ``output_raw`` is also
Changes the output: if this parameter is ``True`` then in place of
one string this method outputs a pair ``(colored_string,
string_width)``. Returns a three-tuple if ``output_raw`` is also
``True``: ``(colored_string, colorless_string, string_width)``.
:param dict segment_info:
Segment information. See also :py:meth:`get_segment_info` method.
:param matcher_info:
Matcher information. Is processed in :py:meth:`get_segment_info`
Matcher information. Is processed in :py:meth:`get_segment_info`
method.
:param dict hl_args:
Additional arguments to pass on the :py:meth:`hl` and
:py:meth`hlstyle` methods. They are ignored in the default
implementation, but renderer-specific overrides can make use of
them as run-time "configuration" information.
'''
theme = self.get_theme(matcher_info)
return self.do_render(
@ -296,6 +302,7 @@ class Renderer(object):
output_width=output_width,
segment_info=self.get_segment_info(segment_info, mode),
theme=theme,
hl_args=hl_args
)
def compute_divider_widths(self, theme):
@ -310,7 +317,20 @@ class Renderer(object):
},
}
def do_render(self, mode, width, side, line, output_raw, output_width, segment_info, theme):
hl_join = staticmethod(''.join)
'''Join a list of rendered segments into a resulting string
This method exists to deal with non-string render outputs, so `segments`
may actually be not an iterable with strings.
:param list segments:
Iterable containing rendered segments. By rendered segments
:py:meth:`Renderer.hl` output is meant.
:return: Results of joining these segments.
'''
def do_render(self, mode, width, side, line, output_raw, output_width, segment_info, theme, hl_args):
'''Like Renderer.render(), but accept theme in place of matcher_info
'''
segments = list(theme.get_segments(side, line, segment_info, mode))
@ -319,14 +339,16 @@ class Renderer(object):
self._prepare_segments(segments, output_width or width)
hl_args = hl_args or dict()
if not width:
# No width specified, so we dont need to crop or pad anything
if output_width:
current_width = self._render_length(theme, segments, self.compute_divider_widths(theme))
return construct_returned_value(''.join([
return construct_returned_value(self.hl_join([
segment['_rendered_hl']
for segment in self._render_segments(theme, segments)
]) + self.hlstyle(), segments, current_width, output_raw, output_width)
for segment in self._render_segments(theme, segments, hl_args)
]) + self.hlstyle(**hl_args), segments, current_width, output_raw, output_width)
divider_widths = self.compute_divider_widths(theme)
@ -341,8 +363,8 @@ class Renderer(object):
segments_priority = iter(segments_priority)
if current_width > width and len(segments) > 100:
# When there are too many segments use faster, but less correct
# algorythm for width computation
# When there are too many segments use faster, but less correct
# algorithm for width computation
diff = current_width - width
for segment in segments_priority:
segments.remove(segment)
@ -351,8 +373,8 @@ class Renderer(object):
break
current_width = self._render_length(theme, segments, divider_widths)
if current_width > width:
# When there are not too much use more precise, but much slower
# width computation. It also finishes computations in case
# When there are not too much use more precise, but much slower
# width computation. It also finishes computations in case
# previous variant did not free enough space.
for segment in segments_priority:
segments.remove(segment)
@ -372,15 +394,18 @@ class Renderer(object):
distribute_len + (1 if distribute_len_remainder > 0 else 0),
segment))
distribute_len_remainder -= 1
# `_len` key is not needed anymore, but current_width should have an
# `_len` key is not needed anymore, but current_width should have an
# actual value for various bindings.
current_width = width
elif output_width:
current_width = self._render_length(theme, segments, divider_widths)
rendered_highlighted = ''.join([segment['_rendered_hl'] for segment in self._render_segments(theme, segments)])
rendered_highlighted = self.hl_join([
segment['_rendered_hl']
for segment in self._render_segments(theme, segments, hl_args)
])
if rendered_highlighted:
rendered_highlighted += self.hlstyle()
rendered_highlighted += self.hlstyle(**hl_args)
return construct_returned_value(rendered_highlighted, segments, current_width, output_raw, output_width)
@ -441,7 +466,7 @@ class Renderer(object):
segment is first_segment
if side == 'left' else
segment is last_segment
))
)) * theme.outer_padding
draw_divider = segment['draw_' + divider_type + '_divider']
segment_len += outer_padding
@ -453,7 +478,7 @@ class Renderer(object):
ret += segment_len
return ret
def _render_segments(self, theme, segments, render_highlighted=True):
def _render_segments(self, theme, segments, hl_args, render_highlighted=True):
'''Internal segment rendering method.
This method loops through the segment array and compares the
@ -502,7 +527,7 @@ class Renderer(object):
segment is first_segment
if side == 'left' else
segment is last_segment
)) * ' '
)) * theme.outer_padding * ' '
divider_type = 'soft' if compare_segment['highlight']['bg'] == segment['highlight']['bg'] else 'hard'
divider_highlighted = ''
@ -510,7 +535,11 @@ class Renderer(object):
contents_highlighted = ''
draw_divider = segment['draw_' + divider_type + '_divider']
# XXX Make sure self.hl() calls are called in the same order
segment_hl_args = {}
segment_hl_args.update(segment['highlight'])
segment_hl_args.update(hl_args)
# XXX Make sure self.hl() calls are called in the same order
# segments are displayed. This is needed for Vim renderer to work.
if draw_divider:
divider_raw = self.escape(theme.get_divider(side, divider_type))
@ -529,14 +558,14 @@ class Renderer(object):
if side == 'left':
if render_highlighted:
contents_highlighted = self.hl(self.escape(contents_raw), **segment['highlight'])
divider_highlighted = self.hl(divider_raw, divider_fg, divider_bg, False)
contents_highlighted = self.hl(self.escape(contents_raw), **segment_hl_args)
divider_highlighted = self.hl(divider_raw, divider_fg, divider_bg, False, **hl_args)
segment['_rendered_raw'] = contents_raw + divider_raw
segment['_rendered_hl'] = contents_highlighted + divider_highlighted
else:
if render_highlighted:
divider_highlighted = self.hl(divider_raw, divider_fg, divider_bg, False)
contents_highlighted = self.hl(self.escape(contents_raw), **segment['highlight'])
divider_highlighted = self.hl(divider_raw, divider_fg, divider_bg, False, **hl_args)
contents_highlighted = self.hl(self.escape(contents_raw), **segment_hl_args)
segment['_rendered_raw'] = divider_raw + contents_raw
segment['_rendered_hl'] = divider_highlighted + contents_highlighted
else:
@ -545,7 +574,7 @@ class Renderer(object):
else:
contents_raw = contents_raw + outer_padding
contents_highlighted = self.hl(self.escape(contents_raw), **segment['highlight'])
contents_highlighted = self.hl(self.escape(contents_raw), **segment_hl_args)
segment['_rendered_raw'] = contents_raw
segment['_rendered_hl'] = contents_highlighted
prev_segment = segment
@ -559,19 +588,19 @@ class Renderer(object):
'''
return string.translate(self.character_translations)
def hlstyle(fg=None, bg=None, attrs=None):
def hlstyle(fg=None, bg=None, attrs=None, **kwargs):
'''Output highlight style string.
Assuming highlighted string looks like ``{style}{contents}`` this method
should output ``{style}``. If it is called without arguments this method
Assuming highlighted string looks like ``{style}{contents}`` this method
should output ``{style}``. If it is called without arguments this method
is supposed to reset style to its default.
'''
raise NotImplementedError
def hl(self, contents, fg=None, bg=None, attrs=None):
def hl(self, contents, fg=None, bg=None, attrs=None, **kwargs):
'''Output highlighted chunk.
This implementation just outputs :py:meth:`hlstyle` joined with
This implementation just outputs :py:meth:`hlstyle` joined with
``contents``.
'''
return self.hlstyle(fg, bg, attrs) + (contents or '')
return self.hlstyle(fg, bg, attrs, **kwargs) + (contents or '')

View File

@ -17,11 +17,11 @@ class I3barRenderer(Renderer):
# We dont need to explicitly reset attributes, so skip those calls
return ''
def hl(self, contents, fg=None, bg=None, attrs=None):
def hl(self, contents, fg=None, bg=None, attrs=None, **kwargs):
segment = {
'full_text': contents,
'separator': False,
'separator_block_width': 0, # no seperators
'separator_block_width': 0, # no separators
}
if fg is not None:
@ -29,9 +29,8 @@ class I3barRenderer(Renderer):
segment['color'] = '#{0:06x}'.format(fg[1])
if bg is not None:
if bg is not False and bg[1] is not False:
segment['background_color'] = '#{0:06x}'.format(bg[1])
# i3bar “pseudo json” requires one line at a time
return json.dumps(segment) + ',\n'
segment['background'] = '#{0:06x}'.format(bg[1])
return json.dumps(segment) + ','
renderer = I3barRenderer

View File

@ -1,12 +1,11 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from powerline.renderers.shell import ShellRenderer
from powerline.renderers.shell.readline import ReadlineRenderer
from powerline.theme import Theme
from powerline.renderers.shell import PromptRenderer
class IPythonRenderer(ShellRenderer):
class IPythonRenderer(PromptRenderer):
'''Powerline ipython segment renderer.'''
def get_segment_info(self, segment_info, mode):
r = self.segment_info.copy()
@ -33,50 +32,3 @@ class IPythonRenderer(ShellRenderer):
for match in self.local_themes.values():
if 'theme' in match:
match['theme'].shutdown()
def render(self, **kwargs):
# XXX super(ShellRenderer), *not* super(IPythonRenderer)
return super(ShellRenderer, self).render(**kwargs)
def do_render(self, segment_info, **kwargs):
segment_info.update(client_id='ipython')
return super(IPythonRenderer, self).do_render(
segment_info=segment_info,
**kwargs
)
class IPythonPromptRenderer(IPythonRenderer, ReadlineRenderer):
'''Powerline ipython prompt (in and in2) renderer'''
pass
class IPythonNonPromptRenderer(IPythonRenderer):
'''Powerline ipython non-prompt (out and rewrite) renderer'''
pass
class RendererProxy(object):
'''Powerline IPython renderer proxy which chooses appropriate renderer
Instantiates two renderer objects: one will be used for prompts and the
other for non-prompts.
'''
def __init__(self, **kwargs):
old_widths = {}
self.non_prompt_renderer = IPythonNonPromptRenderer(old_widths=old_widths, **kwargs)
self.prompt_renderer = IPythonPromptRenderer(old_widths=old_widths, **kwargs)
def render_above_lines(self, *args, **kwargs):
return self.non_prompt_renderer.render_above_lines(*args, **kwargs)
def render(self, is_prompt, *args, **kwargs):
return (self.prompt_renderer if is_prompt else self.non_prompt_renderer).render(
*args, **kwargs)
def shutdown(self, *args, **kwargs):
self.prompt_renderer.shutdown(*args, **kwargs)
self.non_prompt_renderer.shutdown(*args, **kwargs)
renderer = RendererProxy

View File

@ -0,0 +1,56 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from powerline.renderers.shell import ShellRenderer
from powerline.renderers.shell.readline import ReadlineRenderer
from powerline.renderers.ipython import IPythonRenderer
class IPythonPre50Renderer(IPythonRenderer, ShellRenderer):
'''Powerline ipython segment renderer for pre-5.0 IPython versions.'''
def render(self, **kwargs):
# XXX super(ShellRenderer), *not* super(IPythonPre50Renderer)
return super(ShellRenderer, self).render(**kwargs)
def do_render(self, segment_info, **kwargs):
segment_info.update(client_id='ipython')
return super(IPythonPre50Renderer, self).do_render(
segment_info=segment_info,
**kwargs
)
class IPythonPromptRenderer(IPythonPre50Renderer, ReadlineRenderer):
'''Powerline ipython prompt (in and in2) renderer'''
pass
class IPythonNonPromptRenderer(IPythonPre50Renderer):
'''Powerline ipython non-prompt (out and rewrite) renderer'''
pass
class RendererProxy(object):
'''Powerline IPython renderer proxy which chooses appropriate renderer
Instantiates two renderer objects: one will be used for prompts and the
other for non-prompts.
'''
def __init__(self, **kwargs):
old_widths = {}
self.non_prompt_renderer = IPythonNonPromptRenderer(old_widths=old_widths, **kwargs)
self.prompt_renderer = IPythonPromptRenderer(old_widths=old_widths, **kwargs)
def render_above_lines(self, *args, **kwargs):
return self.non_prompt_renderer.render_above_lines(*args, **kwargs)
def render(self, is_prompt, *args, **kwargs):
return (self.prompt_renderer if is_prompt else self.non_prompt_renderer).render(
*args, **kwargs)
def shutdown(self, *args, **kwargs):
self.prompt_renderer.shutdown(*args, **kwargs)
self.non_prompt_renderer.shutdown(*args, **kwargs)
renderer = RendererProxy

View File

@ -0,0 +1,130 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import operator
from collections import defaultdict
try:
from __builtin__ import reduce
except ImportError:
from functools import reduce
from pygments.token import Token
from prompt_toolkit.styles import DynamicStyle, Attrs
from powerline.renderers.ipython import IPythonRenderer
from powerline.ipython import IPythonInfo
from powerline.colorscheme import ATTR_BOLD, ATTR_ITALIC, ATTR_UNDERLINE
PowerlinePromptToken = Token.Generic.Prompt.Powerline
# Note: since 2.7 there is dict.__missing__ with same purpose. But in 2.6 one
# must use defaultdict to get __missing__ working.
class PowerlineStyleDict(defaultdict):
'''Dictionary used for getting pygments style for Powerline groups
'''
def __new__(cls, missing_func):
return defaultdict.__new__(cls)
def __init__(self, missing_func):
super(PowerlineStyleDict, self).__init__()
self.missing_func = missing_func
def __missing__(self, key):
return self.missing_func(key)
class PowerlinePromptStyle(DynamicStyle):
def get_attrs_for_token(self, token):
if (
token not in PowerlinePromptToken
or len(token) != len(PowerlinePromptToken) + 1
or not token[-1].startswith('Pl')
or token[-1] == 'Pl'
):
return super(PowerlinePromptStyle, self).get_attrs_for_token(token)
ret = {
'color': None,
'bgcolor': None,
'bold': None,
'underline': None,
'italic': None,
'reverse': False,
'blink': False,
}
for prop in token[-1][3:].split('_'):
if prop[0] == 'a':
ret[prop[1:]] = True
elif prop[0] == 'f':
ret['color'] = prop[1:]
elif prop[0] == 'b':
ret['bgcolor'] = prop[1:]
return Attrs(**ret)
def get_token_to_attributes_dict(self):
dct = super(PowerlinePromptStyle, self).get_token_to_attributes_dict()
def fallback(key):
try:
return dct[key]
except KeyError:
return self.get_attrs_for_token(key)
return PowerlineStyleDict(fallback)
def invalidation_hash(self):
return super(PowerlinePromptStyle, self).invalidation_hash() + 1
class IPythonPygmentsRenderer(IPythonRenderer):
reduce_initial = []
def get_segment_info(self, segment_info, mode):
return super(IPythonPygmentsRenderer, self).get_segment_info(
IPythonInfo(segment_info), mode)
@staticmethod
def hl_join(segments):
return reduce(operator.iadd, segments, [])
def hl(self, contents, fg=None, bg=None, attrs=None, **kwargs):
'''Output highlighted chunk.
This implementation outputs a list containing a single pair
(:py:class:`pygments.token.Token`,
:py:class:`powerline.lib.unicode.unicode`).
'''
guifg = None
guibg = None
attrs = []
if fg is not None and fg is not False:
guifg = fg[1]
if bg is not None and bg is not False:
guibg = bg[1]
if attrs:
attrs = []
if attrs & ATTR_BOLD:
attrs.append('bold')
if attrs & ATTR_ITALIC:
attrs.append('italic')
if attrs & ATTR_UNDERLINE:
attrs.append('underline')
name = (
'Pl'
+ ''.join(('_a' + attr for attr in attrs))
+ (('_f%6x' % guifg) if guifg is not None else '')
+ (('_b%6x' % guibg) if guibg is not None else '')
)
return [(getattr(Token.Generic.Prompt.Powerline, name), contents)]
def hlstyle(self, **kwargs):
return []
def get_client_id(self, segment_info):
return id(self)
renderer = IPythonPygmentsRenderer

View File

@ -0,0 +1,91 @@
# vim:fileencoding=utf-8:noet
import operator
try:
from __builtin__ import reduce
except ImportError:
from functools import reduce
from pygments.token import Token
from prompt_toolkit.styles import DynamicStyle
from powerline.renderers.ipython import IPythonRenderer
from powerline.ipython import IPythonInfo
from powerline.colorscheme import ATTR_BOLD, ATTR_ITALIC, ATTR_UNDERLINE
used_styles = []
seen = set()
class PowerlinePromptStyle(DynamicStyle):
@property
def style_rules(self):
return (self.get_style() or self._dummy).style_rules + used_styles
def invalidation_hash(self):
return (h + 1 for h in tuple(super(PowerlinePromptStyle, self).invalidation_hash()))
class IPythonPygmentsRenderer(IPythonRenderer):
reduce_initial = []
def __init__(self, **kwargs):
super(IPythonPygmentsRenderer, self).__init__(**kwargs)
self.character_translations[ord(' ')] = ' '
def get_segment_info(self, segment_info, mode):
return super(IPythonPygmentsRenderer, self).get_segment_info(
IPythonInfo(segment_info), mode)
@staticmethod
def hl_join(segments):
return reduce(operator.iadd, segments, [])
def hl(self, escaped_contents, fg=None, bg=None, attrs=None, *args, **kwargs):
'''Output highlighted chunk.
This implementation outputs a list containing a single pair
(:py:class:`string`,
:py:class:`powerline.lib.unicode.unicode`).
'''
guifg = None
guibg = None
att = []
if fg is not None and fg is not False:
guifg = fg[1]
if bg is not None and bg is not False:
guibg = bg[1]
if attrs:
att = []
if attrs & ATTR_BOLD:
att.append('bold')
if attrs & ATTR_ITALIC:
att.append('italic')
if attrs & ATTR_UNDERLINE:
att.append('underline')
fg = (('%06x' % guifg) if guifg is not None else '')
bg = (('%06x' % guibg) if guibg is not None else '')
name = (
'pl'
+ ''.join(('_a' + attr for attr in att))
+ '_f' + fg + '_b' + bg
)
global seen
if not (name in seen):
global used_styles
used_styles += [('pygments.' + name,
''.join((' ' + attr for attr in att))
+ (' fg:#' + fg if fg != '' else ' fg:')
+ (' bg:#' + bg if bg != '' else ' bg:'))]
seen.add(name)
return [((name,), escaped_contents)]
def hlstyle(self, *args, **kwargs):
return []
def get_client_id(self, segment_info):
return id(self)
renderer = IPythonPygmentsRenderer

View File

@ -21,7 +21,7 @@ class LemonbarRenderer(Renderer):
# We dont need to explicitly reset attributes, so skip those calls
return ''
def hl(self, contents, fg=None, bg=None, attrs=None):
def hl(self, contents, fg=None, bg=None, attrs=None, **kwargs):
text = ''
if fg is not None:

View File

@ -15,7 +15,7 @@ class PangoMarkupRenderer(Renderer):
# We dont need to explicitly reset attributes, so skip those calls
return ''
def hl(self, contents, fg=None, bg=None, attrs=None):
def hl(self, contents, fg=None, bg=None, attrs=None, **kwargs):
'''Highlight a segment.'''
awesome_attr = []
if fg is not None:

View File

@ -13,41 +13,30 @@ def int_to_rgb(num):
return r, g, b
class ShellRenderer(Renderer):
'''Powerline shell segment renderer.'''
escape_hl_start = ''
escape_hl_end = ''
term_truecolor = False
term_escape_style = 'auto'
tmux_escape = False
screen_escape = False
character_translations = Renderer.character_translations.copy()
class PromptRenderer(Renderer):
'''Powerline generic prompt segment renderer'''
def __init__(self, old_widths=None, **kwargs):
super(ShellRenderer, self).__init__(**kwargs)
super(PromptRenderer, self).__init__(**kwargs)
self.old_widths = old_widths if old_widths is not None else {}
def render(self, segment_info, **kwargs):
local_theme = segment_info.get('local_theme')
return super(ShellRenderer, self).render(
matcher_info=local_theme,
segment_info=segment_info,
**kwargs
)
def get_client_id(self, segment_info):
'''Get client ID given segment info
This is used by daemon to correctly cache widths for different clients
using a single renderer instance.
:param dict segment_info:
:ref:`Segment info dictionary <dev-segments-info>`. Out of it only
``client_id`` key is used. It is OK for this dictionary to not
contain this key.
:return: Any hashable value or ``None``.
'''
return segment_info.get('client_id') if isinstance(segment_info, dict) else None
def do_render(self, output_width, segment_info, side, theme, width=None, **kwargs):
if self.term_escape_style == 'auto':
if segment_info['environ'].get('TERM') == 'fbterm':
self.used_term_escape_style = 'fbterm'
else:
self.used_term_escape_style = 'xterm'
else:
self.used_term_escape_style = self.term_escape_style
if isinstance(segment_info, dict):
client_id = segment_info.get('client_id')
else:
client_id = None
client_id = self.get_client_id(segment_info)
if client_id is not None:
local_key = (client_id, side, None if theme is self.theme else id(theme))
key = (client_id, side, None)
@ -70,7 +59,7 @@ class ShellRenderer(Renderer):
width -= self.old_widths[(client_id, 'left', local_key[-1])]
except KeyError:
pass
res = super(ShellRenderer, self).do_render(
res = super(PromptRenderer, self).do_render(
output_width=True,
width=width,
theme=theme,
@ -86,7 +75,37 @@ class ShellRenderer(Renderer):
else:
return ret
def hlstyle(self, fg=None, bg=None, attrs=None):
class ShellRenderer(PromptRenderer):
'''Powerline shell segment renderer.'''
escape_hl_start = ''
escape_hl_end = ''
term_truecolor = False
term_escape_style = 'auto'
tmux_escape = False
screen_escape = False
character_translations = Renderer.character_translations.copy()
def render(self, segment_info, **kwargs):
local_theme = segment_info.get('local_theme')
return super(ShellRenderer, self).render(
matcher_info=local_theme,
segment_info=segment_info,
**kwargs
)
def do_render(self, segment_info, **kwargs):
if self.term_escape_style == 'auto':
if segment_info['environ'].get('TERM') == 'fbterm':
self.used_term_escape_style = 'fbterm'
else:
self.used_term_escape_style = 'xterm'
else:
self.used_term_escape_style = self.term_escape_style
return super(ShellRenderer, self).do_render(segment_info=segment_info, **kwargs)
def hlstyle(self, fg=None, bg=None, attrs=None, escape=True, **kwargs):
'''Highlight a segment.
If an argument is None, the argument is ignored. If an argument is
@ -143,7 +162,7 @@ class ShellRenderer(Renderer):
r = '\033Ptmux;' + r.replace('\033', '\033\033') + '\033\\'
elif self.screen_escape:
r = '\033P' + r.replace('\033', '\033\033') + '\033\\'
return self.escape_hl_start + r + self.escape_hl_end
return self.escape_hl_start + r + self.escape_hl_end if escape else r
def get_theme(self, matcher_info):
if not matcher_info:

View File

@ -6,13 +6,91 @@ from powerline.renderers.shell import ShellRenderer
class BashPromptRenderer(ShellRenderer):
'''Powerline bash prompt segment renderer.'''
escape_hl_start = '\['
escape_hl_end = '\]'
escape_hl_start = '\\['
escape_hl_end = '\\]'
character_translations = ShellRenderer.character_translations.copy()
character_translations[ord('$')] = '\\$'
character_translations[ord('`')] = '\\`'
character_translations[ord('\\')] = '\\\\'
def do_render(self, side, line, width, output_width, output_raw, hl_args, **kwargs):
# we are rendering the normal left prompt
if side == 'left' and line == 0 and width is not None:
# we need left prompt's width to render the raw spacer
output_width = output_width or output_raw
left = super(BashPromptRenderer, self).do_render(
side=side,
line=line,
output_width=output_width,
width=width,
output_raw=output_raw,
hl_args=hl_args,
**kwargs
)
left_rendered = left[0] if output_width else left
# we don't escape color sequences in the right prompt so we can do escaping as a whole
if hl_args:
hl_args = hl_args.copy()
hl_args.update({'escape': False})
else:
hl_args = {'escape': False}
right = super(BashPromptRenderer, self).do_render(
side='right',
line=line,
output_width=True,
width=width,
output_raw=output_raw,
hl_args=hl_args,
**kwargs
)
ret = []
if right[-1] > 0:
# if the right prompt is not empty we embed it in the left prompt
# it must be escaped as a whole so readline doesn't see it
ret.append(''.join((
left_rendered,
self.escape_hl_start,
'\033[s', # save the cursor position
'\033[{0}C'.format(width), # move to the right edge of the terminal
'\033[{0}D'.format(right[-1] - 1), # move back to the right prompt position
right[0],
'\033[u', # restore the cursor position
self.escape_hl_end
)))
if output_raw:
ret.append(''.join((
left[1],
' ' * (width - left[-1] - right[-1]),
right[1]
)))
else:
ret.append(left_rendered)
if output_raw:
ret.append(left[1])
if output_width:
ret.append(left[-1])
if len(ret) == 1:
return ret[0]
else:
return ret
else:
return super(BashPromptRenderer, self).do_render(
side=side,
line=line,
width=width,
output_width=output_width,
output_raw=output_raw,
hl_args=hl_args,
**kwargs
)
renderer = BashPromptRenderer

View File

@ -38,7 +38,7 @@ class TmuxRenderer(Renderer):
width = 10
return super(TmuxRenderer, self).render(width=width, segment_info=segment_info, **kwargs)
def hlstyle(self, fg=None, bg=None, attrs=None):
def hlstyle(self, fg=None, bg=None, attrs=None, **kwargs):
'''Highlight a segment.'''
# We dont need to explicitly reset attributes, so skip those calls
if not attrs and not bg and not fg:
@ -48,12 +48,18 @@ class TmuxRenderer(Renderer):
if fg is False or fg[0] is False:
tmux_attrs += ['fg=default']
else:
tmux_attrs += ['fg=colour' + str(fg[0])]
if self.term_truecolor and fg[1]:
tmux_attrs += ['fg=#{0:06x}'.format(int(fg[1]))]
else:
tmux_attrs += ['fg=colour' + str(fg[0])]
if bg is not None:
if bg is False or bg[0] is False:
tmux_attrs += ['bg=default']
else:
tmux_attrs += ['bg=colour' + str(bg[0])]
if self.term_truecolor and bg[1]:
tmux_attrs += ['bg=#{0:06x}'.format(int(bg[1]))]
else:
tmux_attrs += ['bg=colour' + str(bg[0])]
if attrs is not None:
tmux_attrs += attrs_to_tmux_attrs(attrs)
return '#[' + ','.join(tmux_attrs) + ']'
@ -62,7 +68,9 @@ class TmuxRenderer(Renderer):
r = self.segment_info.copy()
if segment_info:
r.update(segment_info)
if 'pane_id' in r:
if 'pane_current_path' in r:
r['getcwd'] = lambda: r['pane_current_path']
elif 'pane_id' in r:
varname = 'TMUX_PWD_' + str(r['pane_id'])
if varname in r['environ']:
r['getcwd'] = lambda: r['environ'][varname]

View File

@ -123,7 +123,7 @@ class VimRenderer(Renderer):
def reset_highlight(self):
self.hl_groups.clear()
def hlstyle(self, fg=None, bg=None, attrs=None):
def hlstyle(self, fg=None, bg=None, attrs=None, **kwargs):
'''Highlight a segment.
If an argument is None, the argument is ignored. If an argument is

View File

@ -72,30 +72,39 @@ def _fetch_battery_info(pl):
devtype_name,
'State'
) != 2
return (energy * 100.0 / energy_full), state
if energy_full > 0:
return (energy * 100.0 / energy_full), state
else:
return 0.0, state
return _flatten_battery
pl.debug('Not using DBUS+UPower as no batteries were found')
if os.path.isdir('/sys/class/power_supply'):
linux_energy_full_fmt = '/sys/class/power_supply/{0}/energy_full'
linux_energy_fmt = '/sys/class/power_supply/{0}/energy_now'
# ENERGY_* attributes represents capacity in µWh only.
# CHARGE_* attributes represents capacity in µAh only.
linux_capacity_units = ('energy', 'charge')
linux_energy_full_fmt = '/sys/class/power_supply/{0}/{1}_full'
linux_energy_fmt = '/sys/class/power_supply/{0}/{1}_now'
linux_status_fmt = '/sys/class/power_supply/{0}/status'
devices = []
for linux_supplier in os.listdir('/sys/class/power_supply'):
energy_path = linux_energy_fmt.format(linux_supplier)
if not os.path.exists(energy_path):
continue
pl.debug('Using /sys/class/power_supply with battery {0}', linux_supplier)
devices.append(linux_supplier)
for unit in linux_capacity_units:
energy_path = linux_energy_fmt.format(linux_supplier, unit)
if not os.path.exists(energy_path):
continue
pl.debug('Using /sys/class/power_supply with battery {0} and unit {1}',
linux_supplier, unit)
devices.append((linux_supplier, unit))
break # energy or charge, not both
if devices:
def _get_battery_status(pl):
energy = 0.0
energy_full = 0.0
state = True
for device in devices:
with open(linux_energy_full_fmt.format(device), 'r') as f:
for device, unit in devices:
with open(linux_energy_full_fmt.format(device, unit), 'r') as f:
energy_full += int(float(f.readline().split()[0]))
with open(linux_energy_fmt.format(device), 'r') as f:
with open(linux_energy_fmt.format(device, unit), 'r') as f:
energy += int(float(f.readline().split()[0]))
try:
with open(linux_status_fmt.format(device), 'r') as f:
@ -105,6 +114,21 @@ def _fetch_battery_info(pl):
return (energy * 100.0 / energy_full), state
return _get_battery_status
pl.debug('Not using /sys/class/power_supply as no batteries were found')
else:
pl.debug("Checking for first capacity battery percentage")
for batt in os.listdir('/sys/class/power_supply'):
if os.path.exists('/sys/class/power_supply/{0}/capacity'.format(batt)):
def _get_battery_perc(pl):
state = True
with open('/sys/class/power_supply/{0}/capacity'.format(batt), 'r') as f:
perc = int(f.readline().split()[0])
try:
with open(linux_status_fmt.format(batt), 'r') as f:
state &= (f.readline().strip() != 'Discharging')
except IOError:
state = None
return perc, state
return _get_battery_perc
else:
pl.debug('Not using /sys/class/power_supply: no directory')

View File

@ -19,20 +19,24 @@ def environment(pl, segment_info, variable=None):
@requires_segment_info
def virtualenv(pl, segment_info, ignore_venv=False, ignore_conda=False):
def virtualenv(pl, segment_info, ignore_venv=False, ignore_conda=False, ignored_names=("venv", ".venv")):
'''Return the name of the current Python or conda virtualenv.
:param list ignored_names:
Names of venvs to ignore. Will then get the name of the venv by ascending to the parent directory
:param bool ignore_venv:
Whether to ignore virtual environments. Default is False.
:param bool ignore_conda:
Whether to ignore conda environments. Default is False.
'''
return (
(not ignore_venv and
os.path.basename(segment_info['environ'].get('VIRTUAL_ENV', ''))) or
(not ignore_conda and
segment_info['environ'].get('CONDA_DEFAULT_ENV', '')) or
None)
if not ignore_venv:
for candidate in reversed(segment_info['environ'].get('VIRTUAL_ENV', '').split("/")):
if candidate and candidate not in ignored_names:
return candidate
if not ignore_conda:
for candidate in reversed(segment_info['environ'].get('CONDA_DEFAULT_ENV', '').split("/")):
if candidate and candidate not in ignored_names:
return candidate
return None
@requires_segment_info
@ -44,7 +48,7 @@ class CwdSegment(Segment):
def omitted_args(self, name, method):
if method is self.get_shortened_path:
return (0, 1, 2)
return ()
else:
return super(CwdSegment, self).omitted_args(name, method)
@ -159,7 +163,8 @@ username = False
_geteuid = getattr(os, 'geteuid', lambda: 1)
def user(pl, hide_user=None, hide_domain=False):
@requires_segment_info
def user(pl, segment_info, hide_user=None, hide_domain=False):
'''Return the current user.
:param str hide_user:
@ -172,6 +177,11 @@ def user(pl, hide_user=None, hide_domain=False):
Highlight groups used: ``superuser`` or ``user``. It is recommended to define all highlight groups.
'''
global username
if (
segment_info['environ'].get('_POWERLINE_RUNNING_SHELL_TESTS')
== 'ee5bcdc6-b749-11e7-9456-50465d597777'
):
return 'user'
if username is False:
username = _get_user()
if username is None:

View File

@ -1,6 +1,8 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
import os
import re
from imaplib import IMAP4_SSL_PORT, IMAP4_SSL, IMAP4
@ -17,9 +19,19 @@ class EmailIMAPSegment(KwThreadedSegment):
interval = 60
@staticmethod
def key(username, password, server='imap.gmail.com', port=IMAP4_SSL_PORT, folder='INBOX', use_ssl=None, **kwargs):
def key(username='', password='', server='imap.gmail.com', port=IMAP4_SSL_PORT, username_variable='', password_variable='', server_variable='', port_variable='', folder='INBOX', use_ssl=None, **kwargs):
if use_ssl is None:
use_ssl = (port == IMAP4_SSL_PORT)
# catch if user set custom mail credential env variables
if username_variable:
username = os.environ[username_variable]
if password_variable:
password = os.environ[password_variable]
if server_variable:
server = os.environ[server_variable]
if port_variable:
port = os.environ[port_variable]
return _IMAPKey(username, password, server, port, folder, use_ssl)
def compute_state(self, key):
@ -33,7 +45,7 @@ class EmailIMAPSegment(KwThreadedSegment):
mail.login(key.username, key.password)
rc, message = mail.status(key.folder, '(UNSEEN)')
unread_str = message[0].decode('utf-8')
unread_count = int(re.search('UNSEEN (\d+)', unread_str).group(1))
unread_count = int(re.search(r'UNSEEN (\d+)', unread_str).group(1))
return unread_count
@staticmethod
@ -64,6 +76,14 @@ email_imap_alert = with_docstring(EmailIMAPSegment(),
e-mail server
:param int port:
e-mail server port
:param str username_variable:
name of environment variable to check for login username
:param str password_variable:
name of environment variable to check for login password
:param str server_variable:
name of environment variable to check for email server
:param str port_variable:
name of environment variable to check for email server port
:param str folder:
folder to check for e-mails
:param int max_msgs:

Some files were not shown because too many files have changed in this diff Show More