Compare commits
347 Commits
Author | SHA1 | Date |
---|---|---|
|
574bb1887b | |
|
2c20cc20dd | |
|
ef68bd8c35 | |
|
8484023b7b | |
|
6b36ba8ae9 | |
|
a34abe325a | |
|
beca2d6e87 | |
|
c04a8dd5a1 | |
|
14cc0d2df8 | |
|
833f30e88e | |
|
50d73bfbc8 | |
|
8af6302c81 | |
|
3555dc97c9 | |
|
567e2c930b | |
|
90af71c122 | |
|
9ce39e6333 | |
|
82c1373ba0 | |
|
57aea1e400 | |
|
8f0d3f8bd2 | |
|
7310d53ade | |
|
a1309cc116 | |
|
1869cc8bed | |
|
c31f83f831 | |
|
999c84a5cb | |
|
f401ee3106 | |
|
a6060c760a | |
|
f4ef122759 | |
|
a1a36699b3 | |
|
0cccb7b4bc | |
|
a80bbdf17d | |
|
91ec7982ca | |
|
40c3e092b6 | |
|
ff629c388e | |
|
73881c1dce | |
|
992c5464ba | |
|
8c6874d855 | |
|
14a4100c4c | |
|
65f968ad3a | |
|
59a5425597 | |
|
da3ed7e720 | |
|
c26938a980 | |
|
3dc174919d | |
|
022d77dc1e | |
|
1234aafa5d | |
|
2bddcc9617 | |
|
7300197433 | |
|
b0ea99430c | |
|
d498f29261 | |
|
4b24e715dc | |
|
15c611ca46 | |
|
d6c06e002a | |
|
5b3e401215 | |
|
43c1707206 | |
|
589461e109 | |
|
f4dfe39112 | |
|
af557ae60c | |
|
fff5c2a7b0 | |
|
4abebb49eb | |
|
f9937ab922 | |
|
ef6c9b435c | |
|
6569cc6cfd | |
|
f9ce8201c4 | |
|
bc33b1ce31 | |
|
2428f78ea4 | |
|
25737d90eb | |
|
aa3d04b2ed | |
|
8c0577d9fd | |
|
5d82d544f3 | |
|
e64ce9bd1a | |
|
393ff7119f | |
|
d7a9393888 | |
|
6a7b7d97f3 | |
|
616ea816c8 | |
|
b7a68da865 | |
|
1bed167d8e | |
|
a92bc72801 | |
|
6257332372 | |
|
4a8e8b5b0c | |
|
e3c34e7136 | |
|
1da9485f5f | |
|
a5dd717ac4 | |
|
052260ad4d | |
|
f813171596 | |
|
80156fb840 | |
|
e52754d5c5 | |
|
166013aab0 | |
|
d36850f33d | |
|
74c08cd538 | |
|
cc965526fb | |
|
3c4ec09281 | |
|
d27961f0b0 | |
|
2fc0e8e520 | |
|
4a834f38aa | |
|
23bec031a4 | |
|
466ee2e295 | |
|
fbf711bc10 | |
|
a5e5ed00d4 | |
|
b53708b577 | |
|
bad86469b7 | |
|
3b3d546e89 | |
|
910c6a33dd | |
|
ed0630d074 | |
|
f507a6370a | |
|
9d836d70e0 | |
|
cee07a69b1 | |
|
2a01c4687e | |
|
b558d200fe | |
|
1b0df9c2bd | |
|
0c594b0b34 | |
|
d18b58821b | |
|
436b4b680a | |
|
eb17b5374b | |
|
870de7be21 | |
|
6bbcb610c7 | |
|
3fca2f8d02 | |
|
96f9c62d86 | |
|
44e0a30b80 | |
|
29d0a3c171 | |
|
cbea5357a9 | |
|
eb5834cf3e | |
|
335be73d3e | |
|
b047abcd9a | |
|
55d9c320dc | |
|
0a1cf1780f | |
|
f111a95b0d | |
|
2787855008 | |
|
f0944f840e | |
|
2a4f76e4fa | |
|
45e148b3a0 | |
|
0ad1d9be40 | |
|
468397b224 | |
|
e71cc3e9ef | |
|
783b56066f | |
|
a4a1c83539 | |
|
6be991c571 | |
|
5198b50463 | |
|
421a71ee53 | |
|
67683ecbb8 | |
|
c8f361c9ca | |
|
119c709bf2 | |
|
d7cbeb9022 | |
|
9bebc2fe7f | |
|
5adb7d11a3 | |
|
5a24eceae9 | |
|
6b3c71bf3b | |
|
bc1713d58b | |
|
01f2a3ae92 | |
|
2a9a0a8282 | |
|
2fe9282d61 | |
|
146cf8994d | |
|
5d6aa0e07a | |
|
5d8739b291 | |
|
1b3456a449 | |
|
d0d0644e3c | |
|
5a53cf9f93 | |
|
8d85c4f73b | |
|
9bff8a5660 | |
|
e627b29f76 | |
|
e3ee79d976 | |
|
544556f145 | |
|
8dd1188bc8 | |
|
324432bd12 | |
|
0595c89f21 | |
|
b82769ad4b | |
|
8a5310806f | |
|
338470c11f | |
|
f35c401b0f | |
|
29ff2b99c4 | |
|
924bbbe92b | |
|
73244eb976 | |
|
8d577b5958 | |
|
34dc7f9f55 | |
|
9cd66c0b2f | |
|
234091c95d | |
|
517f38c566 | |
|
e991b42c1b | |
|
90032f8d0c | |
|
4dc590bde7 | |
|
7189f35cf0 | |
|
d3e5d99a20 | |
|
3c49ed1e96 | |
|
3df98fc276 | |
|
28faebe260 | |
|
8e94773791 | |
|
36dba1134f | |
|
1151449a8c | |
|
abb0cab64f | |
|
ef3b547558 | |
|
b5fe29eff5 | |
|
b0d31181cd | |
|
30acc6ed4c | |
|
b1e2086fe3 | |
|
443679d532 | |
|
de899c5fc5 | |
|
be5879379e | |
|
8150d38bd2 | |
|
da3a0fab68 | |
|
1e6414d0e8 | |
|
f6bf7b4916 | |
|
d23c17b7a0 | |
|
c9824da701 | |
|
37cd44ae75 | |
|
5e46d3b1ef | |
|
bf29fa9537 | |
|
8da977e0a1 | |
|
9bad9b8375 | |
|
343b217cae | |
|
2d877c9240 | |
|
65c6ed1cff | |
|
4c5b02d236 | |
|
2fcbd89ef8 | |
|
225ed1f230 | |
|
5a3e19847e | |
|
717ae5e428 | |
|
1303cd1b04 | |
|
0fc96abce2 | |
|
f3bf749467 | |
|
53a7d1046e | |
|
82ca32edc9 | |
|
c30383a194 | |
|
2a1aef1bac | |
|
cac99271ca | |
|
255ff49def | |
|
9d7366436b | |
|
96d83346a5 | |
|
a05857e64e | |
|
65130ae6ff | |
|
1b3aacb837 | |
|
1d602204b1 | |
|
e34a372f10 | |
|
e3d0649372 | |
|
afb6b0995d | |
|
a2bc59c020 | |
|
93cbeb92e9 | |
|
bbb9ae21f4 | |
|
883aa73e9f | |
|
519f08541b | |
|
3d0f168806 | |
|
3b769d2b98 | |
|
4c2583311c | |
|
32eec2f9f3 | |
|
756ea5bfab | |
|
86f6943b08 | |
|
b93ae8e8a2 | |
|
e19feb9472 | |
|
b71d5f2d44 | |
|
36b9c966e0 | |
|
908d767ec0 | |
|
b7a46eb7a8 | |
|
4a3f098f22 | |
|
fb769d7297 | |
|
14982fc693 | |
|
ca8245b9e8 | |
|
0a2359848a | |
|
d4d6bca2d0 | |
|
5fa504118e | |
|
0eb2bae904 | |
|
05fa1da30a | |
|
5a7c3e02ce | |
|
92c9a4f3e4 | |
|
b4e9242807 | |
|
d9f12a458e | |
|
0d31221f20 | |
|
0299dd132c | |
|
0caef54a85 | |
|
f1014e414f | |
|
340f73eff0 | |
|
4c68f773aa | |
|
faf452e8eb | |
|
3aad562087 | |
|
063a45672f | |
|
c417395ee8 | |
|
dd707cc0a6 | |
|
64c9761c65 | |
|
e2e0d73b2c | |
|
01d28baf72 | |
|
55928a72bc | |
|
09821d98f8 | |
|
19659189da | |
|
8e0bed9677 | |
|
4189862b85 | |
|
908c575223 | |
|
5b9487e27b | |
|
0240643071 | |
|
e578b8af27 | |
|
8286674bf7 | |
|
da4f5137f6 | |
|
d53695a3fd | |
|
12bd79729e | |
|
b7d030a72a | |
|
21ea62db56 | |
|
69a72dbf69 | |
|
51fabca257 | |
|
bfd50a5a7a | |
|
6f32ca001c | |
|
fb9f7dd8ef | |
|
64d96c833e | |
|
19f9885825 | |
|
23f663f228 | |
|
373952684a | |
|
cdea113722 | |
|
18192db3da | |
|
4705aa666e | |
|
f67ea65057 | |
|
32b24593d2 | |
|
cdd0cdbfee | |
|
be762da476 | |
|
25657089db | |
|
03e63fc8d2 | |
|
5784c0cbc6 | |
|
4b8798f192 | |
|
72572c8695 | |
|
70246c38e7 | |
|
d135631e67 | |
|
ead3ff33f3 | |
|
dd58d5f4cd | |
|
08137c52c7 | |
|
31fd9e6c04 | |
|
29cdd7f3dc | |
|
a3b14de0f5 | |
|
ed69b983b2 | |
|
f71d1c1fee | |
|
0fc01e07be | |
|
66c6de34ee | |
|
44db0ac860 | |
|
d89e7909d9 | |
|
5b16efa6ec | |
|
2954c83330 | |
|
897751838c | |
|
d816de054a | |
|
436be7dacb | |
|
2a4e818ab6 | |
|
41a50fe5b2 | |
|
d115012b3b | |
|
4a688a7467 | |
|
23e1edd484 | |
|
f4cbeaff9b | |
|
e027c5ed47 | |
|
72053f688f | |
|
fd54f63347 | |
|
c91bcd9ba1 | |
|
a8f3d016a7 | |
|
4d62732ed5 | |
|
802791e979 | |
|
c9ca8e06d1 | |
|
3bcd0ec547 | |
|
87476e41e9 |
|
@ -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/
|
|
@ -10,4 +10,7 @@ build
|
|||
|
||||
message.fail
|
||||
|
||||
client/powerline
|
||||
/client/powerline
|
||||
|
||||
/tests/tmp
|
||||
/tests/status
|
||||
|
|
21
.travis.yml
21
.travis.yml
|
@ -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
|
||||
|
|
|
@ -5,3 +5,4 @@ recursive-include powerline/dist *.*
|
|||
recursive-include client *.*
|
||||
recursive-include docs/source *.rst *.py
|
||||
include docs/Makefile
|
||||
include LICENSE
|
||||
|
|
68
README.rst
68
README.rst
|
@ -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 Ling’s `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
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -117,10 +117,14 @@ segments that you may want to customize right away:
|
|||
so unless you’re on a VPN you probably won’t 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 you’ll
|
||||
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"
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ Pdb listers
|
|||
:members:
|
||||
|
||||
i3wm listers
|
||||
----------
|
||||
------------
|
||||
|
||||
.. automodule:: powerline.listers.i3wm
|
||||
:members:
|
||||
|
|
|
@ -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>`.
|
||||
|
|
|
@ -9,6 +9,12 @@ Vim segments
|
|||
Plugin-specific segments
|
||||
========================
|
||||
|
||||
Asynchronous Linter Engine (ALE) segments
|
||||
-----------------------------------------
|
||||
|
||||
.. automodule:: powerline.segments.vim.plugin.ale
|
||||
:members:
|
||||
|
||||
Syntastic segments
|
||||
------------------
|
||||
|
||||
|
|
|
@ -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
|
||||
=============
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 it’s
|
||||
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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 Ling’s `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
|
||||
-----------
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
-----------------------------------------------
|
||||
|
|
|
@ -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
|
||||
--------------------------------------------------------
|
||||
|
|
|
@ -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``.
|
||||
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -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``.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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. Won’t 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. Won’t 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:
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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':
|
||||
|
|
|
@ -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))
|
|
@ -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))
|
|
@ -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))
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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)
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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": [] }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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"] }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"] }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"] }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
},
|
||||
"wm": {
|
||||
"colorscheme": "default",
|
||||
"theme": "default"
|
||||
"theme": "default",
|
||||
"update_interval": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 "
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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": "○"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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": {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
"priority": 20
|
||||
},
|
||||
{
|
||||
"function": "powerline.segments.shell.last_status",
|
||||
"function": "powerline.segments.shell.last_pipe_status",
|
||||
"priority": 10
|
||||
}
|
||||
]
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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 "
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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'
|
||||
)
|
||||
|
||||
|
|
|
@ -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,),
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) + ')'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
'''
|
||||
|
|
|
@ -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)))
|
||||
)
|
||||
|
|
|
@ -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 0x00–0x1F (inclusive) to strings
|
||||
Dictionary that maps characters in range 0x00–0x1F (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 0x80–0xFF (inclusive) are transformed into unpaired surrogate escape
|
||||
unicode codepoints 0xDC80–0xDD00. 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 0x80–0xFF (inclusive) are transformed into unpaired surrogate escape
|
||||
unicode codepoints 0xDC80–0xDD00. 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 don’t 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 '')
|
||||
|
|
|
@ -17,11 +17,11 @@ class I3barRenderer(Renderer):
|
|||
# We don’t 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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -21,7 +21,7 @@ class LemonbarRenderer(Renderer):
|
|||
# We don’t 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:
|
||||
|
|
|
@ -15,7 +15,7 @@ class PangoMarkupRenderer(Renderer):
|
|||
# We don’t 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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 don’t 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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
Loading…
Reference in New Issue