Initial release: version 1.0
Current features include: - Application support: vim, ipython, awesome, qtile, i3, tmux, zsh, fish, tcsh, bash and some other shells. - Powerline daemon that makes tmux and shell bindings work faster. - Automatic statusline shrinking. - Segments: - Branch and file status segments support for git, mercurial and bazaar version control systems. - Battery support for linux (dbus and /sys/class/power_supply), OS X and Windows platforms. - Player support: CMUS, MPD, Spotify, Clementine, Rhythmobox, RDIO. - Support for displaying weather. - Current directory display in shells, including zsh named directories support. - Vim plugins support: Ctrl-P, Gundo, NerdTree, Syntastic, TagBar. - A huge number of other segments. - Automatic configuration reloading. - Merging configuration from various locations. - Filesystem watchers for configuration reloading and VCS segments: - INotify-based watcher. - LibUv-based watcher. - Stat-based watcher (only files).
20
.editorconfig
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# editorconfig ini file
|
||||||
|
# Check out http://editorconfig.org for a list of plugins for different
|
||||||
|
# IDEs/text editors that support this file. Vim plugin to support this:
|
||||||
|
#
|
||||||
|
# http://www.vim.org/scripts/script.php?script_id=3934
|
||||||
|
# https://github.com/editorconfig/editorconfig-vim
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = tab
|
||||||
|
# Despite promise somewhere alignment is done only using tabs. Thus setting
|
||||||
|
# indent_size and tab_width is a requirement.
|
||||||
|
indent_size = 4
|
||||||
|
tab_width = 4
|
||||||
|
charset = utf-8
|
||||||
|
|
||||||
|
[*.rst]
|
||||||
|
indent_style = space
|
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.rst whitespace=-blank-at-eol
|
13
.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
tags
|
||||||
|
|
||||||
|
*.py[co]
|
||||||
|
__pycache__
|
||||||
|
|
||||||
|
*.egg
|
||||||
|
*.egg-info
|
||||||
|
dist
|
||||||
|
build
|
||||||
|
|
||||||
|
message.fail
|
||||||
|
|
||||||
|
client/powerline
|
11
.local.vimrc
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
" Project vimrc file. To be sourced each time you open any file in this
|
||||||
|
" repository. You may use [vimscript #3393][1] [(homepage)][2] to do this
|
||||||
|
" automatically.
|
||||||
|
"
|
||||||
|
" [1]: http://www.vim.org/scripts/script.php?script_id=3393
|
||||||
|
" [2]: https://github.com/thinca/vim-localrc
|
||||||
|
let g:syntastic_python_flake8_args = '--ignore=W191,E501,E128,W291,E126,E101'
|
||||||
|
let b:syntastic_checkers = ['flake8']
|
||||||
|
unlet! g:python_space_error_highlight
|
||||||
|
let g:pymode_syntax_indent_errors = 0
|
||||||
|
let g:pymode_syntax_space_errors = 0
|
12
.travis.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
language: python
|
||||||
|
python:
|
||||||
|
- "2.6"
|
||||||
|
- "2.7"
|
||||||
|
- "3.2"
|
||||||
|
- "3.3"
|
||||||
|
- "3.4"
|
||||||
|
- "pypy"
|
||||||
|
install: tests/install.sh
|
||||||
|
script: tests/test.sh
|
||||||
|
|
||||||
|
# vim: et
|
137
CONTRIBUTING.rst
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
*****************
|
||||||
|
How to contribute
|
||||||
|
*****************
|
||||||
|
|
||||||
|
So you want to contribute to the Powerline project? Awesome! This document
|
||||||
|
describes the guidelines you should follow when making contributions to the
|
||||||
|
project.
|
||||||
|
|
||||||
|
**Please note that these guidelines aren't mandatory in any way, but your
|
||||||
|
pull request will be merged a lot faster if you follow them.**
|
||||||
|
|
||||||
|
Getting started
|
||||||
|
===============
|
||||||
|
|
||||||
|
* Make sure you have a `GitHub account <https://github.com/signup/free>`_.
|
||||||
|
* Submit an `issue on GitHub
|
||||||
|
<https://github.com/Lokaltog/powerline/issues>`_, assuming one does not
|
||||||
|
already exist.
|
||||||
|
|
||||||
|
* Clearly describe the issue.
|
||||||
|
* If the issue is a bug: make sure you include steps to reproduce, and
|
||||||
|
include the earliest revision that you know has the issue.
|
||||||
|
|
||||||
|
* Fork the repository on GitHub.
|
||||||
|
|
||||||
|
Making changes
|
||||||
|
==============
|
||||||
|
|
||||||
|
* Create a topic branch from where you want to base your work.
|
||||||
|
|
||||||
|
* Powerline uses the `Git Flow
|
||||||
|
<http://nvie.com/posts/a-successful-git-branching-model/>`_ branching
|
||||||
|
model.
|
||||||
|
* Most contributions should be based off the ``develop`` branch.
|
||||||
|
* Prefix your branch with ``feature/`` if you're working on a new feature.
|
||||||
|
* Include the issue number in your topic branch, e.g.
|
||||||
|
``321-fix-some-error`` or ``feature/123-a-cool-feature``.
|
||||||
|
|
||||||
|
* Make commits of logical units.
|
||||||
|
* Run your code through ``flake8`` and fix any programming style errors. Use
|
||||||
|
common sense regarding whitespace warnings, not all warnings need to be
|
||||||
|
fixed.
|
||||||
|
* Make sure your commit messages are in the `proper format
|
||||||
|
<http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html>`_.
|
||||||
|
The summary must be no longer than 70 characters. Refer to any related
|
||||||
|
issues with e.g. ``Ref #123`` or ``Fixes #234`` at the bottom of the
|
||||||
|
commit message. Commit messages can use Markdown with the following
|
||||||
|
exceptions:
|
||||||
|
|
||||||
|
* No HTML extensions.
|
||||||
|
* Only indented code blocks (no ``````` blocks).
|
||||||
|
* Long links should be moved to the bottom if they make the text wrap or
|
||||||
|
extend past 72 columns.
|
||||||
|
|
||||||
|
* Make sure you have added the necessary tests for your changes.
|
||||||
|
* Run *all* the tests to assure nothing else was accidentally broken.
|
||||||
|
|
||||||
|
Programming style
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
* The project uses *tabs for indentation* and *spaces for alignment*, this
|
||||||
|
is also included in a vim modeline on top of every script file.
|
||||||
|
* Run your code through ``flake8 --ignore=W191,E501,E128,W291,E126,E101`` to fix
|
||||||
|
any style errors. Use common sense regarding whitespace warnings, not all
|
||||||
|
``flake8`` warnings need to be fixed.
|
||||||
|
* Trailing whitespace to indicate a continuing paragraph is OK in comments,
|
||||||
|
documentation and commit messages.
|
||||||
|
* It is allowed to have too long lines. It is advised though to avoid lines
|
||||||
|
wider then a hundred of characters.
|
||||||
|
* Imports have the following structure:
|
||||||
|
|
||||||
|
1. Shebang and modeline in a form
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
|
||||||
|
. Modeline is required, shebang is not. If shebang is present file must end
|
||||||
|
with
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# Actual script here
|
||||||
|
|
||||||
|
2. Module docstring.
|
||||||
|
3. ``__future__`` import exactly in a form
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
(powerline.shell is the only exception due to problems with argparse). It
|
||||||
|
is not separated by newline with shebang and modeline, but is with
|
||||||
|
docstring.
|
||||||
|
4. Standard python library imports in a form ``import X``.
|
||||||
|
5. Standard python library imports in a form ``from X import Y``.
|
||||||
|
6. Third-party (non-python and non-powerline) library imports in a form
|
||||||
|
``import X``.
|
||||||
|
7. Third-party library imports in a form ``from X import Y``.
|
||||||
|
8. Powerline non-test imports in a form ``from powerline.X import Y``.
|
||||||
|
9. Powerline test imports in a form ``import tests.vim as vim_module``.
|
||||||
|
10. Powerline test imports in a form ``from tests.X import Y``.
|
||||||
|
|
||||||
|
Each entry is separated by newline from another entry. Any entry except for
|
||||||
|
the first and third ones is optional. Example with all entries:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
|
||||||
|
'''Powerline super module'''
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
|
import psutil
|
||||||
|
|
||||||
|
from colormath.color_diff import delta_e_cie2000
|
||||||
|
|
||||||
|
from powerline.lib.unicode import u
|
||||||
|
|
||||||
|
import tests.vim as vim_module
|
||||||
|
|
||||||
|
from tests import TestCase
|
||||||
|
|
||||||
|
Submitting changes
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Push your changes to a topic branch in your fork of the repository.
|
||||||
|
* If necessary, use ``git rebase -i <revision>`` to squash or reword commits
|
||||||
|
before submitting a pull request.
|
||||||
|
* Submit a pull request to `Lokaltog's repository
|
||||||
|
<https://github.com/Lokaltog/powerline>`_.
|
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
Copyright 2013 Kim Silkebækken and other contributors
|
||||||
|
https://github.com/Lokaltog/powerline
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
4
MANIFEST.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
recursive-include powerline *.json *.vim
|
||||||
|
recursive-include powerline/bindings *.*
|
||||||
|
recursive-exclude powerline/bindings *.pyc *.pyo
|
||||||
|
recursive-include client *.*
|
95
README.rst
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
Powerline
|
||||||
|
=========
|
||||||
|
|
||||||
|
:Author: Kim Silkebækken (kim.silkebaekken+vim@gmail.com)
|
||||||
|
:Source: https://github.com/Lokaltog/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 and Qtile.**
|
||||||
|
|
||||||
|
* `Support forum`_ (powerline-support@googlegroups.com)
|
||||||
|
* `Development discussion`_ (powerline-dev@googlegroups.com)
|
||||||
|
|
||||||
|
.. image:: https://api.travis-ci.org/Lokaltog/powerline.png?branch=develop
|
||||||
|
:target: `travis-build-status`_
|
||||||
|
:alt: Build status
|
||||||
|
|
||||||
|
.. _travis-build-status: https://travis-ci.org/Lokaltog/powerline
|
||||||
|
.. _`Support forum`: https://groups.google.com/forum/#!forum/powerline-support
|
||||||
|
.. _`Development discussion`: https://groups.google.com/forum/#!forum/powerline-dev
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
* **Extensible and feature rich, written in Python.** Powerline was
|
||||||
|
completely rewritten in Python to get rid of as much vimscript as
|
||||||
|
possible. This has allowed much better extensibility, leaner and better
|
||||||
|
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.
|
||||||
|
* **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
|
||||||
|
bash/zsh and other applications. It's simple to write renderers for any
|
||||||
|
other applications that Powerline doesn't yet support.
|
||||||
|
* **Configuration and colorschemes written in JSON.** JSON is
|
||||||
|
a standardized, simple and easy to use file format that allows for easy
|
||||||
|
user configuration across all of Powerline's supported applications.
|
||||||
|
* **Fast and lightweight, with daemon support for even better performance.**
|
||||||
|
Although the code base spans a couple of thousand lines of code with no
|
||||||
|
goal of "less than X lines of code", the main focus is on good performance
|
||||||
|
and as little code as possible while still providing a rich set of
|
||||||
|
features. The new daemon also ensures that only one Python instance is
|
||||||
|
launched for prompts and statuslines, which provides excellent
|
||||||
|
performance.
|
||||||
|
|
||||||
|
*But I hate Python / I don't need shell prompts / this is just too much
|
||||||
|
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.
|
||||||
|
|
||||||
|
------
|
||||||
|
|
||||||
|
* Consult the `documentation
|
||||||
|
<https://powerline.readthedocs.org/en/latest/>`_ for more information and
|
||||||
|
installation instructions.
|
||||||
|
* Check out `powerline-fonts <https://github.com/Lokaltog/powerline-fonts>`_
|
||||||
|
for pre-patched versions of popular, open source coding fonts.
|
||||||
|
|
||||||
|
Screenshots
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Vim statusline
|
||||||
|
^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
**Mode-dependent highlighting**
|
||||||
|
|
||||||
|
* .. image:: https://raw.github.com/Lokaltog/powerline/develop/docs/source/_static/img/pl-mode-normal.png
|
||||||
|
:alt: Normal mode
|
||||||
|
* .. image:: https://raw.github.com/Lokaltog/powerline/develop/docs/source/_static/img/pl-mode-insert.png
|
||||||
|
:alt: Insert mode
|
||||||
|
* .. image:: https://raw.github.com/Lokaltog/powerline/develop/docs/source/_static/img/pl-mode-visual.png
|
||||||
|
:alt: Visual mode
|
||||||
|
* .. image:: https://raw.github.com/Lokaltog/powerline/develop/docs/source/_static/img/pl-mode-replace.png
|
||||||
|
:alt: Replace mode
|
||||||
|
|
||||||
|
**Automatic truncation of segments in small windows**
|
||||||
|
|
||||||
|
* .. image:: https://raw.github.com/Lokaltog/powerline/develop/docs/source/_static/img/pl-truncate1.png
|
||||||
|
:alt: Truncation illustration
|
||||||
|
* .. image:: https://raw.github.com/Lokaltog/powerline/develop/docs/source/_static/img/pl-truncate2.png
|
||||||
|
:alt: Truncation illustration
|
||||||
|
* .. image:: https://raw.github.com/Lokaltog/powerline/develop/docs/source/_static/img/pl-truncate3.png
|
||||||
|
:alt: Truncation illustration
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
The font in the screenshots is `Pragmata Pro`_ by Fabrizio Schiavi.
|
||||||
|
|
||||||
|
.. _`Pragmata Pro`: http://www.fsd.it/fonts/pragmatapro.htm
|
143
client/powerline.c
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
/* vim:fileencoding=utf-8:noet
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define HANDLE_ERROR(msg) \
|
||||||
|
do { \
|
||||||
|
perror(msg); \
|
||||||
|
exit(EXIT_FAILURE); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define TEMP_FAILURE_RETRY(var, expression) \
|
||||||
|
do { \
|
||||||
|
ptrdiff_t __result; \
|
||||||
|
do { \
|
||||||
|
__result = (expression); \
|
||||||
|
} while (__result == -1L && errno == EINTR); \
|
||||||
|
var = __result; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
extern char **environ;
|
||||||
|
|
||||||
|
void do_write(int sd, const char *raw, size_t len) {
|
||||||
|
size_t written = 0;
|
||||||
|
ptrdiff_t n = -1;
|
||||||
|
|
||||||
|
while (written < len) {
|
||||||
|
TEMP_FAILURE_RETRY(n, write(sd, raw + written, len - written));
|
||||||
|
if (n == -1) {
|
||||||
|
close(sd);
|
||||||
|
HANDLE_ERROR("write() failed");
|
||||||
|
}
|
||||||
|
written += (size_t) n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
# define ADDRESS_TEMPLATE "/tmp/powerline-ipc-%d"
|
||||||
|
# define A
|
||||||
|
#else
|
||||||
|
# define ADDRESS_TEMPLATE "powerline-ipc-%d"
|
||||||
|
# define A +1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ADDRESS_SIZE sizeof(ADDRESS_TEMPLATE) + (sizeof(uid_t) * 4)
|
||||||
|
#define NUM_ARGS_SIZE (sizeof(int) * 2)
|
||||||
|
#define BUF_SIZE 4096
|
||||||
|
#define NEW_ARGV_SIZE 200
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
int sd = -1;
|
||||||
|
int i;
|
||||||
|
ptrdiff_t read_size;
|
||||||
|
struct sockaddr_un server;
|
||||||
|
char address_buf[ADDRESS_SIZE];
|
||||||
|
const char eof[2] = "\0\0";
|
||||||
|
char num_args[NUM_ARGS_SIZE];
|
||||||
|
char buf[BUF_SIZE];
|
||||||
|
char *newargv[NEW_ARGV_SIZE];
|
||||||
|
char *wd = NULL;
|
||||||
|
char **envp;
|
||||||
|
const char *address;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("Must provide at least one argument.\n");
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 3 && strcmp(argv[1], "--socket") == 0) {
|
||||||
|
address = argv[2];
|
||||||
|
argv += 2;
|
||||||
|
argc -= 2;
|
||||||
|
} else {
|
||||||
|
snprintf(address_buf, ADDRESS_SIZE, ADDRESS_TEMPLATE, getuid());
|
||||||
|
address = &(address_buf[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
if (sd == -1)
|
||||||
|
HANDLE_ERROR("socket() failed");
|
||||||
|
|
||||||
|
memset(&server, 0, sizeof(struct sockaddr_un));
|
||||||
|
server.sun_family = AF_UNIX;
|
||||||
|
strncpy(server.sun_path A, address, strlen(address));
|
||||||
|
|
||||||
|
if (connect(sd, (struct sockaddr *) &server, (socklen_t) (sizeof(server.sun_family) + strlen(address) A)) < 0) {
|
||||||
|
close(sd);
|
||||||
|
/* We failed to connect to the daemon, execute powerline instead */
|
||||||
|
argc = (argc < NEW_ARGV_SIZE - 1) ? argc : NEW_ARGV_SIZE - 1;
|
||||||
|
for (i = 1; i < argc; i++)
|
||||||
|
newargv[i] = argv[i];
|
||||||
|
newargv[0] = "powerline-render";
|
||||||
|
newargv[argc] = NULL;
|
||||||
|
execvp("powerline-render", newargv);
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(num_args, NUM_ARGS_SIZE, "%x", argc - 1);
|
||||||
|
do_write(sd, num_args, strlen(num_args));
|
||||||
|
do_write(sd, eof, 1);
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++) {
|
||||||
|
do_write(sd, argv[i], strlen(argv[i]));
|
||||||
|
do_write(sd, eof, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
wd = getcwd(NULL, 0);
|
||||||
|
if (wd != NULL) {
|
||||||
|
do_write(sd, wd, strlen(wd));
|
||||||
|
free(wd);
|
||||||
|
wd = NULL;
|
||||||
|
}
|
||||||
|
do_write(sd, eof, 1);
|
||||||
|
|
||||||
|
for(envp=environ; *envp; envp++) {
|
||||||
|
do_write(sd, *envp, strlen(*envp));
|
||||||
|
do_write(sd, eof, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
do_write(sd, eof, 2);
|
||||||
|
|
||||||
|
read_size = -1;
|
||||||
|
while (read_size != 0) {
|
||||||
|
TEMP_FAILURE_RETRY(read_size, read(sd, buf, BUF_SIZE));
|
||||||
|
if (read_size == -1) {
|
||||||
|
close(sd);
|
||||||
|
HANDLE_ERROR("read() failed");
|
||||||
|
} else if (read_size > 0) {
|
||||||
|
do_write(STDOUT_FILENO, buf, (size_t) read_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(sd);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
99
client/powerline.py
Executable file
@ -0,0 +1,99 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import socket
|
||||||
|
import errno
|
||||||
|
import os
|
||||||
|
|
||||||
|
from locale import getpreferredencoding
|
||||||
|
|
||||||
|
try:
|
||||||
|
from posix import environ
|
||||||
|
except ImportError:
|
||||||
|
from os import environ
|
||||||
|
|
||||||
|
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print('Must provide at least one argument.', file=sys.stderr)
|
||||||
|
raise SystemExit(1)
|
||||||
|
|
||||||
|
platform = sys.platform.lower()
|
||||||
|
use_filesystem = 'darwin' in platform
|
||||||
|
del platform
|
||||||
|
|
||||||
|
if sys.argv[1] == '--socket':
|
||||||
|
address = sys.argv[2]
|
||||||
|
if not use_filesystem:
|
||||||
|
address = '\0' + address
|
||||||
|
del sys.argv[1:3]
|
||||||
|
else:
|
||||||
|
address = ('/tmp/powerline-ipc-%d' if use_filesystem else '\0powerline-ipc-%d') % os.getuid()
|
||||||
|
|
||||||
|
sock = socket.socket(family=socket.AF_UNIX)
|
||||||
|
|
||||||
|
|
||||||
|
def eintr_retry_call(func, *args, **kwargs):
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
except EnvironmentError as e:
|
||||||
|
if getattr(e, 'errno', None) == errno.EINTR:
|
||||||
|
continue
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
eintr_retry_call(sock.connect, address)
|
||||||
|
except Exception:
|
||||||
|
# Run the powerline renderer
|
||||||
|
args = ['powerline-render'] + sys.argv[1:]
|
||||||
|
os.execvp('powerline-render', args)
|
||||||
|
|
||||||
|
fenc = getpreferredencoding() or 'utf-8'
|
||||||
|
|
||||||
|
|
||||||
|
def tobytes(s):
|
||||||
|
if isinstance(s, bytes):
|
||||||
|
return s
|
||||||
|
else:
|
||||||
|
return s.encode(fenc)
|
||||||
|
|
||||||
|
|
||||||
|
args = [tobytes('%x' % (len(sys.argv) - 1))]
|
||||||
|
args.extend((tobytes(s) for s in sys.argv[1:]))
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
cwd = os.getcwd()
|
||||||
|
except EnvironmentError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if not isinstance(cwd, bytes):
|
||||||
|
cwd = cwd.encode(fenc)
|
||||||
|
args.append(cwd)
|
||||||
|
|
||||||
|
|
||||||
|
args.extend((tobytes(k) + b'=' + tobytes(v) for k, v in environ.items()))
|
||||||
|
|
||||||
|
EOF = b'\0\0'
|
||||||
|
|
||||||
|
for a in args:
|
||||||
|
eintr_retry_call(sock.sendall, a + b'\0')
|
||||||
|
|
||||||
|
eintr_retry_call(sock.sendall, EOF)
|
||||||
|
|
||||||
|
received = []
|
||||||
|
while True:
|
||||||
|
r = sock.recv(4096)
|
||||||
|
if not r:
|
||||||
|
break
|
||||||
|
received.append(r)
|
||||||
|
|
||||||
|
sock.close()
|
||||||
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
sys.stdout.write(b''.join(received))
|
||||||
|
else:
|
||||||
|
sys.stdout.buffer.write(b''.join(received))
|
34
client/powerline.sh
Executable file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test "${OSTYPE#darwin}" = "${OSTYPE}" && darwin=n || darwin=y
|
||||||
|
|
||||||
|
if test "$1" = "--socket" ; then
|
||||||
|
shift
|
||||||
|
ADDRESS="$1"
|
||||||
|
shift
|
||||||
|
else
|
||||||
|
ADDRESS="powerline-ipc-${UID:-`id -u`}"
|
||||||
|
test "$darwin" = y && ADDRESS="/tmp/$ADDRESS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "$darwin" = y; then
|
||||||
|
ENV=genv
|
||||||
|
else
|
||||||
|
ENV=env
|
||||||
|
ADDRESS="abstract-client:$ADDRESS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Warning: env -0 does not work in busybox. Consider switching to parsing
|
||||||
|
# `set` output in this case
|
||||||
|
(
|
||||||
|
printf '%x\0' "$#"
|
||||||
|
for argv in "$@" ; do
|
||||||
|
printf '%s\0' "$argv"
|
||||||
|
done
|
||||||
|
printf '%s\0' "$PWD"
|
||||||
|
$ENV -0
|
||||||
|
) | socat -lf/dev/null -t 10 - "$ADDRESS"
|
||||||
|
|
||||||
|
if test $? -ne 0 ; then
|
||||||
|
powerline-render "$@"
|
||||||
|
fi
|
1
docs/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
_build
|
36
docs/Makefile
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Makefile for Sphinx documentation
|
||||||
|
SPHINXOPTS =
|
||||||
|
SPHINXBUILD = sphinx-build2
|
||||||
|
PAPER =
|
||||||
|
BUILDDIR = _build
|
||||||
|
|
||||||
|
# Internal variables
|
||||||
|
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||||
|
PAPEROPT_letter = -D latex_paper_size=letter
|
||||||
|
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
|
||||||
|
|
||||||
|
GH_PAGES_SOURCES = source Makefile
|
||||||
|
GH_SOURCE_BRANCH = develop
|
||||||
|
|
||||||
|
.PHONY: clean html gh-pages
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-rm -rf $(BUILDDIR)/*
|
||||||
|
|
||||||
|
html:
|
||||||
|
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||||
|
@echo
|
||||||
|
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||||
|
|
||||||
|
gh-pages:
|
||||||
|
git checkout gh-pages
|
||||||
|
find .. -maxdepth 1 ! -name '.git*' -and ! -name 'docs' -exec rm -rf {} \;
|
||||||
|
git checkout ${GH_SOURCE_BRANCH} ${GH_PAGES_SOURCES}
|
||||||
|
git reset HEAD
|
||||||
|
make html
|
||||||
|
mv -fv _build/html/* ..
|
||||||
|
rm -rf _build ${GH_PAGES_SOURCES}
|
||||||
|
git add ..
|
||||||
|
git commit -m "Create gh-pages for '`git log develop -1 --pretty=oneline --abbrev-commit`'"
|
||||||
|
git push origin gh-pages
|
||||||
|
git checkout ${GH_SOURCE_BRANCH}
|
BIN
docs/source/_static/img/icons/cross.png
Normal file
After Width: | Height: | Size: 473 B |
BIN
docs/source/_static/img/icons/error.png
Normal file
After Width: | Height: | Size: 543 B |
BIN
docs/source/_static/img/icons/tick.png
Normal file
After Width: | Height: | Size: 451 B |
BIN
docs/source/_static/img/pl-mode-insert.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
docs/source/_static/img/pl-mode-normal.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
docs/source/_static/img/pl-mode-replace.png
Normal file
After Width: | Height: | Size: 6.8 KiB |
BIN
docs/source/_static/img/pl-mode-visual.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
docs/source/_static/img/pl-truncate1.png
Normal file
After Width: | Height: | Size: 6.7 KiB |
BIN
docs/source/_static/img/pl-truncate2.png
Normal file
After Width: | Height: | Size: 5.4 KiB |
BIN
docs/source/_static/img/pl-truncate3.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
31
docs/source/conf.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(os.getcwd()))))
|
||||||
|
sys.path.insert(0, os.path.abspath(os.getcwd()))
|
||||||
|
|
||||||
|
extensions = ['powerline_autodoc', 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.viewcode']
|
||||||
|
source_suffix = '.rst'
|
||||||
|
master_doc = 'index'
|
||||||
|
project = u'Powerline'
|
||||||
|
version = 'beta'
|
||||||
|
release = 'beta'
|
||||||
|
exclude_patterns = ['_build']
|
||||||
|
pygments_style = 'sphinx'
|
||||||
|
html_theme = 'default'
|
||||||
|
html_static_path = ['_static']
|
||||||
|
html_show_copyright = False
|
||||||
|
|
||||||
|
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||||
|
|
||||||
|
if not on_rtd: # only import and set the theme if we're building docs locally
|
||||||
|
try:
|
||||||
|
import sphinx_rtd_theme
|
||||||
|
html_theme = 'sphinx_rtd_theme'
|
||||||
|
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||||
|
except ImportError:
|
||||||
|
pass
|
138
docs/source/configuration.rst
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
*******************************
|
||||||
|
Configuration and customization
|
||||||
|
*******************************
|
||||||
|
|
||||||
|
.. note:: **You DO NOT have to fork the main GitHub repo to personalize your
|
||||||
|
Powerline configuration!** Please read through the :ref:`quick-guide` for
|
||||||
|
a quick introduction to user configuration.
|
||||||
|
|
||||||
|
Powerline is configured with one main configuration file, and with separate
|
||||||
|
configuration files for themes and colorschemes. All configuration files are
|
||||||
|
written in JSON, with the exception of segment definitions, which are
|
||||||
|
written in Python.
|
||||||
|
|
||||||
|
Powerline provides default configurations in the following locations:
|
||||||
|
|
||||||
|
:ref:`Main configuration <config-main>`
|
||||||
|
:file:`powerline/config.json`
|
||||||
|
:ref:`Colorschemes <config-colors>`
|
||||||
|
:file:`powerline/colorschemes/{name}.json`,
|
||||||
|
:file:`powerline/colorscheme/{extension}/__main__.json`,
|
||||||
|
:file:`powerline/colorschemes/{extension}/{name}.json`
|
||||||
|
:ref:`Themes <config-themes>`
|
||||||
|
:file:`powerline/themes/{top_theme}.json`,
|
||||||
|
:file:`powerline/themes/{extension}/__main__.json`,
|
||||||
|
:file:`powerline/themes/{extension}/default.json`
|
||||||
|
|
||||||
|
The default configuration files are stored in the main package. User
|
||||||
|
configuration files are stored in :file:`$XDG_CONFIG_HOME/powerline` for
|
||||||
|
Linux users, and in :file:`~/.config/powerline` for OS X users. This usually
|
||||||
|
corresponds to :file:`~/.config/powerline` on both platforms.
|
||||||
|
|
||||||
|
If you need per-instance configuration please refer to :ref:`Local configuration
|
||||||
|
overrides <local-configuration-overrides>`.
|
||||||
|
|
||||||
|
.. note:: If you have multiple configuration files with the same name in
|
||||||
|
different directories then these files will be merged. Merging happens in
|
||||||
|
the following order:
|
||||||
|
|
||||||
|
* :file:`{powerline_root}/powerline/config_files` is checked for
|
||||||
|
configuration first. Configuration from this source has least priority.
|
||||||
|
* :file:`$XDG_CONFIG_DIRS/powerline` directories are the next ones to check.
|
||||||
|
Checking happens in the reversed order: directories mentioned last are
|
||||||
|
checked before directories mentioned first. Each new found file is merged
|
||||||
|
with the result of previous merge.
|
||||||
|
* :file:`$XDG_CONFIG_HOME/powerline` directory is the last to check.
|
||||||
|
Configuration from there has top priority.
|
||||||
|
|
||||||
|
When merging configuration only dictionaries are merged and they are merged
|
||||||
|
recursively: keys from next file overrule those from the previous unless
|
||||||
|
corresponding values are both dictionaries in which case these dictionaries
|
||||||
|
are merged and key is assigned the result of the merge.
|
||||||
|
|
||||||
|
.. note:: Some configuration files (i.e. themes and colorschemes) have two level
|
||||||
|
of merging: first happens merging described above, second theme- or
|
||||||
|
colorscheme-specific merging happens.
|
||||||
|
|
||||||
|
.. _quick-guide:
|
||||||
|
|
||||||
|
Quick setup guide
|
||||||
|
=================
|
||||||
|
|
||||||
|
This guide will help you with the initial configuration of Powerline.
|
||||||
|
|
||||||
|
Start by copying the entire set of default configuration files to the
|
||||||
|
corresponding path in your user config directory:
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
mkdir ~/.config/powerline
|
||||||
|
cp -R /path/to/powerline/config_files/* ~/.config/powerline
|
||||||
|
|
||||||
|
Each extension (vim, tmux, etc.) has its own theme, and they are located in
|
||||||
|
:file:`{config directory}/themes/{extension}/default.json`.
|
||||||
|
|
||||||
|
If you want to move, remove or customize any of the provided segments, you
|
||||||
|
can do that by updating the segment dictionary in the theme you want to
|
||||||
|
customize. A segment dictionary looks like this:
|
||||||
|
|
||||||
|
.. code-block:: javascript
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "segment_name"
|
||||||
|
...
|
||||||
|
}
|
||||||
|
|
||||||
|
You can move the segment dictionaries around to change the segment
|
||||||
|
positions, or remove the entire dictionary to remove the segment from the
|
||||||
|
prompt or statusline.
|
||||||
|
|
||||||
|
.. note:: It's essential that the contents of all your configuration files
|
||||||
|
is valid JSON! It's strongly recommended that you run your configuration
|
||||||
|
files through ``jsonlint`` after changing them.
|
||||||
|
|
||||||
|
Some segments need a user configuration to work properly. Here's a couple of
|
||||||
|
segments that you may want to customize right away:
|
||||||
|
|
||||||
|
**E-mail alert segment**
|
||||||
|
You have to set your username and password (and possibly server/port)
|
||||||
|
for the e-mail alert segment. If you're using GMail it's recommended
|
||||||
|
that you `generate an application-specific password
|
||||||
|
<https://accounts.google.com/IssuedAuthSubTokens>`_ for this purpose.
|
||||||
|
|
||||||
|
Open a theme file, scroll down to the ``email_imap_alert`` segment and
|
||||||
|
set your ``username`` and ``password``. The server defaults to GMail's
|
||||||
|
IMAP server, but you can set the server/port by adding a ``server`` and
|
||||||
|
a ``port`` argument.
|
||||||
|
**Weather segment**
|
||||||
|
The weather segment will try to find your location using a GeoIP lookup,
|
||||||
|
so unless you're on a VPN you probably won't have to change the location
|
||||||
|
query.
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
.. code-block:: javascript
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "weather",
|
||||||
|
"priority": 50,
|
||||||
|
"args": {
|
||||||
|
"unit": "F",
|
||||||
|
"location_query": "oslo, norway"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
References
|
||||||
|
==========
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:glob:
|
||||||
|
|
||||||
|
configuration/reference
|
||||||
|
configuration/segments
|
||||||
|
configuration/listers
|
||||||
|
configuration/selectors
|
||||||
|
configuration/local
|
25
docs/source/configuration/listers.rst
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
.. _config-listers:
|
||||||
|
|
||||||
|
****************
|
||||||
|
Lister reference
|
||||||
|
****************
|
||||||
|
|
||||||
|
Listers are special segment collections which allow to show some list of
|
||||||
|
segments for each entity in the list of entities (multiply their segments list
|
||||||
|
by a list of entities). E.g. ``powerline.listers.vim.tablister`` presented with
|
||||||
|
``powerline.segments.vim.tabnr`` and ``….file_name`` as segments will emit
|
||||||
|
segments with buffer names and tabpage numbers for each tabpage shown by vim.
|
||||||
|
|
||||||
|
Listers appear in configuration as irregular segments having ``segment_list`` as
|
||||||
|
their type and ``segments`` key with a list of segments (a bit more details in
|
||||||
|
:ref:`Themes section of configuration reference <config-themes-segments>`).
|
||||||
|
|
||||||
|
More information in :ref:`Writing listers <dev-listers>` section.
|
||||||
|
|
||||||
|
Currently only Vim listers are available.
|
||||||
|
|
||||||
|
Vim listers
|
||||||
|
-----------
|
||||||
|
|
||||||
|
.. automodule:: powerline.listers.vim
|
||||||
|
:members:
|
147
docs/source/configuration/local.rst
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
.. _local-configuration-overrides:
|
||||||
|
|
||||||
|
*****************************
|
||||||
|
Local configuration overrides
|
||||||
|
*****************************
|
||||||
|
|
||||||
|
Depending on the application used it is possible to override configuration. Here
|
||||||
|
is the list:
|
||||||
|
|
||||||
|
Vim overrides
|
||||||
|
=============
|
||||||
|
|
||||||
|
Vim configuration can be overridden using the following options:
|
||||||
|
|
||||||
|
``g:powerline_config_overrides``
|
||||||
|
Dictionary, recursively merged with contents of
|
||||||
|
:file:`powerline/config.json`.
|
||||||
|
|
||||||
|
``g:powerline_theme_overrides__{theme_name}``
|
||||||
|
Dictionary, recursively merged with contents of
|
||||||
|
:file:`powerline/themes/vim/{theme_name}.json`. Note that this way you can’t
|
||||||
|
redefine some value (e.g. segment) in list, only the whole list itself: only
|
||||||
|
dictionaries are merged recursively.
|
||||||
|
|
||||||
|
``g:powerline_config_paths``
|
||||||
|
Paths list (each path must be expanded, ``~`` shortcut is not supported).
|
||||||
|
Points to the list of directories which will be searched for configuration.
|
||||||
|
When this option is present, none of the other locations are searched.
|
||||||
|
|
||||||
|
``g:powerline_no_python_error``
|
||||||
|
If this variable is set to a true value it will prevent Powerline from reporting
|
||||||
|
an error when loaded in a copy of vim without the necessary Python support.
|
||||||
|
|
||||||
|
Powerline script overrides
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Powerline script has a number of options controlling powerline behavior. Here
|
||||||
|
``VALUE`` always means “some JSON object”.
|
||||||
|
|
||||||
|
``-c KEY.NESTED_KEY=VALUE`` or ``--config=KEY.NESTED_KEY=VALUE``
|
||||||
|
Overrides options from :file:`powerline/config.json`.
|
||||||
|
``KEY.KEY2.KEY3=VALUE`` is a shortcut for ``KEY={"KEY2": {"KEY3": VALUE}}``.
|
||||||
|
Multiple options (i.e. ``-c K1=V1 -c K2=V2``) are allowed, result (in the
|
||||||
|
example: ``{"K1": V1, "K2": V2}``) is recursively merged with the contents
|
||||||
|
of the file.
|
||||||
|
|
||||||
|
If ``VALUE`` is omitted then corresponding key will be removed from the
|
||||||
|
configuration (if it was present).
|
||||||
|
|
||||||
|
``-t THEME_NAME.KEY.NESTED_KEY=VALUE`` or ``--theme_option=THEME_NAME.KEY.NESTED_KEY=VALUE``
|
||||||
|
Overrides options from :file:`powerline/themes/{ext}/{THEME_NAME}.json`.
|
||||||
|
``KEY.NESTED_KEY=VALUE`` is processed like described above, ``{ext}`` is the
|
||||||
|
first argument to powerline script. May be passed multiple times.
|
||||||
|
|
||||||
|
If ``VALUE`` is omitted then corresponding key will be removed from the
|
||||||
|
configuration (if it was present).
|
||||||
|
|
||||||
|
``-p PATH`` or ``--config_path=PATH``
|
||||||
|
Sets directory where configuration should be read from. If present, no
|
||||||
|
default locations are searched for configuration. No expansions are
|
||||||
|
performed by powerline script itself, but ``-p ~/.powerline`` will likely be
|
||||||
|
expanded by the shell to something like ``-p /home/user/.powerline``.
|
||||||
|
|
||||||
|
Zsh/zpython overrides
|
||||||
|
=====================
|
||||||
|
|
||||||
|
Here overrides are controlled by similarly to the powerline script, but values
|
||||||
|
are taken from zsh variables.
|
||||||
|
|
||||||
|
``POWERLINE_CONFIG``
|
||||||
|
Overrides options from :file:`powerline/config.json`. Should be a zsh
|
||||||
|
associative array with keys equal to ``KEY.NESTED_KEY`` and values being
|
||||||
|
JSON strings. Pair ``KEY.KEY1 VALUE`` is equivalent to ``{"KEY": {"KEY1":
|
||||||
|
VALUE}}``. All pairs are then recursively merged into one dictionary and
|
||||||
|
this dictionary is recursively merged with the contents of the file.
|
||||||
|
|
||||||
|
``POWERLINE_THEME_CONFIG``
|
||||||
|
Overrides options from :file:`powerline/themes/shell/*.json`. Should be
|
||||||
|
a zsh associative array with keys equal to ``THEME_NAME.KEY.NESTED_KEY`` and
|
||||||
|
values being JSON strings. Is processed like the above ``POWERLINE_CONFIG``,
|
||||||
|
but only subdictionaries for ``THEME_NAME`` key are merged with theme
|
||||||
|
configuration when theme with given name is requested.
|
||||||
|
|
||||||
|
``POWERLINE_CONFIG_PATHS``
|
||||||
|
Sets directories where configuration should be read from. If present, no
|
||||||
|
default locations are searched for configuration. No expansions are
|
||||||
|
performed by powerline script itself, but zsh usually performs them on its
|
||||||
|
own if you set variable without quotes: ``POWERLINE_CONFIG_PATHS=( ~/example
|
||||||
|
)``. You should use array parameter or the usual colon-separated
|
||||||
|
``POWERLINE_CONFIG_PATHS=$HOME/path1:$HOME/path2``.
|
||||||
|
|
||||||
|
Ipython overrides
|
||||||
|
=================
|
||||||
|
|
||||||
|
Ipython overrides depend on ipython version. Before ipython-0.11 you should pass
|
||||||
|
additional keyword arguments to setup() function. After ipython-0.11 you should
|
||||||
|
use ``c.Powerline.KEY``. Supported ``KEY`` strings or keyword argument names:
|
||||||
|
|
||||||
|
``config_overrides``
|
||||||
|
Overrides options from :file:`powerline/config.json`. Should be a dictionary
|
||||||
|
that will be recursively merged with the contents of the file.
|
||||||
|
|
||||||
|
``theme_overrides``
|
||||||
|
Overrides options from :file:`powerline/themes/ipython/*.json`. Should be
|
||||||
|
a dictionary where keys are theme names and values are dictionaries which
|
||||||
|
will be recursively merged with the contents of the given theme.
|
||||||
|
|
||||||
|
``paths``
|
||||||
|
Sets directories where configuration should be read from. If present, no
|
||||||
|
default locations are searched for configuration. No expansions are
|
||||||
|
performed thus you cannot use paths starting with ``~/``.
|
||||||
|
|
||||||
|
Prompt command
|
||||||
|
==============
|
||||||
|
|
||||||
|
In addition to the above configuration options you can use
|
||||||
|
``$POWERLINE_COMMAND`` environment variable to tell shell or tmux to use
|
||||||
|
specific powerline implementation and ``$POWERLINE_CONFIG`` to tell zsh or tmux
|
||||||
|
where ``powerline-config`` script is located. This is mostly useful for putting
|
||||||
|
powerline into different directory.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
``$POWERLINE_COMMAND`` appears in shell scripts without quotes thus you can
|
||||||
|
specify additional parameters in bash. In tmux it is passed to ``eval`` and
|
||||||
|
depends on the shell used. POSIX-compatible shells, zsh, bash and fish will
|
||||||
|
split this variable in this case.
|
||||||
|
|
||||||
|
If you want to disable prompt in shell, but still have tmux support or if you
|
||||||
|
want to disable tmux support you can use variables
|
||||||
|
``$POWERLINE_NO_{SHELL}_PROMPT``/``$POWERLINE_NO_SHELL_PROMPT`` and
|
||||||
|
``$POWERLINE_NO_{SHELL}_TMUX_SUPPORT``/``$POWERLINE_NO_SHELL_TMUX_SUPPORT``
|
||||||
|
(substitute ``{SHELL}`` with the name of the shell (all-caps) you want to
|
||||||
|
disable support for (e.g. ``BASH``) or use all-inclusive ``SHELL`` that will
|
||||||
|
disable support for all shells). These variables have no effect after
|
||||||
|
configuration script was sourced (in fish case: after ``powerline-setup``
|
||||||
|
function was run). To disable specific feature support set one of these
|
||||||
|
variables to some non-empty value.
|
||||||
|
|
||||||
|
If you do not want to disable prompt in shell, but yet do not want to launch
|
||||||
|
python twice to get :ref:`above <config-themes-above>` lines you do not use in
|
||||||
|
tcsh you should set ``$POWERLINE_NO_TCSH_ABOVE`` or
|
||||||
|
``$POWERLINE_NO_SHELL_ABOVE`` variable.
|
||||||
|
|
||||||
|
If you do not want to see additional space which is added to the right prompt in
|
||||||
|
fish in order to support multiline prompt you should set
|
||||||
|
``$POWERLINE_NO_FISH_ABOVE`` or ``$POWERLINE_NO_SHELL_ABOVE`` variables.
|
537
docs/source/configuration/reference.rst
Normal file
@ -0,0 +1,537 @@
|
|||||||
|
***********************
|
||||||
|
Configuration reference
|
||||||
|
***********************
|
||||||
|
|
||||||
|
.. _config-main:
|
||||||
|
|
||||||
|
Main configuration
|
||||||
|
==================
|
||||||
|
|
||||||
|
:Location: :file:`powerline/config.json`
|
||||||
|
|
||||||
|
The main configuration file defines some common options that applies to all
|
||||||
|
extensions, as well as some extension-specific options like themes and
|
||||||
|
colorschemes.
|
||||||
|
|
||||||
|
Common configuration
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Common configuration is a subdictionary that is a value of ``common`` key in
|
||||||
|
:file:`powerline/config.json` file.
|
||||||
|
|
||||||
|
.. _config-common-term_truecolor:
|
||||||
|
|
||||||
|
``term_truecolor``
|
||||||
|
Defines whether to output cterm indices (8-bit) or RGB colors (24-bit)
|
||||||
|
to the terminal emulator. See the :ref:`term-feature-support-matrix` for
|
||||||
|
information on whether your terminal emulator supports 24-bit colors.
|
||||||
|
|
||||||
|
.. _config-common-ambiwidth:
|
||||||
|
|
||||||
|
``ambiwidth``
|
||||||
|
Tells powerline what to do with characters with East Asian Width Class
|
||||||
|
Ambigious (such as Euro, Registered Sign, Copyright Sign, Greek
|
||||||
|
letters, Cyrillic letters). Valid values: any positive integer; it is
|
||||||
|
suggested that you only set it to 1 (default) or 2.
|
||||||
|
|
||||||
|
.. _config-common-watcher:
|
||||||
|
|
||||||
|
``watcher``
|
||||||
|
Select filesystem watcher. Variants are
|
||||||
|
|
||||||
|
======= ===================================
|
||||||
|
Variant Description
|
||||||
|
======= ===================================
|
||||||
|
auto Selects most performant watcher.
|
||||||
|
inotify Select inotify watcher. Linux only.
|
||||||
|
stat Select stat-based polling watcher.
|
||||||
|
uv Select libuv-based watcher.
|
||||||
|
======= ===================================
|
||||||
|
|
||||||
|
Default is ``auto``.
|
||||||
|
|
||||||
|
.. _config-common-additional_escapes:
|
||||||
|
|
||||||
|
``additional_escapes``
|
||||||
|
Valid for shell extensions, makes sense only if :ref:`term_truecolor
|
||||||
|
<config-common-term_truecolor>` is enabled. Is to be set from command-line
|
||||||
|
(unless you are sure you always need it). Controls additional escaping that
|
||||||
|
is needed for tmux/screen to work with terminal true color escape codes:
|
||||||
|
normally tmux/screen prevent terminal emulator from receiving these control
|
||||||
|
codes thus rendering powerline prompt colorless. Valid values: ``"tmux"``,
|
||||||
|
``"screen"``, ``null`` (default).
|
||||||
|
|
||||||
|
.. _config-common-paths:
|
||||||
|
|
||||||
|
``paths``
|
||||||
|
Defines additional paths which will be searched for modules when using
|
||||||
|
:ref:`function segment option <config-themes-seg-function>` or :ref:`Vim
|
||||||
|
local_themes option <config-ext-local_themes>`. Paths defined here have
|
||||||
|
priority when searching for modules.
|
||||||
|
|
||||||
|
.. _config-common-log:
|
||||||
|
|
||||||
|
``log_file``
|
||||||
|
Defines path which will hold powerline logs. If not present, logging will be
|
||||||
|
done to stderr.
|
||||||
|
|
||||||
|
``log_level``
|
||||||
|
String, determines logging level. Defaults to ``WARNING``.
|
||||||
|
|
||||||
|
``log_format``
|
||||||
|
String, determines format of the log messages. Defaults to
|
||||||
|
``'%(asctime)s:%(level)s:%(message)s'``.
|
||||||
|
|
||||||
|
``interval``
|
||||||
|
Number, determines time (in seconds) between checks for changed
|
||||||
|
configuration. Checks are done in a seprate thread. Use ``null`` to check
|
||||||
|
for configuration changes on ``.render()`` call in main thread.
|
||||||
|
Defaults to ``None``.
|
||||||
|
|
||||||
|
``reload_config``
|
||||||
|
Boolean, determines whether configuration should be reloaded at all.
|
||||||
|
Defaults to ``True``.
|
||||||
|
|
||||||
|
.. _config-common-default_top_theme:
|
||||||
|
|
||||||
|
``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.
|
||||||
|
|
||||||
|
Extension-specific configuration
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
Common configuration is a subdictionary that is a value of ``ext`` key in
|
||||||
|
:file:`powerline/config.json` file.
|
||||||
|
|
||||||
|
``colorscheme``
|
||||||
|
Defines the colorscheme used for this extension.
|
||||||
|
|
||||||
|
.. _config-ext-theme:
|
||||||
|
|
||||||
|
``theme``
|
||||||
|
Defines the theme used for this extension.
|
||||||
|
|
||||||
|
.. _config-ext-top_theme:
|
||||||
|
|
||||||
|
``top_theme``
|
||||||
|
Defines the top-level theme used for this extension. See `Themes`_ section
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
.. _config-ext-local_themes:
|
||||||
|
|
||||||
|
``local_themes``
|
||||||
|
Defines themes used when certain conditions are met, e.g. for
|
||||||
|
buffer-specific statuslines in vim. Value depends on extension used. For vim
|
||||||
|
it is a dictionary ``{matcher_name : theme_name}``, where ``matcher_name``
|
||||||
|
is either ``matcher_module.module_attribute`` or ``module_attribute``
|
||||||
|
(``matcher_module`` defaults to ``powerline.matchers.vim``) and
|
||||||
|
``module_attribute`` should point to a function that returns boolean value
|
||||||
|
indicating that current buffer has (not) matched conditions. There is an
|
||||||
|
exception for ``matcher_name`` though: if it is ``__tabline__`` no functions
|
||||||
|
are loaded. This special theme is used for ``tabline`` Vim option.
|
||||||
|
|
||||||
|
For shell and ipython it is a simple ``{prompt_type : theme_name}``, where
|
||||||
|
``prompt_type`` is a string with no special meaning (specifically it does
|
||||||
|
not refer to any Python function). Shell has ``continuation``, and
|
||||||
|
``select`` prompts with rather self-explanatory names, IPython has ``in2``,
|
||||||
|
``out`` and ``rewrite`` prompts (refer to IPython documentation for more
|
||||||
|
details) while ``in`` prompt is the default.
|
||||||
|
|
||||||
|
``components``
|
||||||
|
Determines which extension components should be enabled. This key is highly
|
||||||
|
extension-specific, here is the table of extensions and corresponding
|
||||||
|
components:
|
||||||
|
|
||||||
|
+---------+----------+-----------------------------------------------------+
|
||||||
|
|Extension|Component |Description |
|
||||||
|
+---------+----------+-----------------------------------------------------+
|
||||||
|
|vim |statusline|Makes Vim use powerline statusline. |
|
||||||
|
| +----------+-----------------------------------------------------+
|
||||||
|
| |tabline |Makes Vim use powerline tabline. |
|
||||||
|
+---------+----------+-----------------------------------------------------+
|
||||||
|
|shell |prompt |Makes shell display powerline prompt. |
|
||||||
|
| +----------+-----------------------------------------------------+
|
||||||
|
| |tmux |Makes shell report its current working directory |
|
||||||
|
| | |and screen width to tmux for tmux powerline |
|
||||||
|
| | |bindings. |
|
||||||
|
| | | |
|
||||||
|
+---------+----------+-----------------------------------------------------+
|
||||||
|
|
||||||
|
All components are enabled by default.
|
||||||
|
|
||||||
|
.. _config-colors:
|
||||||
|
|
||||||
|
Color definitions
|
||||||
|
=================
|
||||||
|
|
||||||
|
:Location: :file:`powerline/colors.json`
|
||||||
|
|
||||||
|
.. _config-colors-colors:
|
||||||
|
|
||||||
|
``colors``
|
||||||
|
Color definitions, consisting of a dict where the key is the name of the
|
||||||
|
color, and the value is one of the following:
|
||||||
|
|
||||||
|
* A cterm color index.
|
||||||
|
* A list with a cterm color index and a hex color string (e.g. ``[123,
|
||||||
|
"aabbcc"]``). This is useful for colorschemes that use colors that
|
||||||
|
aren't available in color terminals.
|
||||||
|
|
||||||
|
``gradients``
|
||||||
|
Gradient definitions, consisting of a dict where the key is the name of the
|
||||||
|
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 hex color strings.
|
||||||
|
|
||||||
|
It is expected that you define gradients from least alert color to most
|
||||||
|
alert or use non-alert colors.
|
||||||
|
|
||||||
|
.. _config-colorschemes:
|
||||||
|
|
||||||
|
Colorschemes
|
||||||
|
============
|
||||||
|
|
||||||
|
:Location: :file:`powerline/colorschemes/{name}.json`,
|
||||||
|
:file:`powerline/colorschemes/__main__.json`,
|
||||||
|
:file:`powerline/colorschemes/{extension}/{name}.json`
|
||||||
|
|
||||||
|
Colorscheme files are processed in order given: definitions from each next file
|
||||||
|
override those from each previous file. It is required that either
|
||||||
|
:file:`powerline/colorschemes/{name}.json`, or
|
||||||
|
:file:`powerline/colorschemes/{extension}/{name}.json` exists.
|
||||||
|
|
||||||
|
``name``
|
||||||
|
Name of the colorscheme.
|
||||||
|
|
||||||
|
.. _config-colorschemes-groups:
|
||||||
|
|
||||||
|
``groups``
|
||||||
|
Segment highlighting groups, consisting of a dict where the key is the
|
||||||
|
name of the highlighting group (usually the function name for function
|
||||||
|
segments), and the value is either
|
||||||
|
|
||||||
|
#) a dict that defines the foreground color, background color and
|
||||||
|
attributes:
|
||||||
|
|
||||||
|
``fg``
|
||||||
|
Foreground color. Must be defined in :ref:`colors
|
||||||
|
<config-colors-colors>`.
|
||||||
|
|
||||||
|
``bg``
|
||||||
|
Background color. Must be defined in :ref:`colors
|
||||||
|
<config-colors-colors>`.
|
||||||
|
|
||||||
|
``attr``
|
||||||
|
List of attributes. Valid values are one or more of ``bold``,
|
||||||
|
``italic`` and ``underline``. Note that some attributes may be
|
||||||
|
unavailable in some applications or terminal emulators. If you do not
|
||||||
|
need any attributes leave this empty.
|
||||||
|
|
||||||
|
#) a string (an alias): a name of existing group. This group’s definition
|
||||||
|
will be used when this color is requested.
|
||||||
|
|
||||||
|
``mode_translations``
|
||||||
|
Mode-specific highlighting for extensions that support it (e.g. the vim
|
||||||
|
extension). It's an easy way of changing a color in a specific mode.
|
||||||
|
Consists of a dict where the key is the mode and the value is a dict
|
||||||
|
with the following options:
|
||||||
|
|
||||||
|
``colors``
|
||||||
|
A dict where the key is the color to be translated in this mode, and
|
||||||
|
the value is the new color. Both the key and the value must be defined
|
||||||
|
in :ref:`colors <config-colors-colors>`.
|
||||||
|
|
||||||
|
``groups``
|
||||||
|
Segment highlighting groups for this mode. Same syntax as the main
|
||||||
|
:ref:`groups <config-colorschemes-groups>` option.
|
||||||
|
|
||||||
|
.. _config-themes:
|
||||||
|
|
||||||
|
Themes
|
||||||
|
======
|
||||||
|
|
||||||
|
:Location: :file:`powerline/themes/{top_theme}.json`,
|
||||||
|
:file:`powerline/themes/{extension}/__main__.json`,
|
||||||
|
:file:`powerline/themes/{extension}/{name}.json`
|
||||||
|
|
||||||
|
Theme files are processed in order given: definitions from each next file
|
||||||
|
override those from each previous file. It is required that file
|
||||||
|
:file:`powerline/themes/{extension}/{name}.json` exists.
|
||||||
|
|
||||||
|
`{top_theme}` component of the file name is obtained either from :ref:`top_theme
|
||||||
|
extension-specific key <config-ext-top_theme>` or from :ref:`default_top_theme
|
||||||
|
common configuration key <config-common-default_top_theme>`. Powerline ships
|
||||||
|
with the following top themes:
|
||||||
|
|
||||||
|
.. _config-top_themes-list:
|
||||||
|
|
||||||
|
========================== ====================================================
|
||||||
|
Theme Description
|
||||||
|
========================== ====================================================
|
||||||
|
powerline Default powerline theme with fancy powerline 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
|
||||||
|
ascii Theme without any unicode characters at all
|
||||||
|
========================== ====================================================
|
||||||
|
|
||||||
|
``name``
|
||||||
|
Name of the theme.
|
||||||
|
|
||||||
|
.. _config-themes-default_module:
|
||||||
|
|
||||||
|
``default_module``
|
||||||
|
Python module where segments will be looked by default. Defaults to
|
||||||
|
``powerline.segments.{ext}``.
|
||||||
|
|
||||||
|
``spaces``
|
||||||
|
Defines number of spaces just before the divider (on the right side) or just
|
||||||
|
after it (on the left side). These spaces will not be added if divider is
|
||||||
|
not drawn.
|
||||||
|
|
||||||
|
``use_non_breaking_spaces``
|
||||||
|
Determines whether non-breaking spaces should be used in place of the
|
||||||
|
regular ones. This option is needed because regular spaces are not displayed
|
||||||
|
properly when using powerline with some font configuration. Defaults to
|
||||||
|
``True``.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Unlike all other options this one is only checked once at startup using
|
||||||
|
whatever theme is :ref:`the default <config-ext-theme>`. If this option
|
||||||
|
is set in the local themes it will be ignored. This option may also be
|
||||||
|
ignored in some bindings.
|
||||||
|
|
||||||
|
|
||||||
|
``dividers``
|
||||||
|
Defines the dividers used in all Powerline extensions. This option
|
||||||
|
should usually only be changed if you don't have a patched font, or if
|
||||||
|
you use a font patched with the legacy font patcher.
|
||||||
|
|
||||||
|
The ``hard`` dividers are used to divide segments with different
|
||||||
|
background colors, while the ``soft`` dividers are used to divide
|
||||||
|
segments with the same background color.
|
||||||
|
|
||||||
|
.. _config-themes-cursor_space:
|
||||||
|
|
||||||
|
``cursor_space``
|
||||||
|
Space reserved for user input in shell bindings. It is measured in per
|
||||||
|
cents.
|
||||||
|
|
||||||
|
``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-segment_data:
|
||||||
|
|
||||||
|
``segment_data``
|
||||||
|
A dict where keys are segment names or strings ``{module}.{function}``. Used
|
||||||
|
to specify default values for various keys:
|
||||||
|
:ref:`after <config-themes-seg-after>`,
|
||||||
|
:ref:`before <config-themes-seg-before>`,
|
||||||
|
:ref:`contents <config-themes-seg-contents>` (only for string segments
|
||||||
|
if :ref:`name <config-themes-seg-name>` is defined),
|
||||||
|
: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
|
||||||
|
merged with all other values, except that a single ``{module}.{function}``
|
||||||
|
key if found prevents merging all ``{function}`` values.
|
||||||
|
|
||||||
|
When using :ref:`local themes <config-ext-local_themes>` values of these
|
||||||
|
keys are first searched in the segment description, then in ``segment_data``
|
||||||
|
key of a local theme, then in ``segment_data`` key of a :ref:`default theme
|
||||||
|
<config-ext-theme>`. For the :ref:`default theme <config-ext-theme>` itself
|
||||||
|
step 2 is obviously avoided.
|
||||||
|
|
||||||
|
.. note:: Top-level themes are out of equation here: they are merged
|
||||||
|
before the above merging process happens.
|
||||||
|
|
||||||
|
.. _config-themes-segments:
|
||||||
|
|
||||||
|
``segments``
|
||||||
|
A dict with a ``left`` and a ``right`` lists, consisting of segment
|
||||||
|
dictionaries. Shell themes may also contain ``above`` list of dictionaries.
|
||||||
|
Each item in ``above`` list may have ``left`` and ``right`` keys like this
|
||||||
|
dictionary, but no ``above`` key.
|
||||||
|
|
||||||
|
.. _config-themes-above:
|
||||||
|
|
||||||
|
``above`` list is used for multiline shell configurations.
|
||||||
|
|
||||||
|
``left`` and ``right`` lists are used for segments that should be put on the
|
||||||
|
left or right side in the output. Actual mechanizm of putting segments on
|
||||||
|
the left or the right depends on used renderer, but most renderers require
|
||||||
|
one to specify segment with :ref:`width <config-themes-seg-width>` ``auto``
|
||||||
|
on either side to make generated line fill all of the available width.
|
||||||
|
|
||||||
|
Each segment dictionary has the following options:
|
||||||
|
|
||||||
|
.. _config-themes-seg-type:
|
||||||
|
|
||||||
|
``type``
|
||||||
|
The segment type. Can be one of ``function`` (default), ``string`` or
|
||||||
|
``segments_list``:
|
||||||
|
|
||||||
|
``function``
|
||||||
|
The segment contents is the return value of the function defined in
|
||||||
|
the :ref:`function option <config-themes-seg-function>`.
|
||||||
|
|
||||||
|
List of function segments is available in :ref:`Segment reference
|
||||||
|
<config-segments>` section.
|
||||||
|
|
||||||
|
``string``
|
||||||
|
A static string segment where the contents is defined in the
|
||||||
|
:ref:`contents option <config-themes-seg-contents>`, and the
|
||||||
|
highlighting group is defined in the :ref:`highlight_group
|
||||||
|
option <config-themes-seg-highlight_group>`.
|
||||||
|
|
||||||
|
``segments_list``
|
||||||
|
Sub-list of segments. This list only allows :ref:`function
|
||||||
|
<config-themes-seg-function>`, :ref:`segments
|
||||||
|
<config-themes-seg-segments>` and :ref:`args
|
||||||
|
<config-themes-seg-args>` options.
|
||||||
|
|
||||||
|
List of lister segments is available in :ref:`Lister reference
|
||||||
|
<config-listers>` section.
|
||||||
|
|
||||||
|
.. _config-themes-seg-name:
|
||||||
|
|
||||||
|
``name``
|
||||||
|
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
|
||||||
|
either ``{module}.{function_name}`` or ``{function_name}``, whichever
|
||||||
|
will be found first. Function name is taken from :ref:`function key
|
||||||
|
<config-themes-seg-function>`.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
If present prevents ``function`` key from acting as a segment name.
|
||||||
|
|
||||||
|
.. _config-themes-seg-function:
|
||||||
|
|
||||||
|
``function``
|
||||||
|
Function used to get segment contents, in format ``{module}.{function}``
|
||||||
|
or ``{function}``. If ``{module}`` is omitted :ref:`default_module
|
||||||
|
option <config-themes-default_module>` is used.
|
||||||
|
|
||||||
|
.. _config-themes-seg-highlight_group:
|
||||||
|
|
||||||
|
``highlight_group``
|
||||||
|
Highlighting group for this segment. Consists of a prioritized list of
|
||||||
|
highlighting groups, where the first highlighting group that is
|
||||||
|
available in the colorscheme is used.
|
||||||
|
|
||||||
|
Ignored for segments that have ``function`` type.
|
||||||
|
|
||||||
|
.. _config-themes-seg-before:
|
||||||
|
|
||||||
|
``before``
|
||||||
|
A string which will be prepended to the segment contents.
|
||||||
|
|
||||||
|
.. _config-themes-seg-after:
|
||||||
|
|
||||||
|
``after``
|
||||||
|
A string which will be appended to the segment contents.
|
||||||
|
|
||||||
|
.. _config-themes-seg-contents:
|
||||||
|
|
||||||
|
``contents``
|
||||||
|
Segment contents, only required for ``string`` segments.
|
||||||
|
|
||||||
|
.. _config-themes-seg-args:
|
||||||
|
|
||||||
|
``args``
|
||||||
|
A dict of arguments to be passed to a ``function`` segment.
|
||||||
|
|
||||||
|
.. _config-themes-seg-align:
|
||||||
|
|
||||||
|
``align``
|
||||||
|
Aligns the segments contents to the left (``l``), center (``c``) or
|
||||||
|
right (``r``). Has no sense if ``width`` key was not specified or if
|
||||||
|
segment provides its own function for ``auto`` ``width`` handling and
|
||||||
|
does not care about this option.
|
||||||
|
|
||||||
|
.. _config-themes-seg-width:
|
||||||
|
|
||||||
|
``width``
|
||||||
|
Enforces a specific width for this segment.
|
||||||
|
|
||||||
|
This segment will work as a spacer if the width is set to ``auto``.
|
||||||
|
Several spacers may be used, and the space will be distributed
|
||||||
|
equally among all the spacer segments. Spacers may have contents,
|
||||||
|
either returned by a function or a static string, and the contents
|
||||||
|
can be aligned with the ``align`` property.
|
||||||
|
|
||||||
|
.. _config-themes-seg-priority:
|
||||||
|
|
||||||
|
``priority``
|
||||||
|
Optional segment priority. Segments with priority ``None`` (the default
|
||||||
|
priority, represented by ``null`` in json) will always be included,
|
||||||
|
regardless of the width of the prompt/statusline.
|
||||||
|
|
||||||
|
If the priority is any number, the segment may be removed if the
|
||||||
|
prompt/statusline width is too small for all the segments to be
|
||||||
|
rendered. A lower number means that the segment has a higher priority.
|
||||||
|
|
||||||
|
Segments are removed according to their priority, with low priority
|
||||||
|
segments being removed first.
|
||||||
|
|
||||||
|
.. _config-themes-seg-draw_divider:
|
||||||
|
|
||||||
|
``draw_hard_divider``, ``draw_soft_divider``
|
||||||
|
Whether to draw a divider between this and the adjacent segment. The
|
||||||
|
adjacent segment is to the *right* for segments on the *left* side, and
|
||||||
|
vice versa. Hard dividers are used between segments with different
|
||||||
|
background colors, soft ones are used between segments with same
|
||||||
|
background. Both options default to ``True``.
|
||||||
|
|
||||||
|
.. _config-themes-seg-draw_inner_divider:
|
||||||
|
|
||||||
|
``draw_inner_divider``
|
||||||
|
Determines whether inner soft dividers are to be drawn for function
|
||||||
|
segments. Only applicable for functions returning multiple segments.
|
||||||
|
Defaults to ``False``.
|
||||||
|
|
||||||
|
.. _config-themes-seg-exclude_modes:
|
||||||
|
|
||||||
|
``exclude_modes``, ``include_modes``
|
||||||
|
A list of modes where this segment will be excluded: the segment is not
|
||||||
|
included or is included in all modes, *except* for the modes in one of
|
||||||
|
these lists respectively. If ``exclude_modes`` is not present then it
|
||||||
|
acts like an empty list (segment is not excluded from any modes).
|
||||||
|
Without ``include_modes`` it acts like a list with all possible modes
|
||||||
|
(segment is included in all modes). When there are both
|
||||||
|
``exclude_modes`` overrides ``include_modes``.
|
||||||
|
|
||||||
|
.. _config-themes-seg-exclude_function:
|
||||||
|
|
||||||
|
``exclude_function``, ``include_function``
|
||||||
|
Function name in a form ``{name}`` or ``{module}.{name}`` (in the first
|
||||||
|
form ``{module}`` defaults to ``powerline.selectors.{ext}``). Determines
|
||||||
|
under which condition specific segment will be included or excluded. By
|
||||||
|
default segment is always included and never excluded.
|
||||||
|
``exclude_function`` overrides ``include_function``.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Options :ref:`exclude_/include_modes
|
||||||
|
<config-themes-seg-exclude_modes>` complement
|
||||||
|
``exclude_/include_functions``: segment will be included if it is
|
||||||
|
included by either ``include_mode`` or ``include_function`` and will
|
||||||
|
be excluded if it is excluded by either ``exclude_mode`` or
|
||||||
|
``exclude_function``.
|
||||||
|
|
||||||
|
.. _config-themes-seg-display:
|
||||||
|
|
||||||
|
``display``
|
||||||
|
Boolean. If false disables displaying of the segment.
|
||||||
|
Defaults to ``True``.
|
||||||
|
|
||||||
|
.. _config-themes-seg-segments:
|
||||||
|
|
||||||
|
``segments``
|
||||||
|
A list of subsegments.
|
28
docs/source/configuration/segments.rst
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
.. _config-segments:
|
||||||
|
|
||||||
|
*****************
|
||||||
|
Segment reference
|
||||||
|
*****************
|
||||||
|
|
||||||
|
Segments
|
||||||
|
========
|
||||||
|
|
||||||
|
Segments are written in Python, and the default segments provided with
|
||||||
|
Powerline are located in :file:`powerline/segments/{extension}.py`.
|
||||||
|
User-defined segments can be defined in any module in ``sys.path`` or
|
||||||
|
:ref:`paths common configuration option <config-common-paths>`, import is
|
||||||
|
always absolute.
|
||||||
|
|
||||||
|
Segments are regular Python functions, and they may accept arguments. All
|
||||||
|
arguments should have a default value which will be used for themes that
|
||||||
|
don't provide an ``args`` dict.
|
||||||
|
|
||||||
|
More information is available in :ref:`Writing segments <dev-segments>` section.
|
||||||
|
|
||||||
|
Available segments
|
||||||
|
==================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:glob:
|
||||||
|
|
||||||
|
segments/*
|
6
docs/source/configuration/segments/common.rst
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
***************
|
||||||
|
Common segments
|
||||||
|
***************
|
||||||
|
|
||||||
|
.. automodule:: powerline.segments.common
|
||||||
|
:members:
|
6
docs/source/configuration/segments/shell.rst
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
**************
|
||||||
|
Shell segments
|
||||||
|
**************
|
||||||
|
|
||||||
|
.. automodule:: powerline.segments.shell
|
||||||
|
:members:
|
6
docs/source/configuration/segments/tmux.rst
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
*************
|
||||||
|
Tmux segments
|
||||||
|
*************
|
||||||
|
|
||||||
|
.. automodule:: powerline.segments.tmux
|
||||||
|
:members:
|
34
docs/source/configuration/segments/vim.rst
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
************
|
||||||
|
Vim segments
|
||||||
|
************
|
||||||
|
|
||||||
|
.. automodule:: powerline.segments.vim
|
||||||
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
Plugin-specific segments
|
||||||
|
========================
|
||||||
|
|
||||||
|
Syntastic segments
|
||||||
|
------------------
|
||||||
|
|
||||||
|
.. automodule:: powerline.segments.vim.plugin.syntastic
|
||||||
|
:members:
|
||||||
|
|
||||||
|
Ctrl-P segments
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: powerline.segments.vim.plugin.ctrlp
|
||||||
|
:members:
|
||||||
|
|
||||||
|
Tagbar segments
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: powerline.segments.vim.plugin.tagbar
|
||||||
|
:members:
|
||||||
|
|
||||||
|
NERDTree segments
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
.. automodule:: powerline.segments.vim.plugin.nerdtree
|
||||||
|
:members:
|
17
docs/source/configuration/selectors.rst
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
.. _config-selectors:
|
||||||
|
|
||||||
|
******************
|
||||||
|
Selector functions
|
||||||
|
******************
|
||||||
|
|
||||||
|
Selector functions are functions that return ``True`` or ``False`` depending on
|
||||||
|
application state. They are used for :ref:`exclude_function and include_function
|
||||||
|
segment options <config-themes-seg-exclude_function>`.
|
||||||
|
|
||||||
|
Available selectors
|
||||||
|
===================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:glob:
|
||||||
|
|
||||||
|
selectors/*
|
6
docs/source/configuration/selectors/vim.rst
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
*************
|
||||||
|
Vim selectors
|
||||||
|
*************
|
||||||
|
|
||||||
|
.. automodule:: powerline.selectors.vim
|
||||||
|
:members:
|
13
docs/source/develop.rst
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
***************
|
||||||
|
Developer guide
|
||||||
|
***************
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 2
|
||||||
|
:glob:
|
||||||
|
|
||||||
|
develop/segments
|
||||||
|
develop/listers
|
||||||
|
develop/local-themes
|
||||||
|
develop/extensions
|
||||||
|
develop/tips-and-tricks
|
47
docs/source/develop/extensions.rst
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
********************************
|
||||||
|
Creating new powerline extension
|
||||||
|
********************************
|
||||||
|
|
||||||
|
Powerline extension is a code that tells powerline how to highlight and display
|
||||||
|
segments in some set of applications. Specifically this means
|
||||||
|
|
||||||
|
#. Creating a :py:class:`powerline.Powerline` subclass that knows how to obtain
|
||||||
|
:ref:`local configuration overrides <local-configuration-overrides>`. It also
|
||||||
|
knows how to load local themes, but not when to apply them.
|
||||||
|
|
||||||
|
Instance of this class is the only instance that interacts directly with
|
||||||
|
bindings code, so it has a proxy :py:meth:`powerline.Powerline.render` and
|
||||||
|
:py:meth:`powerline.Powerline.shutdown` methods and other methods which may
|
||||||
|
be useful for bindings.
|
||||||
|
|
||||||
|
This subclass must be placed directly in :file:`powerline` directory (e.g. in
|
||||||
|
:file:`powerline/vim.py`) and named like ``VimPowerline`` (version of the
|
||||||
|
file name without directory and extension and first capital letter
|
||||||
|
+ ``Powerline``). There is no technical reason for naming classes like this.
|
||||||
|
#. Creating a :py:class:`powerline.renderer.Renderer` subclass that knows how to
|
||||||
|
highlight a segment or reset highlighting to the default value (only makes
|
||||||
|
sense in prompts). It is also responsible for selecting local themes and
|
||||||
|
computing text width.
|
||||||
|
|
||||||
|
This subclass must be placed directly in :file:`powerline/renderers`
|
||||||
|
directory (if you are creating powerline extension for a set of applications
|
||||||
|
use :file:`powerline/renderers/{ext}/*.py`) and named like ``ExtRenderer`` or
|
||||||
|
``AppPromptRenderer``. For technical reasons the class itself must be
|
||||||
|
referenced in ``renderer`` module attribute thus allowing only one renderer
|
||||||
|
per one module.
|
||||||
|
#. Creating an extension bindings. These are to be placed in
|
||||||
|
:file:`powerline/bindings/{ext}` and may contain virtually anything which may
|
||||||
|
be required for powerline to work inside given applications, assuming it does
|
||||||
|
not fit in other places.
|
||||||
|
|
||||||
|
Powerline class
|
||||||
|
===============
|
||||||
|
|
||||||
|
.. autoclass:: powerline.Powerline
|
||||||
|
:members:
|
||||||
|
|
||||||
|
Renderer class
|
||||||
|
==============
|
||||||
|
|
||||||
|
.. autoclass:: powerline.renderer.Renderer
|
||||||
|
:members:
|
49
docs/source/develop/listers.rst
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
.. _dev-listers:
|
||||||
|
|
||||||
|
***************
|
||||||
|
Writing listers
|
||||||
|
***************
|
||||||
|
|
||||||
|
Listers allow you to show some segments multiple times: once per each entity
|
||||||
|
(buffer, tabpage, etc) lister knows. They are functions which receive the
|
||||||
|
following arguments:
|
||||||
|
|
||||||
|
``pl``
|
||||||
|
A :py:class:`powerline.PowerlineLogger` class instance. It must be used for
|
||||||
|
logging.
|
||||||
|
|
||||||
|
``segment_info``
|
||||||
|
Base segment info dictionary. Lister function or class must have
|
||||||
|
``powerline_requires_segment_info`` to receive this argument.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
Listers are close to useless if they do not have access to this
|
||||||
|
argument.
|
||||||
|
|
||||||
|
Refer to :ref:`segment_info detailed description <dev-segments-info>` for
|
||||||
|
further details.
|
||||||
|
|
||||||
|
``draw_inner_divider``
|
||||||
|
If False (default) soft dividers between segments in the listed group will
|
||||||
|
not be drawn regardless of actual segment settings. If True they will be
|
||||||
|
drawn, again regardless of actual segment settings. Set it to ``None`` in
|
||||||
|
order to respect segment settings.
|
||||||
|
|
||||||
|
And also any other argument(s) specified by user in :ref:`args key
|
||||||
|
<config-themes-seg-args>` (no additional arguments by default).
|
||||||
|
|
||||||
|
Listers must return a sequence of pairs. First item in the pair must contain
|
||||||
|
a ``segment_info`` dictionary specific to one of the listed entities.
|
||||||
|
|
||||||
|
Second item must contain another dictionary: it will be used to modify the
|
||||||
|
resulting segment. In addition to :ref:`usual keys that describe segment
|
||||||
|
<dev-segments-segment>` the following keys may be present (it is advised that
|
||||||
|
*only* the following keys will be used):
|
||||||
|
|
||||||
|
``priority_multiplier``
|
||||||
|
Value (usually a ``float``) used to multiply segment priority. It is useful
|
||||||
|
for finer-grained controlling which segments disappear first: e.g. when
|
||||||
|
listing tab pages make first disappear directory names of the tabpages which
|
||||||
|
are most far away from current tabpage, then (when all directory names
|
||||||
|
disappeared) buffer names. Check out existing listers implementation in
|
||||||
|
:file:`powerline/listers/vim.py`.
|
59
docs/source/develop/local-themes.rst
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
************
|
||||||
|
Local themes
|
||||||
|
************
|
||||||
|
|
||||||
|
From the user point of view local themes are the regular themes with a specific
|
||||||
|
scope where they are applied (i.e. specific vim window or specific kind of
|
||||||
|
prompt). Used themes are defined in :ref:`local_themes key
|
||||||
|
<config-ext-local_themes>`.
|
||||||
|
|
||||||
|
Vim local themes
|
||||||
|
================
|
||||||
|
|
||||||
|
Vim is the only available extension that has a wide variaty of options for local
|
||||||
|
themes. It is the only extension where local theme key refers to a function as
|
||||||
|
described in :ref:`local_themes value documentation <config-ext-local_themes>`.
|
||||||
|
|
||||||
|
This function always takes a single value named ``matcher_info`` which is the
|
||||||
|
same dictionary as :ref:`segment_info dictionary <dev-segment_info-vim>`. Unlike
|
||||||
|
segments it takes this single argument as a *positional* argument, not as
|
||||||
|
a keyword one.
|
||||||
|
|
||||||
|
Matcher function should return a boolean value: ``True`` if theme applies for
|
||||||
|
the given ``matcher_info`` dictionary or ``False`` if it is not. When one of the
|
||||||
|
matcher functions returns ``True`` powerline takes the corresponding theme at
|
||||||
|
uses it for the given window. Matchers are not tested in any particular order.
|
||||||
|
|
||||||
|
In addition to :ref:`local_themes configuration key <config-ext-local_themes>`
|
||||||
|
developer of some plugin which wishes to support powerline without including his
|
||||||
|
code in powerline tree may use
|
||||||
|
:py:meth:`powerline.vim.VimPowerline.add_local_theme` method. It accepts two
|
||||||
|
arguments: matcher name (same as in :ref:`local_themes
|
||||||
|
<config-ext-local_themes>`) and dictionary with theme. This dictionary is merged
|
||||||
|
with :ref:`top theme <config-ext-top_theme>` and
|
||||||
|
:file:`powerline/themes/vim/__main__.json`. Note that if user already specified
|
||||||
|
your matcher in his configuration file ``KeyError`` is raised.
|
||||||
|
|
||||||
|
Other local themes
|
||||||
|
==================
|
||||||
|
|
||||||
|
Except for Vim only IPython and shells have local themes. Unlike Vim these
|
||||||
|
themes are names with no special meaning (they do not refer to or cause loading
|
||||||
|
of any Python functions):
|
||||||
|
|
||||||
|
+---------+------------+-------------------------------------------------------+
|
||||||
|
|Extension|Theme name |Description |
|
||||||
|
+---------+------------+-------------------------------------------------------+
|
||||||
|
|Shell |continuation|Shown for unfinished command (unclosed quote, |
|
||||||
|
| | |unfinished cycle). |
|
||||||
|
| +------------+-------------------------------------------------------+
|
||||||
|
| |select |Shown for ``select`` command available in some shells. |
|
||||||
|
+---------+------------+-------------------------------------------------------+
|
||||||
|
|IPython |in2 |Continuation prompt: shown for unfinished (multiline) |
|
||||||
|
| | |expression, unfinished class or function definition. |
|
||||||
|
| +------------+-------------------------------------------------------+
|
||||||
|
| |out |Displayed before the result. |
|
||||||
|
| +------------+-------------------------------------------------------+
|
||||||
|
| |rewrite |Displayed before the actually executed code when |
|
||||||
|
| | |``autorewrite`` IPython feature is enabled. |
|
||||||
|
+---------+------------+-------------------------------------------------------+
|
451
docs/source/develop/segments.rst
Normal file
@ -0,0 +1,451 @@
|
|||||||
|
.. _dev-segments:
|
||||||
|
|
||||||
|
****************
|
||||||
|
Writing segments
|
||||||
|
****************
|
||||||
|
|
||||||
|
Each powerline segment is a callable object. It is supposed to be either
|
||||||
|
a Python function or :py:class:`powerline.segments.Segment` class. As a callable
|
||||||
|
object it should receive the following arguments:
|
||||||
|
|
||||||
|
.. note:: All received arguments are keyword arguments.
|
||||||
|
|
||||||
|
``pl``
|
||||||
|
A :py:class:`powerline.PowerlineLogger` instance. It must be used every time
|
||||||
|
you need to log something.
|
||||||
|
|
||||||
|
``segment_info``
|
||||||
|
A dictionary. It is only received if callable has
|
||||||
|
``powerline_requires_segment_info`` attribute.
|
||||||
|
|
||||||
|
Refer to :ref:`segment_info detailed description <dev-segments-info>` for
|
||||||
|
further details.
|
||||||
|
|
||||||
|
``create_watcher``
|
||||||
|
Function that will create filesystem watcher once called. Which watcher will
|
||||||
|
be created exactly is controlled by :ref:`watcher configuration option
|
||||||
|
<config-common-watcher>`.
|
||||||
|
|
||||||
|
And also any other argument(s) specified by user in :ref:`args key
|
||||||
|
<config-themes-seg-args>` (no additional arguments by default).
|
||||||
|
|
||||||
|
Object representing segment may have the following attributes used by
|
||||||
|
powerline:
|
||||||
|
|
||||||
|
``powerline_requires_segment_info``
|
||||||
|
This attribute controls whether segment will receive ``segment_info``
|
||||||
|
argument: if it is present argument will be received.
|
||||||
|
|
||||||
|
``powerline_requires_filesystem_watcher``
|
||||||
|
This attribute controls whether segment will receive ``create_watcher``
|
||||||
|
argument: if it is present argument will be received.
|
||||||
|
|
||||||
|
``powerline_segment_datas``
|
||||||
|
This attribute must be a dictionary containing ``top_theme: segment_data``
|
||||||
|
mapping where ``top_theme`` is any theme name (it is expected that all of
|
||||||
|
the names from :ref:`top-level themes list <config-top_themes-list>` are
|
||||||
|
present) and ``segment_data`` is a dictionary like the one that is contained
|
||||||
|
inside :ref:`segment_data dictionary in configuration
|
||||||
|
<config-themes-segment_data>`. This attribute should be used to specify
|
||||||
|
default theme-specific values for *third-party* segments: powerline
|
||||||
|
theme-specific values go directly to :ref:`top-level themes
|
||||||
|
<config-themes>`.
|
||||||
|
|
||||||
|
.. _dev-segments-startup:
|
||||||
|
|
||||||
|
``startup``
|
||||||
|
This attribute must be a callable which accepts the following keyword
|
||||||
|
arguments:
|
||||||
|
|
||||||
|
* ``pl``: :py:class:`powerline.PowerlineLogger` instance which is to be used
|
||||||
|
for logging.
|
||||||
|
* ``shutdown_event``: :py:class:`Event` object which will be set when
|
||||||
|
powerline will be shut down.
|
||||||
|
* Any arguments found in user configuration for the given segment (i.e.
|
||||||
|
:ref:`args key <config-themes-seg-args>`).
|
||||||
|
|
||||||
|
This function is called at powerline startup when using long-running
|
||||||
|
processes (e.g. powerline in vim, in zsh with libzpython, in ipython or in
|
||||||
|
powerline daemon) and not called when ``powerline-render`` executable is
|
||||||
|
used (more specific: when :py:class:`powerline.Powerline` constructor
|
||||||
|
received true ``run_once`` argument).
|
||||||
|
|
||||||
|
.. _dev-segments-shutdown:
|
||||||
|
|
||||||
|
``shutdown``
|
||||||
|
This attribute must be a callable that accepts no arguments and shuts down
|
||||||
|
threads and frees any other resources allocated in ``startup`` method of the
|
||||||
|
segment in question.
|
||||||
|
|
||||||
|
This function is not called when ``startup`` method is not called.
|
||||||
|
|
||||||
|
.. _dev-segments-expand:
|
||||||
|
|
||||||
|
``expand``
|
||||||
|
This attribute must be a callable that accepts the following keyword
|
||||||
|
arguments:
|
||||||
|
|
||||||
|
* ``pl``: :py:class:`powerline.PowerlineLogger` instance which is to be used
|
||||||
|
for logging.
|
||||||
|
* ``amount``: integer number representing amount of display cells result
|
||||||
|
must occupy.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
“Amount of display cells” is *not* number of Unicode codepoints, string
|
||||||
|
length, or byte count. It is suggested that your function should look
|
||||||
|
something like ``return (' ' * amount) + segment['contents']`` where
|
||||||
|
``' '`` may be replaced with anything that is known to occupy exactly
|
||||||
|
one display cell.
|
||||||
|
* ``segment``: :ref:`segment dictionary <dev-segments-segment>`.
|
||||||
|
* Any arguments found in user configuration for the given segment (i.e.
|
||||||
|
:ref:`args key <config-themes-seg-args>`).
|
||||||
|
|
||||||
|
It must return new value of :ref:`contents <dev-segments-seg-contents>` key.
|
||||||
|
|
||||||
|
.. _dev-segments-truncate:
|
||||||
|
|
||||||
|
``truncate``
|
||||||
|
Like :ref:`expand function <dev-segments-expand>`, but for truncating
|
||||||
|
segments. Here ``amount`` means the number of display cells which must be
|
||||||
|
freed.
|
||||||
|
|
||||||
|
This function is called for all segments before powerline starts purging
|
||||||
|
them to free space.
|
||||||
|
|
||||||
|
This callable object should may return either a string (``unicode`` in Python2
|
||||||
|
or ``str`` in Python3, *not* ``str`` in Python2 or ``bytes`` in Python3) object
|
||||||
|
or a list of dictionaries. String object is a short form of the following return
|
||||||
|
value:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
[{
|
||||||
|
'contents': original_return,
|
||||||
|
'highlight_group': [segment_name],
|
||||||
|
}]
|
||||||
|
|
||||||
|
.. _dev-segments-return:
|
||||||
|
|
||||||
|
Returned list is a list of segments treated independently, except for
|
||||||
|
:ref:`draw_inner_divider key <dev-segments-draw_inner_divider>`.
|
||||||
|
|
||||||
|
All keys in segments returned by the function override those obtained from
|
||||||
|
:ref:`configuration <config-themes-segments>` and have the same meaning.
|
||||||
|
|
||||||
|
Detailed description of used dictionary keys:
|
||||||
|
|
||||||
|
``contents``
|
||||||
|
Text displayed by segment. Should be a ``unicode`` (Python2) or ``str``
|
||||||
|
(Python3) instance.
|
||||||
|
|
||||||
|
.. _dev-segments-draw_inner_divider:
|
||||||
|
|
||||||
|
``draw_hard_divider``, ``draw_soft_divider``, ``draw_inner_divider``
|
||||||
|
Determines whether given divider should be drawn. All have the same meaning
|
||||||
|
as :ref:`the similar keys in configuration <config-themes-seg-draw_divider>`
|
||||||
|
(:ref:`draw_inner_divider <config-themes-seg-draw_inner_divider>`).
|
||||||
|
|
||||||
|
.. _dev-segments-highlight_group:
|
||||||
|
|
||||||
|
``highlight_group``
|
||||||
|
Determines segment highlighting. Refer to :ref:`themes documentation
|
||||||
|
<config-themes-seg-highlight_group>` for more details.
|
||||||
|
|
||||||
|
Defaults to the name of the segment.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
If you want to include your segment in powerline you must specify all
|
||||||
|
highlighting groups used in the segment documentation in the form::
|
||||||
|
|
||||||
|
Highlight groups used: ``g1``[ or ``g2``]*[, ``g3`` (gradient)[ or ``g4``]*]*.
|
||||||
|
|
||||||
|
I.e. use::
|
||||||
|
|
||||||
|
Highlight groups used: ``foo_gradient`` (gradient) or ``foo``, ``bar``.
|
||||||
|
|
||||||
|
to specify that your segment uses *either* ``foo_gradient`` group or
|
||||||
|
``foo`` group *and* ``bar`` group meaning that ``powerline-lint`` will
|
||||||
|
check that at least one of the first two groups is defined (and if
|
||||||
|
``foo_gradient`` is defined it must use at least one gradient color) and
|
||||||
|
third group is defined as well.
|
||||||
|
|
||||||
|
You must specify all groups on one line.
|
||||||
|
|
||||||
|
``divider_highlight_group``
|
||||||
|
Determines segment divider highlight group. Only applicable for soft
|
||||||
|
dividers: colors for hard dividers are determined by colors of adjacent
|
||||||
|
segments.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
If you want to include your segment in powerline you must specify used
|
||||||
|
groups in the segment documentation in the form::
|
||||||
|
|
||||||
|
Divider highlight group used: ``group``.
|
||||||
|
|
||||||
|
This text must not wrap and you are supposed to end all divider
|
||||||
|
highlight group names with ``:divider``: e.g. ``cwd:divider``.
|
||||||
|
|
||||||
|
``gradient_level``
|
||||||
|
First and the only key that may not be specified in user configuration. It
|
||||||
|
determines which color should be used for this segment when one of the
|
||||||
|
highlighting groups specified by :ref:`highlight_group
|
||||||
|
<dev-segments-highlight_group>` was defined to use the color gradient.
|
||||||
|
|
||||||
|
This key may have any value from 0 to 100 inclusive, value is supposed to be
|
||||||
|
an ``int`` or ``float`` instance.
|
||||||
|
|
||||||
|
No error occurs if segment has this key, but no used highlight groups use
|
||||||
|
gradient color.
|
||||||
|
|
||||||
|
``_*``
|
||||||
|
Keys starting with underscore are reserved for powerline and must not be
|
||||||
|
returned.
|
||||||
|
|
||||||
|
``__*``
|
||||||
|
Keys starting with two underscores are reserved for the segment functions,
|
||||||
|
specifically for :ref:`expand function <dev-segments-expand>`.
|
||||||
|
|
||||||
|
.. _dev-segments-segment:
|
||||||
|
|
||||||
|
Segment dictionary
|
||||||
|
==================
|
||||||
|
|
||||||
|
Segment dictionary contains the following keys:
|
||||||
|
|
||||||
|
* All keys returned by segment function (if it was used).
|
||||||
|
|
||||||
|
* All of the following keys:
|
||||||
|
|
||||||
|
``name``
|
||||||
|
Segment name: value of the :ref:`name key <config-themes-seg-name>` or
|
||||||
|
function name (last component of the :ref:`function key
|
||||||
|
<config-themes-seg-function>`). May be ``None``.
|
||||||
|
|
||||||
|
``type``
|
||||||
|
:ref:`Segment type <config-themes-seg-type>`. Always represents actual type
|
||||||
|
and is never ``None``.
|
||||||
|
|
||||||
|
``highlight_group``, ``divider_highlight_group``
|
||||||
|
Used highlight groups. May be ``None``.
|
||||||
|
|
||||||
|
``highlight_group_prefix``
|
||||||
|
If this key is present then given prefix will be prepended to each highlight
|
||||||
|
group (both regular and divider) used by this segment in a form
|
||||||
|
``{prefix}:{group}`` (note the colon). This key is mostly useful for
|
||||||
|
:ref:`segment listers <dev-listers>`.
|
||||||
|
|
||||||
|
.. _dev-segments-seg-around:
|
||||||
|
|
||||||
|
``before``, ``after``
|
||||||
|
Value of :ref:`before <config-themes-seg-before>` or :ref:`after
|
||||||
|
<config-themes-seg-after>` configuration options. May be ``None`` as well as
|
||||||
|
an empty string.
|
||||||
|
|
||||||
|
``contents_func``
|
||||||
|
Function used to get segment contents. May be ``None``.
|
||||||
|
|
||||||
|
.. _dev-segments-seg-contents:
|
||||||
|
|
||||||
|
``contents``
|
||||||
|
Actual segment contents, excluding dividers and :ref:`before/after
|
||||||
|
<dev-segments-seg-around>`. May be ``None``.
|
||||||
|
|
||||||
|
``priority``
|
||||||
|
:ref:`Segment priority <config-themes-seg-priority>`. May be ``None`` for no
|
||||||
|
priority (such segments are always shown).
|
||||||
|
|
||||||
|
``draw_soft_divider``, ``draw_hard_divider``, ``draw_inner_divider``
|
||||||
|
:ref:`Divider control flags <dev-segments-draw_inner_divider>`.
|
||||||
|
|
||||||
|
``side``
|
||||||
|
Segment side: ``right`` or ``left``.
|
||||||
|
|
||||||
|
``display_condition```
|
||||||
|
Contains function that takes three position parameters:
|
||||||
|
:py:class:`powerline.PowerlineLogger` instance, :ref:`segment_info
|
||||||
|
<dev-segments-info>` dictionary and current mode and returns either ``True``
|
||||||
|
or ``False`` to indicate whether particular segment should be processed.
|
||||||
|
|
||||||
|
This key is constructed based on :ref:`exclude_/include_modes keys
|
||||||
|
<config-themes-seg-exclude_modes>` and :ref:`exclude_/include_function keys
|
||||||
|
<config-themes-seg-exclude_function>`.
|
||||||
|
|
||||||
|
``width``, ``align``
|
||||||
|
:ref:`Width and align options <config-themes-seg-align>`. May be ``None``.
|
||||||
|
|
||||||
|
``expand``, ``truncate``
|
||||||
|
Partially applied :ref:`expand <dev-segments-expand>` or :ref:`truncate
|
||||||
|
<dev-segments-truncate>` function. Accepts ``pl``, ``amount`` and
|
||||||
|
``segment`` positional parameters, keyword parameters from :ref:`args
|
||||||
|
<config-themes-seg-args>` key were applied.
|
||||||
|
|
||||||
|
``startup``
|
||||||
|
Partially applied :ref:`startup function <dev-segments-startup>`. Accepts
|
||||||
|
``pl`` and ``shutdown_event`` positional parameters, keyword parameters from
|
||||||
|
:ref:`args <config-themes-seg-args>` key were applied.
|
||||||
|
|
||||||
|
``shutdown``
|
||||||
|
:ref:`Shutdown function <dev-segments-shutdown>`. Accepts no argument.
|
||||||
|
|
||||||
|
Segments layout
|
||||||
|
===============
|
||||||
|
|
||||||
|
Powerline segments are all located in one of the ``powerline.segments``
|
||||||
|
submodules. For extension-specific segments ``powerline.segments.{ext}`` module
|
||||||
|
should be used (e.g. ``powerline.segments.shell``), for extension-agnostic there
|
||||||
|
is ``powerline.segments.common``.
|
||||||
|
|
||||||
|
Plugin-specific segments (currently only those that are specific to vim plugins)
|
||||||
|
should live in ``powerline.segments.{ext}.plugin.{plugin_name}``: e.g.
|
||||||
|
``powerline.segments.vim.plugin.gundo``.
|
||||||
|
|
||||||
|
.. _dev-segments-info:
|
||||||
|
|
||||||
|
Segment information used in various extensions
|
||||||
|
==============================================
|
||||||
|
|
||||||
|
Each ``segment_info`` value should be a dictionary with at least the following
|
||||||
|
keys:
|
||||||
|
|
||||||
|
``environ``
|
||||||
|
Current environment, may be an alias to ``os.environ``. Is guaranteed to
|
||||||
|
have ``__getitem__`` and ``get`` methods and nothing more.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
You must not ever use ``os.environ``. If your segment is run in daemon
|
||||||
|
you will get daemon’s environment which is not correct. If your segment
|
||||||
|
is run in Vim or in zsh with libzpython you will get Vim or zsh
|
||||||
|
environment at python startup.
|
||||||
|
|
||||||
|
``getcwd``
|
||||||
|
Function that returns current working directory being called with no
|
||||||
|
arguments. You must not use ``os.getcwd`` for the same reasons you must not
|
||||||
|
use ``os.environ``, except that current working directory is valid in Vim
|
||||||
|
and zsh (but not in daemon).
|
||||||
|
|
||||||
|
``home``
|
||||||
|
Current home directory. May be false.
|
||||||
|
|
||||||
|
.. _dev-segment_info-vim:
|
||||||
|
|
||||||
|
Vim
|
||||||
|
---
|
||||||
|
|
||||||
|
Vim ``segment_info`` argument is a dictionary with the following keys:
|
||||||
|
|
||||||
|
``window``
|
||||||
|
``vim.Window`` object. You may obtain one using ``vim.current.window`` or
|
||||||
|
``vim.windows[number - 1]``. May be a false object, in which case you should
|
||||||
|
not use any of this objects’ properties.
|
||||||
|
|
||||||
|
``winnr``
|
||||||
|
Window number. Same as ``segment_info['window'].number`` *assuming* Vim is
|
||||||
|
new enough for ``vim.Window`` object to have ``number`` attribute.
|
||||||
|
|
||||||
|
``window_id``
|
||||||
|
Internal powerline window id, unique for each newly created window. You
|
||||||
|
should assume that this ID is hashable and supports equality comparison, but
|
||||||
|
you must not use any other assumptions about it. Currently uses integer
|
||||||
|
numbers incremented each time window is created.
|
||||||
|
|
||||||
|
``buffer``
|
||||||
|
``vim.Buffer`` object. You may obtain one using ``vim.current.buffer``,
|
||||||
|
``segment_info['window'].buffer`` or ``vim.buffers[some_number]``. Note that
|
||||||
|
in the latter case depending on vim version ``some_number`` may be ``bufnr``
|
||||||
|
or the internal Vim buffer index which is *not* buffer number. For this
|
||||||
|
reason to get ``vim.Buffer`` object other then stored in ``segment_info``
|
||||||
|
dictionary you must iterate over ``vim.buffers`` and check their ``number``
|
||||||
|
attributes.
|
||||||
|
|
||||||
|
``bufnr``
|
||||||
|
Buffer number.
|
||||||
|
|
||||||
|
``tabpage``
|
||||||
|
``vim.Tabpage`` object. You may obtain one using ``vim.current.tabpage`` or
|
||||||
|
``vim.tabpages[number - 1]``. May be a false object, in which case you
|
||||||
|
should not use any of this objects’ properties.
|
||||||
|
|
||||||
|
``tabnr``
|
||||||
|
Tabpage number.
|
||||||
|
|
||||||
|
``mode``
|
||||||
|
Current mode.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Your segment generally should not assume that it is run for the current
|
||||||
|
window, current buffer or current tabpage. “Current window” and “current
|
||||||
|
buffer” restrictions may be ignored if you use ``window_cached`` decorator,
|
||||||
|
“current tabpage” restriction may be safely ignored if you do not plan to
|
||||||
|
ever see your segment in the tabline.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
Powerline is being tested with vim-7.2 and will be tested with it until
|
||||||
|
travis changes used vim version. This means that you may not use most of the
|
||||||
|
functionality like ``vim.Window.number``, ``vim.*.vars``, ``vim.*.options``
|
||||||
|
or even ``dir(vim object)`` if you want your segment to be included in
|
||||||
|
powerline.
|
||||||
|
|
||||||
|
Shell
|
||||||
|
-----
|
||||||
|
|
||||||
|
``args``
|
||||||
|
Parsed shell arguments: a ``argparse.Namespace`` object. Check out
|
||||||
|
``powerline-render --help`` for the list of all available arguments.
|
||||||
|
Currently it is expected to contain at least the following attributes:
|
||||||
|
|
||||||
|
``last_exit_code``
|
||||||
|
Exit code returned by last shell command.
|
||||||
|
|
||||||
|
``last_pipe_status``
|
||||||
|
List of exit codes returned by last programs in the pipe or some false
|
||||||
|
object. Only available in ``zsh``.
|
||||||
|
|
||||||
|
``jobnum``
|
||||||
|
Number of background jobs.
|
||||||
|
|
||||||
|
``renderer_arg``
|
||||||
|
Dictionary containing some keys that are additional arguments used by
|
||||||
|
shell bindings. *You must not use this attribute directly*: all
|
||||||
|
arguments from this dictionary are merged with ``segment_info``
|
||||||
|
dictionary. Known to have at least the following keys:
|
||||||
|
|
||||||
|
``client_id``
|
||||||
|
Identifier unique to one shell instance. Is used to record instance
|
||||||
|
state by powerline daemon.
|
||||||
|
|
||||||
|
It is not guaranteed that existing client ID will not be retaken
|
||||||
|
when old shell with this ID quit: usually process PID is used as
|
||||||
|
a client ID.
|
||||||
|
|
||||||
|
It is also not guaranteed that client ID will be process PID, number
|
||||||
|
or something else at all. It is guaranteed though that client ID
|
||||||
|
will be some hashable object which supports equality comparison.
|
||||||
|
|
||||||
|
``local_theme``
|
||||||
|
Local theme that will be used by shell. One should not rely on the
|
||||||
|
existence of this key.
|
||||||
|
|
||||||
|
Other keys, if any, are specific to segments.
|
||||||
|
|
||||||
|
Ipython
|
||||||
|
-------
|
||||||
|
|
||||||
|
``ipython``
|
||||||
|
Some object which has ``prompt_count`` attribute. Currently it is guaranteed
|
||||||
|
to have only this attribute.
|
||||||
|
|
||||||
|
Attribute ``prompt_count`` contains the so-called “history count”
|
||||||
|
(equivalent to ``\N`` in ``in_template``).
|
||||||
|
|
||||||
|
Segment class
|
||||||
|
=============
|
||||||
|
|
||||||
|
.. autoclass:: powerline.segments.Segment
|
||||||
|
:members:
|
||||||
|
|
||||||
|
PowerlineLogger class
|
||||||
|
=====================
|
||||||
|
|
||||||
|
.. autoclass:: powerline.PowerlineLogger
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
21
docs/source/develop/tips-and-tricks.rst
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
****************************************
|
||||||
|
Tips and tricks for powerline developers
|
||||||
|
****************************************
|
||||||
|
|
||||||
|
Profiling powerline in Vim
|
||||||
|
==========================
|
||||||
|
|
||||||
|
Given that current directory is the root of the powerline repository the
|
||||||
|
following command may be used:
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
vim --cmd 'let g:powerline_pyeval="powerline#debug#profile_pyeval"' \
|
||||||
|
--cmd 'set rtp=powerline/bindings/vim' \
|
||||||
|
-c 'runtime! plugin/powerline.vim' \
|
||||||
|
{other arguments if needed}
|
||||||
|
|
||||||
|
After some time run ``:WriteProfiling {filename}`` Vim command. Currently this
|
||||||
|
only works with recent Vim and python-2*. It should be easy to modify
|
||||||
|
:file:`powerline/bindings/vim/autoload/powerline/debug.vim` to suit other
|
||||||
|
needs.
|
23
docs/source/index.rst
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
*********
|
||||||
|
Powerline
|
||||||
|
*********
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 3
|
||||||
|
:glob:
|
||||||
|
|
||||||
|
overview
|
||||||
|
installation
|
||||||
|
usage
|
||||||
|
configuration
|
||||||
|
develop
|
||||||
|
troubleshooting
|
||||||
|
tips-and-tricks
|
||||||
|
license-and-credits
|
||||||
|
|
||||||
|
Indices and tables
|
||||||
|
==================
|
||||||
|
|
||||||
|
* :ref:`genindex`
|
||||||
|
* :ref:`modindex`
|
||||||
|
* :ref:`search`
|
107
docs/source/installation.rst
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
************
|
||||||
|
Installation
|
||||||
|
************
|
||||||
|
|
||||||
|
Generic requirements
|
||||||
|
====================
|
||||||
|
|
||||||
|
* Python 2.6 or later, 3.2 or later, PyPy 2.0 or later. It is the only
|
||||||
|
non-optional requirement.
|
||||||
|
* C compiler. Required to build powerline client on linux. If it is not present
|
||||||
|
then powerline will fall back to shell script or python client.
|
||||||
|
* ``socat`` program. Required for shell variant of client which runs a bit
|
||||||
|
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.
|
||||||
|
* ``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-py``, `available on github <https://github.com/ziberna/i3-py>`_. Required
|
||||||
|
for i3wm bindings and segments.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Until mercurial and bazaar support Python-3 or PyPy powerline will not
|
||||||
|
support repository information when running in these interpreters.
|
||||||
|
|
||||||
|
Pip installation
|
||||||
|
================
|
||||||
|
|
||||||
|
This project is currently unavailable from PyPI due to a naming conflict with an
|
||||||
|
unrelated project, thus you will have to use the following command to install
|
||||||
|
powerline with ``pip``:
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
pip install --user git+git://github.com/Lokaltog/powerline
|
||||||
|
|
||||||
|
. You may also choose to clone powerline repository somewhere and use
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
pip install -e --user {path_to_powerline}
|
||||||
|
|
||||||
|
, but note that in this case ``pip`` will not install ``powerline`` executable
|
||||||
|
and you will have to do something like
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
ln -s {path_to_powerline}/scripts/powerline ~/.local/bin
|
||||||
|
|
||||||
|
(:file:`~/.local/bin` should be replaced with some path present in ``$PATH``).
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
If your ISP blocks git protocol for some reason github also provides ``ssh``
|
||||||
|
(``git+ssh://git@github.com/Lokaltog/powerline``) and ``https``
|
||||||
|
(``git+https://github.com/Lokaltog/powerline``) protocols. ``git`` protocol
|
||||||
|
should be the fastest, but least secure one though.
|
||||||
|
|
||||||
|
To install release version uploaded to PyPI use
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
pip install powerline-status
|
||||||
|
|
||||||
|
Fonts installation
|
||||||
|
==================
|
||||||
|
|
||||||
|
Powerline uses several special glyphs to get the arrow effect and some custom
|
||||||
|
symbols for developers. This requires that you either have a symbol font or
|
||||||
|
a patched font on your system. Your terminal emulator must also support either
|
||||||
|
patched fonts or fontconfig for Powerline to work properly.
|
||||||
|
|
||||||
|
You can also enable :ref:`24-bit color support <config-common-term_truecolor>`
|
||||||
|
if your terminal emulator supports it (see :ref:`the terminal emulator support
|
||||||
|
matrix <usage-terminal-emulators>`).
|
||||||
|
|
||||||
|
There are basically two ways to get powerline glyphs displayed: use
|
||||||
|
:file:`PowerlineSymbols.otf` font as a fallback for one of the existing fonts or
|
||||||
|
install a patched font.
|
||||||
|
|
||||||
|
.. _installation-patched-fonts:
|
||||||
|
|
||||||
|
Patched fonts
|
||||||
|
-------------
|
||||||
|
|
||||||
|
This method is the fallback method and works for every terminal, with the
|
||||||
|
exception of :ref:`rxvt-unicode <tips-and-tricks-urxvt>`.
|
||||||
|
|
||||||
|
Download the font of your choice from `powerline-fonts`_. If you can't find
|
||||||
|
your preferred font in the `powerline-fonts`_ repo, you'll have to patch your
|
||||||
|
own font instead.
|
||||||
|
|
||||||
|
.. _powerline-fonts: https://github.com/Lokaltog/powerline-fonts
|
||||||
|
|
||||||
|
After downloading this font refer to platform-specific instructions.
|
||||||
|
|
||||||
|
Installation on various platforms
|
||||||
|
=================================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
|
||||||
|
Linux <installation/linux>
|
||||||
|
OS X <installation/osx>
|
95
docs/source/installation/linux.rst
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
*********************
|
||||||
|
Installation on Linux
|
||||||
|
*********************
|
||||||
|
|
||||||
|
The following distribution-specific packages are officially supported, and they
|
||||||
|
provide an easy way of installing and upgrading Powerline. The packages will
|
||||||
|
automatically do most of the configuration for you.
|
||||||
|
|
||||||
|
* `Arch Linux (AUR), Python 2 version <https://aur.archlinux.org/packages/python2-powerline-git/>`_
|
||||||
|
* `Arch Linux (AUR), Python 3 version <https://aur.archlinux.org/packages/python-powerline-git/>`_
|
||||||
|
* Gentoo Live ebuild in `raiagent <https://github.com/leycec/raiagent>`_ overlay
|
||||||
|
|
||||||
|
If you're running a distribution without an official package you'll have to
|
||||||
|
follow the installation guide below:
|
||||||
|
|
||||||
|
1. Install Python 3.2+ or Python 2.6+ with ``pip``. This step is
|
||||||
|
distribution-specific, so no commands provided.
|
||||||
|
2. Install Powerline using the following command::
|
||||||
|
|
||||||
|
pip install --user git+git://github.com/Lokaltog/powerline
|
||||||
|
|
||||||
|
.. note:: You need to use the GitHub URI when installing Powerline! This
|
||||||
|
project is currently unavailable on the PyPI due to a naming conflict
|
||||||
|
with an unrelated project.
|
||||||
|
|
||||||
|
.. note:: If you are powerline developer you should be aware that ``pip install
|
||||||
|
--editable`` does not currently fully work. If you
|
||||||
|
install powerline this way you will be missing ``powerline`` executable and
|
||||||
|
need to symlink it. It will be located in ``scripts/powerline``.
|
||||||
|
|
||||||
|
Fonts installation
|
||||||
|
==================
|
||||||
|
|
||||||
|
Fontconfig
|
||||||
|
----------
|
||||||
|
|
||||||
|
This method only works on Linux. It's the recommended method if your
|
||||||
|
terminal emulator supports it as you don't have to patch any fonts, and it
|
||||||
|
generally works well with any coding font.
|
||||||
|
|
||||||
|
#. Download the latest version of the symbol font and fontconfig file::
|
||||||
|
|
||||||
|
wget https://github.com/Lokaltog/powerline/raw/develop/font/PowerlineSymbols.otf
|
||||||
|
wget https://github.com/Lokaltog/powerline/raw/develop/font/10-powerline-symbols.conf
|
||||||
|
|
||||||
|
#. Move the symbol font to a valid X font path. Valid font paths can be
|
||||||
|
listed with ``xset q``::
|
||||||
|
|
||||||
|
mv PowerlineSymbols.otf ~/.fonts/
|
||||||
|
|
||||||
|
#. Update font cache for the path you moved the font to (you may need to be
|
||||||
|
root to update the cache for system-wide paths)::
|
||||||
|
|
||||||
|
fc-cache -vf ~/.fonts/
|
||||||
|
|
||||||
|
#. Install the fontconfig file. For newer versions of fontconfig the config
|
||||||
|
path is ``~/.config/fontconfig/conf.d/``, for older versions it's
|
||||||
|
``~/.fonts.conf.d/``::
|
||||||
|
|
||||||
|
mv 10-powerline-symbols.conf ~/.config/fontconfig/conf.d/
|
||||||
|
|
||||||
|
If you can't see the custom symbols, please close all instances of your
|
||||||
|
terminal emulator. You may need to restart X for the changes to take
|
||||||
|
effect.
|
||||||
|
|
||||||
|
If you *still* can't see the custom symbols, double-check that you have
|
||||||
|
installed the font to a valid X font path, and that you have installed the
|
||||||
|
fontconfig file to a valid fontconfig path. Alternatively try to install
|
||||||
|
a :ref:`patched font <installation-patched-fonts>`.
|
||||||
|
|
||||||
|
Patched font installation
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
After downloading font you should do the following:
|
||||||
|
|
||||||
|
#. Move the patched font to a valid X font path. Valid font paths can be
|
||||||
|
listed with ``xset q``::
|
||||||
|
|
||||||
|
mv 'MyFont for Powerline.otf' ~/.fonts/
|
||||||
|
|
||||||
|
#. Update font cache for the path you moved the font to (you may need to be
|
||||||
|
root to update the cache for system-wide paths)::
|
||||||
|
|
||||||
|
fc-cache -vf ~/.fonts/
|
||||||
|
|
||||||
|
After installing the patched font you need to update Gvim or your terminal
|
||||||
|
emulator to use the patched font. The correct font usually ends with *for
|
||||||
|
Powerline*.
|
||||||
|
|
||||||
|
If you can't see the custom symbols, please close all instances of your
|
||||||
|
terminal emulator. You may need to restart X for the changes to take
|
||||||
|
effect.
|
||||||
|
|
||||||
|
If you *still* can't see the custom symbols, double-check that you have
|
||||||
|
installed the font to a valid X font path.
|
60
docs/source/installation/osx.rst
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
********************
|
||||||
|
Installation on OS X
|
||||||
|
********************
|
||||||
|
|
||||||
|
Python package
|
||||||
|
==============
|
||||||
|
|
||||||
|
1. Install a proper Python version (see `issue #39
|
||||||
|
<https://github.com/Lokaltog/powerline/issues/39>`_ for a discussion
|
||||||
|
regarding the required Python version on OS X)::
|
||||||
|
|
||||||
|
sudo port select python python27-apple
|
||||||
|
|
||||||
|
. You may use homebrew for this::
|
||||||
|
|
||||||
|
brew install python
|
||||||
|
|
||||||
|
.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
In case you want or have to use ``powerline.sh`` socat-based client you
|
||||||
|
should also install GNU env named ``genv``. This may be achieved by
|
||||||
|
running ``brew install coreutils``.
|
||||||
|
|
||||||
|
2. Install Powerline using the following command::
|
||||||
|
|
||||||
|
pip install --user git+git://github.com/Lokaltog/powerline
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
When using ``brew install`` to install Python one must not supply
|
||||||
|
``--user`` flag to ``pip``.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
You need to use the GitHub URI when installing Powerline! This project is
|
||||||
|
currently unavailable on the PyPI due to a naming conflict with an
|
||||||
|
unrelated project.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
If you are powerline developer you should be aware that ``pip install
|
||||||
|
--editable`` does not currently fully work. If you install powerline this
|
||||||
|
way you will be missing ``powerline`` executable and need to symlink it. It
|
||||||
|
will be located in ``scripts/powerline``.
|
||||||
|
|
||||||
|
Vim installation
|
||||||
|
================
|
||||||
|
|
||||||
|
Any terminal vim version with Python 3.2+ or Python 2.6+ support should work,
|
||||||
|
but if you're using MacVim you need to install it using the following command::
|
||||||
|
|
||||||
|
brew install macvim --env-std --override-system-vim
|
||||||
|
|
||||||
|
Fonts installation
|
||||||
|
==================
|
||||||
|
|
||||||
|
Install downloaded patched font by double-clicking the font file in Finder, then
|
||||||
|
clicking :guilabel:`Install this font` in the preview window.
|
||||||
|
|
||||||
|
After installing the patched font you need to update MacVim or your terminal
|
||||||
|
emulator to use the patched font. The correct font usually ends with *for
|
||||||
|
Powerline*.
|
23
docs/source/license-and-credits.rst
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
*******************
|
||||||
|
License and credits
|
||||||
|
*******************
|
||||||
|
|
||||||
|
Powerline is licensed under the `MIT license
|
||||||
|
<https://raw.github.com/Lokaltog/powerline/develop/LICENSE>`_.
|
||||||
|
|
||||||
|
Authors
|
||||||
|
-------
|
||||||
|
|
||||||
|
* `Kim Silkebækken <https://github.com/Lokaltog>`_
|
||||||
|
* `Nikolay Pavlov <https://github.com/ZyX-I>`_
|
||||||
|
* `Kovid Goyal <https://github.com/kovidgoyal>`_
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
|
||||||
|
* `List of contributors
|
||||||
|
<https://github.com/Lokaltog/powerline/contributors>`_
|
||||||
|
* The glyphs in the font patcher are created by Fabrizio Schiavi, creator of
|
||||||
|
the excellent coding font `Pragmata Pro`_.
|
||||||
|
|
||||||
|
.. _`Pragmata Pro`: http://www.fsd.it/fonts/pragmatapro.htm
|
67
docs/source/overview.rst
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
********
|
||||||
|
Overview
|
||||||
|
********
|
||||||
|
|
||||||
|
**Powerline is a statusline plugin for vim, and provides statuslines and
|
||||||
|
prompts for several other applications, including zsh, bash, tmux, IPython,
|
||||||
|
Awesome and Qtile.**
|
||||||
|
|
||||||
|
Features
|
||||||
|
--------
|
||||||
|
|
||||||
|
* **Extensible and feature rich, written in Python.** Powerline was
|
||||||
|
completely rewritten in Python to get rid of as much vimscript as
|
||||||
|
possible. This has allowed much better extensibility, leaner and better
|
||||||
|
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.
|
||||||
|
* **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
|
||||||
|
bash/zsh and other applications. It's simple to write renderers for any
|
||||||
|
other applications that Powerline doesn't yet support.
|
||||||
|
* **Configuration and colorschemes written in JSON.** JSON is
|
||||||
|
a standardized, simple and easy to use file format that allows for easy
|
||||||
|
user configuration across all of Powerline's supported applications.
|
||||||
|
* **Fast and lightweight, with daemon support for even better performance.**
|
||||||
|
Although the code base spans a couple of thousand lines of code with no
|
||||||
|
goal of "less than X lines of code", the main focus is on good performance
|
||||||
|
and as little code as possible while still providing a rich set of
|
||||||
|
features. The new daemon also ensures that only one Python instance is
|
||||||
|
launched for prompts and statuslines, which provides excellent
|
||||||
|
performance.
|
||||||
|
|
||||||
|
*But I hate Python / I don't need shell prompts / this is just too much
|
||||||
|
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.
|
||||||
|
|
||||||
|
Screenshots
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Vim statusline
|
||||||
|
^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
**Mode-dependent highlighting**
|
||||||
|
|
||||||
|
* .. image:: _static/img/pl-mode-normal.png
|
||||||
|
:alt: Normal mode
|
||||||
|
* .. image:: _static/img/pl-mode-insert.png
|
||||||
|
:alt: Insert mode
|
||||||
|
* .. image:: _static/img/pl-mode-visual.png
|
||||||
|
:alt: Visual mode
|
||||||
|
* .. image:: _static/img/pl-mode-replace.png
|
||||||
|
:alt: Replace mode
|
||||||
|
|
||||||
|
**Automatic truncation of segments in small windows**
|
||||||
|
|
||||||
|
* .. image:: _static/img/pl-truncate1.png
|
||||||
|
:alt: Truncation illustration
|
||||||
|
* .. image:: _static/img/pl-truncate2.png
|
||||||
|
:alt: Truncation illustration
|
||||||
|
* .. image:: _static/img/pl-truncate3.png
|
||||||
|
:alt: Truncation illustration
|
34
docs/source/powerline_autodoc.py
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
from inspect import formatargspec
|
||||||
|
|
||||||
|
from sphinx.ext import autodoc
|
||||||
|
|
||||||
|
from powerline.lint.inspect import getconfigargspec
|
||||||
|
from powerline.segments import Segment
|
||||||
|
from powerline.lib.unicode import unicode
|
||||||
|
|
||||||
|
|
||||||
|
def formatvalue(val):
|
||||||
|
if type(val) is str:
|
||||||
|
return '="' + unicode(val, 'utf-8').replace('"', '\\"').replace('\\', '\\\\') + '"'
|
||||||
|
else:
|
||||||
|
return '=' + repr(val)
|
||||||
|
|
||||||
|
|
||||||
|
class ThreadedDocumenter(autodoc.FunctionDocumenter):
|
||||||
|
'''Specialized documenter subclass for ThreadedSegment subclasses.'''
|
||||||
|
@classmethod
|
||||||
|
def can_document_member(cls, member, membername, isattr, parent):
|
||||||
|
return (isinstance(member, Segment) or
|
||||||
|
super(ThreadedDocumenter, cls).can_document_member(member, membername, isattr, parent))
|
||||||
|
|
||||||
|
def format_args(self):
|
||||||
|
argspec = getconfigargspec(self.object)
|
||||||
|
return formatargspec(*argspec, formatvalue=formatvalue).replace('\\', '\\\\')
|
||||||
|
|
||||||
|
|
||||||
|
def setup(app):
|
||||||
|
autodoc.setup(app)
|
||||||
|
app.add_autodocumenter(ThreadedDocumenter)
|
94
docs/source/tips-and-tricks.rst
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
***************
|
||||||
|
Tips and tricks
|
||||||
|
***************
|
||||||
|
|
||||||
|
Vim
|
||||||
|
===
|
||||||
|
|
||||||
|
Useful settings
|
||||||
|
---------------
|
||||||
|
|
||||||
|
You may find the following vim settings useful when using the Powerline
|
||||||
|
statusline:
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
set laststatus=2 " Always display the statusline in all windows
|
||||||
|
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-urxvt:
|
||||||
|
|
||||||
|
Rxvt-unicode
|
||||||
|
============
|
||||||
|
|
||||||
|
Terminus font and urxvt
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
The Terminus fonts does not have the powerline glyphs and unless someone submits
|
||||||
|
a patch to the font author, it is unlikely to happen. However, Andre Klärner
|
||||||
|
came up with this work around: In your ``~/.Xdefault`` file add the following::
|
||||||
|
|
||||||
|
urxvt*font: xft:Terminus:pixelsize=12,xft:Inconsolata\ for\ Powerline:pixelsize=12
|
||||||
|
|
||||||
|
This will allow urxvt to fallback onto the Inconsolata fonts in case it does not
|
||||||
|
find the right glyphs within the terminus font.
|
||||||
|
|
||||||
|
Source Code Pro font and urxvt
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
Much like the terminus font that was mentioned above, a similar fix can be
|
||||||
|
applied to the Source Code Pro fonts.
|
||||||
|
|
||||||
|
In the ``~/.Xdefaults`` add the following::
|
||||||
|
|
||||||
|
URxvt*font: xft:Source\ Code\ Pro\ Medium:pixelsize=13:antialias=true:hinting=true,xft:Source\ Code\ Pro\ Medium:pixelsize=13:antialias=true:hinting=true
|
||||||
|
|
||||||
|
I noticed that Source Code Pro has the glyphs there already, but the pixel size
|
||||||
|
of the fonts play a role in whether or not the > or the < separators showing up
|
||||||
|
or not. Using font size 12, glyphs on the right hand side of the powerline are
|
||||||
|
present, but the ones on the left don't. Pixel size 14, brings the reverse
|
||||||
|
problem. Font size 13 seems to work just fine.
|
||||||
|
|
||||||
|
Reloading powerline after update
|
||||||
|
================================
|
||||||
|
|
||||||
|
Once you have updated powerline you generally have the following options:
|
||||||
|
|
||||||
|
#. Restart the application you are using it in. This is the safest one. Will not
|
||||||
|
work if the application uses ``powerline-daemon``.
|
||||||
|
#. For shell and tmux bindings (except for zsh with libzpython): do not do
|
||||||
|
anything if you do not use ``powerline-daemon``, run ``powerline-daemon
|
||||||
|
--replace`` if you do.
|
||||||
|
#. Use powerline reloading feature.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
This feature is an unsafe one. It is not guaranteed to work always, it may
|
||||||
|
render your Python constantly error out in place of displaying powerline
|
||||||
|
and sometimes may render your application useless, forcing you to
|
||||||
|
restart.
|
||||||
|
|
||||||
|
*Do not report any bugs occurred when using this feature unless you know
|
||||||
|
both what caused it and how this can be fixed.*
|
||||||
|
|
||||||
|
* When using zsh with libzpython use
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
powerline-reload
|
||||||
|
|
||||||
|
.. note:: This shell function is only defined when using libzpython.
|
||||||
|
|
||||||
|
* When using IPython use
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
%powerline reload
|
||||||
|
|
||||||
|
* When using Vim use
|
||||||
|
|
||||||
|
.. code-block:: Vim
|
||||||
|
|
||||||
|
py powerline.reload()
|
||||||
|
" or (depending on Python version you are using)
|
||||||
|
py3 powerline.reload()
|
244
docs/source/troubleshooting.rst
Normal file
@ -0,0 +1,244 @@
|
|||||||
|
***************
|
||||||
|
Troubleshooting
|
||||||
|
***************
|
||||||
|
|
||||||
|
System-specific issues
|
||||||
|
======================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
|
||||||
|
Linux <troubleshooting/linux>
|
||||||
|
OS X <troubleshooting/osx>
|
||||||
|
|
||||||
|
Common issues
|
||||||
|
=============
|
||||||
|
|
||||||
|
I'm using tmux and Powerline looks like crap, what's wrong?
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
* You need to tell tmux that it has 256-color capabilities. Add this to your
|
||||||
|
:file:`.tmux.conf` to solve this issue::
|
||||||
|
|
||||||
|
set -g default-terminal "screen-256color"
|
||||||
|
* If you're using iTerm2, make sure that you have enabled the setting
|
||||||
|
:guilabel:`Set locale variables automatically` in :menuselection:`Profiles -->
|
||||||
|
Terminal --> Environment`.
|
||||||
|
* Make sure tmux knows that terminal it is running in support 256 colors. You
|
||||||
|
may tell it tmux by using ``-2`` option when launching it.
|
||||||
|
|
||||||
|
I’m using tmux/screen and Powerline is colorless
|
||||||
|
------------------------------------------------
|
||||||
|
|
||||||
|
* If the above advices do not help, then you need to disable
|
||||||
|
:ref:`term_truecolor <config-common-term_truecolor>`.
|
||||||
|
* Alternative: set :ref:`additional_escapes <config-common-additional_escapes>`
|
||||||
|
to ``"tmux"`` or ``"screen"``. Note that it is known to work perfectly in
|
||||||
|
screen, but in tmux it may produce ugly spaces.
|
||||||
|
|
||||||
|
|
||||||
|
After an update something stopped working
|
||||||
|
-----------------------------------------
|
||||||
|
|
||||||
|
Assuming powerline was working before update and stopped only after there are
|
||||||
|
two possible explanations:
|
||||||
|
|
||||||
|
* You have more then one powerline installation (e.g. ``pip`` and ``Vundle``
|
||||||
|
installations) and you have updated only one.
|
||||||
|
* Update brought some bug to powerline.
|
||||||
|
|
||||||
|
In the second case you, of course, should report the bug to `powerline bug
|
||||||
|
tracker <https://github.com/Lokaltog/powerline>`_. In the first you should make
|
||||||
|
sure you either have only one powerline installation or you update all of them
|
||||||
|
simultaneously (beware that in the second case you are not supported). To
|
||||||
|
diagnose this problem you may do the following:
|
||||||
|
|
||||||
|
#) If this problem is observed within the shell make sure that
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
python -c 'import powerline; print (powerline.__file__)'
|
||||||
|
|
||||||
|
which should report something like
|
||||||
|
:file:`/usr/lib64/python2.7/site-packages/powerline/__init__.pyc` (if
|
||||||
|
powerline is installed system-wide) or
|
||||||
|
:file:`/home/USER/.../powerline/__init__.pyc` (if powerline was cloned
|
||||||
|
somewhere, e.g. in :file:`/home/USER/.vim/bundle/powerline`) reports the same
|
||||||
|
location you use to source in your shell configuration: in first case it
|
||||||
|
should be some location in :file:`/usr` (e.g.
|
||||||
|
:file:`/usr/share/zsh/site-contrib/powerline.zsh`), in the second it should
|
||||||
|
be something like
|
||||||
|
:file:`/home/USER/.../powerline/bindings/zsh/powerline.zsh`. If this is true
|
||||||
|
it may be a powerline bug, but if locations do not match you should not
|
||||||
|
report the bug until you observe it on configuration where locations do
|
||||||
|
match.
|
||||||
|
#) If this problem is observed specifically within bash make sure that you clean
|
||||||
|
``$POWERLINE_COMMAND`` and ``$PROMPT_COMMAND`` environment variables on
|
||||||
|
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
|
||||||
|
code reporting.
|
||||||
|
|
||||||
|
These are the sources which may keep outdated environment variables:
|
||||||
|
|
||||||
|
* Any command launched from any application inherits its environment unless
|
||||||
|
callee explicitly requests to use specific environment. So if you did
|
||||||
|
``exec bash`` after update it is rather unlikely to fix the problem.
|
||||||
|
* More interesting: `tmux` is a client-server application, it keeps one
|
||||||
|
server instance per one user. You probably already knew that, but there is
|
||||||
|
an interesting consequence: once `tmux` server was started it inherits its
|
||||||
|
environment from the callee and keeps it *forever* (i.e. until server is
|
||||||
|
killed). This environment is then inherited by applications you start with
|
||||||
|
``tmux new-session``. Easiest solution is to kill tmux with ``tmux
|
||||||
|
kill-server``, but you may also use ``tmux set-environment -u`` to unset
|
||||||
|
offending variables.
|
||||||
|
* Also check `When using z powerline shows wrong number of jobs`_: though
|
||||||
|
this problem should not be seen after update only, it contains another
|
||||||
|
example of ``$PROMPT_COMMAND`` spoiling results.
|
||||||
|
|
||||||
|
#) If this problem is observed within the vim instance you should check out the
|
||||||
|
output of the following Ex mode commands
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
python import powerline as pl ; print (pl.__file__)
|
||||||
|
python3 import powerline as pl ; print (pl.__file__)
|
||||||
|
|
||||||
|
One (but not both) of them will most likely error out, this is OK. The same
|
||||||
|
rules apply as in the 1), but in place of sourcing you should seek for the
|
||||||
|
place where you modify `runtimepath` vim option. If you install powerline
|
||||||
|
using `VAM <https://github.com/MarcWeber/vim-addon-manager>`_ then no
|
||||||
|
explicit modifications of runtimpath were performed in your vimrc
|
||||||
|
(runtimepath is modified by VAM in this case), but powerline will be placed
|
||||||
|
in :file:`{plugin_root_dir}/powerline` where `{plugin_root_dir}` is stored in
|
||||||
|
VAM settings dictionary: do `echo g:vim_addon_manager.plugin_root_dir`.
|
||||||
|
|
||||||
|
There is a hint if you want to place powerline repository somewhere, but still
|
||||||
|
make powerline package importable anywhere: use
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
pip install --user --editable path/to/powerline
|
||||||
|
|
||||||
|
Shell issues
|
||||||
|
============
|
||||||
|
|
||||||
|
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.
|
||||||
|
* Compile and install ``libzpython`` module that lives in
|
||||||
|
https://bitbucket.org/ZyX_I/zpython. This variant is zsh-specific.
|
||||||
|
|
||||||
|
Prompt is spoiled after completing files in ksh
|
||||||
|
-----------------------------------------------
|
||||||
|
|
||||||
|
This is exactly why powerline has official mksh support, but not official ksh
|
||||||
|
support. If you know the solution feel free to share it in `powerline bug
|
||||||
|
tracker`_.
|
||||||
|
|
||||||
|
When using z powerline shows wrong number of jobs
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
This happens because `z <https://github.com/rupa/z>`_ is launching some jobs in
|
||||||
|
the background from ``$POWERLINE_COMMAND`` and these jobs fail to finish before
|
||||||
|
powerline prompt is run.
|
||||||
|
|
||||||
|
Solution to this problem is simple: be sure that :file:`z.sh` is sourced
|
||||||
|
strictly after :file:`powerline/bindings/bash/powerline.sh`. This way background
|
||||||
|
jobs are spawned by `z <https://github.com/rupa/z>`_ after powerline has done
|
||||||
|
its job.
|
||||||
|
|
||||||
|
When using shell I do not see powerline fancy characters
|
||||||
|
--------------------------------------------------------
|
||||||
|
|
||||||
|
If your locale encoding is not unicode (any encoding that starts with “utf” or
|
||||||
|
“ucs” will work, case is ignored) powerline falls back to ascii-only theme. You
|
||||||
|
should set up your system to use unicode locale or forget about powerline fancy
|
||||||
|
characters.
|
||||||
|
|
||||||
|
Vim issues
|
||||||
|
==========
|
||||||
|
|
||||||
|
My vim statusline has strange characters like ``^B`` in it!
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
* Please add ``set encoding=utf-8`` to your :file:`vimrc`.
|
||||||
|
|
||||||
|
My vim statusline has a lot of ``^`` or underline characters in it!
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
|
* You need to configure the ``fillchars`` setting to disable statusline
|
||||||
|
fillchars (see ``:h fillchars`` for details). Add this to your
|
||||||
|
:file:`vimrc` to solve this issue:
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
set fillchars+=stl:\ ,stlnc:\
|
||||||
|
|
||||||
|
My vim statusline is hidden/only appears in split windows!
|
||||||
|
----------------------------------------------------------
|
||||||
|
|
||||||
|
* Make sure that you have ``set laststatus=2`` in your :file:`vimrc`.
|
||||||
|
|
||||||
|
My vim statusline is not displayed completely and has too much spaces
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
* Be sure you have ``ambiwidth`` option set to ``single``.
|
||||||
|
* Alternative: set :ref:`ambiwidth <config-common-ambiwidth>` to 2, remove fancy
|
||||||
|
dividers (they suck when ``ambiwidth`` is set to double).
|
||||||
|
|
||||||
|
Powerline loses color after editing vimrc
|
||||||
|
-----------------------------------------
|
||||||
|
|
||||||
|
If your vimrc has something like
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
autocmd! BufWritePost vimrc :source ~/.vimrc
|
||||||
|
|
||||||
|
to automatically source vimrc after saving it you must then add ``nested`` after
|
||||||
|
pattern (``vimrc`` in this case):
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
autocmd! BufWritePost vimrc nested :source ~/.vimrc
|
||||||
|
|
||||||
|
. Alternatively move ``:colorscheme`` command out of the vimrc to the file which
|
||||||
|
will not be automatically resourced. Observed problem is that when you use
|
||||||
|
``:colorscheme`` command existing highlighting groups are usually cleared,
|
||||||
|
including those defined by powerline. To workaround this issue powerline hooks
|
||||||
|
``Colorscheme`` event, but when you source vimrc with ``BufWritePost`` event,
|
||||||
|
but without ``nested`` this event is not launched. See also `autocmd-nested
|
||||||
|
<http://vimpluginloader.sourceforge.net/doc/autocmd.txt.html#autocmd-nested>`_
|
||||||
|
Vim documentation.
|
||||||
|
|
||||||
|
Powerline loses color after saving any file
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
It may be one of the incarnations of the above issue: specifically minibufexpl
|
||||||
|
is known to trigger it. If you are using minibufexplorer you should set
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
let g:miniBufExplForceSyntaxEnable = 1
|
||||||
|
|
||||||
|
variable so that this issue is not triggered. Complete explanation:
|
||||||
|
|
||||||
|
#. When MBE autocommand is executed it launches ``:syntax enable`` Vim command…
|
||||||
|
#. … which makes Vim source :file:`syntax/syntax.vim` file …
|
||||||
|
#. … which in turn sources :file:`syntax/synload.vim` …
|
||||||
|
#. … which executes ``:colorscheme`` command. Normally this command triggers
|
||||||
|
``Colorscheme`` event, but in the first point minibufexplorer did set up
|
||||||
|
autocommands that miss ``nested`` attribute meaning that no events will be
|
||||||
|
triggered when processing MBE events.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
This setting was introduced in version 6.3.1 of `minibufexpl
|
||||||
|
<http://www.vim.org/scripts/script.php?script_id=159>`_ and removed in
|
||||||
|
version 6.5.0 of its successor `minibufexplorer
|
||||||
|
<http://www.vim.org/scripts/script.php?script_id=3239>`_. It is highly
|
||||||
|
advised to use the latter because `minibufexpl`_ was last updated late in
|
||||||
|
2004.
|
21
docs/source/troubleshooting/linux.rst
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
************************
|
||||||
|
Troubleshooting on Linux
|
||||||
|
************************
|
||||||
|
|
||||||
|
I can't see any fancy symbols, what's wrong?
|
||||||
|
--------------------------------------------
|
||||||
|
|
||||||
|
* Make sure that you've configured gvim or your terminal emulator to use
|
||||||
|
a patched font.
|
||||||
|
* You need to set your ``LANG`` and ``LC_*`` environment variables to
|
||||||
|
a UTF-8 locale (e.g. ``LANG=en_US.utf8``). Consult your Linux distro's
|
||||||
|
documentation for information about setting these variables correctly.
|
||||||
|
* Make sure that vim is compiled with the ``--with-features=big`` flag.
|
||||||
|
* If you're using rxvt-unicode, make sure that it's compiled with the
|
||||||
|
``--enable-unicode3`` flag.
|
||||||
|
|
||||||
|
The fancy symbols look a bit blurry or "off"!
|
||||||
|
---------------------------------------------
|
||||||
|
|
||||||
|
* Make sure that you have patched all variants of your font (i.e. both the
|
||||||
|
regular and the bold font files).
|
61
docs/source/troubleshooting/osx.rst
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
***********************
|
||||||
|
Troubleshooting on OS X
|
||||||
|
***********************
|
||||||
|
|
||||||
|
I can't see any fancy symbols, what's wrong?
|
||||||
|
--------------------------------------------
|
||||||
|
|
||||||
|
* If you're using iTerm2, please update to `this revision
|
||||||
|
<https://github.com/gnachman/iTerm2/commit/8e3ad6dabf83c60b8cf4a3e3327c596401744af6>`_
|
||||||
|
or newer.
|
||||||
|
* You need to set your ``LANG`` and ``LC_*`` environment variables to
|
||||||
|
a UTF-8 locale (e.g. ``LANG=en_US.utf8``). Consult your Linux distro's
|
||||||
|
documentation for information about setting these variables correctly.
|
||||||
|
|
||||||
|
The colors look weird in the default OS X Terminal app!
|
||||||
|
-------------------------------------------------------
|
||||||
|
|
||||||
|
* The arrows may have the wrong colors if you have changed the "minimum
|
||||||
|
contrast" slider in the color tab of your OS X settings.
|
||||||
|
* The default OS X Terminal app is known to have some issues with the
|
||||||
|
Powerline colors. Please use another terminal emulator. iTerm2 should work
|
||||||
|
fine.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
Statusline is getting wrapped to the next line in iTerm2
|
||||||
|
--------------------------------------------------------
|
||||||
|
|
||||||
|
* Turn off “Treat ambigious-width characters as double width” in `Preferences
|
||||||
|
--> Text`.
|
||||||
|
* Alternative: remove fancy dividers (they suck in this case), set
|
||||||
|
:ref:`ambiwidth <config-common-ambiwidth>` to 2.
|
||||||
|
|
||||||
|
I receive a ``NameError`` when trying to use Powerline with MacVim!
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
|
* Please install MacVim using this command::
|
||||||
|
|
||||||
|
brew install macvim --env-std --override-system-vim
|
||||||
|
|
||||||
|
Then install Powerline locally with ``pip install --user``, or by
|
||||||
|
running these commands in the ``powerline`` directory::
|
||||||
|
|
||||||
|
./setup.py build
|
||||||
|
./setup.py install --user
|
||||||
|
|
||||||
|
I receive an ``ImportError`` when trying to use Powerline on OS X!
|
||||||
|
------------------------------------------------------------------
|
||||||
|
|
||||||
|
* This is caused by an invalid ``sys.path`` when using system vim and system
|
||||||
|
Python. Please try to select another Python distribution::
|
||||||
|
|
||||||
|
sudo port select python python27-apple
|
||||||
|
|
||||||
|
* See `issue #39 <https://github.com/Lokaltog/powerline/issues/39>`_ for
|
||||||
|
a discussion and other possible solutions for this issue.
|
74
docs/source/usage.rst
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
*****
|
||||||
|
Usage
|
||||||
|
*****
|
||||||
|
|
||||||
|
Application-specific requirements
|
||||||
|
---------------------------------
|
||||||
|
|
||||||
|
Vim plugin requirements
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
The vim plugin requires a vim version with Python support compiled in. You
|
||||||
|
can check if your vim supports Python by running ``vim --version | grep
|
||||||
|
+python``.
|
||||||
|
|
||||||
|
If your vim version doesn't have support for Python, you'll have to compile
|
||||||
|
it with the ``--enable-pythoninterp`` flag (``--enable-python3interp`` if
|
||||||
|
you want Python 3 support instead). Note that this also requires the related
|
||||||
|
Python headers to be installed on your system. Please consult your
|
||||||
|
distribution's documentation for details on how to compile and install
|
||||||
|
packages.
|
||||||
|
|
||||||
|
Vim version 7.4 or newer is recommended for performance reasons, but Powerline
|
||||||
|
is known to work on vim-7.0.112 (some segments may not work though as it was not
|
||||||
|
actually tested).
|
||||||
|
|
||||||
|
.. _usage-terminal-emulators:
|
||||||
|
|
||||||
|
Terminal emulator requirements
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Powerline uses several special glyphs to get the arrow effect and some
|
||||||
|
custom symbols for developers. This requires that you either have a symbol
|
||||||
|
font or a patched font on your system. Your terminal emulator must also
|
||||||
|
support either patched fonts or fontconfig for Powerline to work properly.
|
||||||
|
|
||||||
|
You can also enable :ref:`24-bit color support <config-common-term_truecolor>`
|
||||||
|
if your terminal emulator supports it.
|
||||||
|
|
||||||
|
.. table:: Application/terminal emulator feature support matrix
|
||||||
|
:name: term-feature-support-matrix
|
||||||
|
|
||||||
|
===================== ======= ===================== ===================== =====================
|
||||||
|
Name OS Patched font support Fontconfig support 24-bit color support
|
||||||
|
===================== ======= ===================== ===================== =====================
|
||||||
|
Gvim Linux |i_yes| |i_no| |i_yes|
|
||||||
|
iTerm2 OS X |i_yes| |i_no| |i_no|
|
||||||
|
Konsole Linux |i_yes| |i_yes| |i_yes|
|
||||||
|
lxterminal Linux |i_yes| |i_yes| |i_no|
|
||||||
|
MacVim OS X |i_yes| |i_no| |i_yes|
|
||||||
|
rxvt-unicode Linux |i_partial| [#]_ |i_no| |i_no|
|
||||||
|
st Linux |i_yes| |i_yes| |i_yes| [#]_
|
||||||
|
Terminal.app OS X |i_yes| |i_no| |i_no|
|
||||||
|
libvte-based [#]_ Linux |i_yes| |i_yes| |i_yes| [#]_
|
||||||
|
xterm Linux |i_yes| |i_no| |i_partial| [#]_
|
||||||
|
===================== ======= ===================== ===================== =====================
|
||||||
|
|
||||||
|
.. |i_yes| image:: _static/img/icons/tick.png
|
||||||
|
.. |i_no| image:: _static/img/icons/cross.png
|
||||||
|
.. |i_partial| image:: _static/img/icons/error.png
|
||||||
|
|
||||||
|
.. [#] Must be compiled with ``--enable-unicode3`` for the patched font to work.
|
||||||
|
.. [#] Since version 0.5.
|
||||||
|
.. [#] Including XFCE terminal and GNOME terminal.
|
||||||
|
.. [#] Since version 0.36.
|
||||||
|
.. [#] Uses nearest color from 8-bit palette.
|
||||||
|
|
||||||
|
Plugins
|
||||||
|
-------
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
|
||||||
|
usage/shell-prompts
|
||||||
|
usage/wm-widgets
|
||||||
|
usage/other
|
121
docs/source/usage/other.rst
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
*************
|
||||||
|
Other plugins
|
||||||
|
*************
|
||||||
|
|
||||||
|
.. _vim-vimrc:
|
||||||
|
|
||||||
|
Vim statusline
|
||||||
|
==============
|
||||||
|
|
||||||
|
If installed using pip just add
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
python from powerline.vim import setup as powerline_setup
|
||||||
|
python powerline_setup()
|
||||||
|
python del powerline_setup
|
||||||
|
|
||||||
|
(replace ``python`` with ``python3`` if appropriate) to your :file:`vimrc`.
|
||||||
|
|
||||||
|
If you just cloned the repository add the following line to your :file:`vimrc`,
|
||||||
|
where ``{repository_root}`` is the absolute path to your Powerline installation
|
||||||
|
directory:
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
set rtp+={repository_root}/powerline/bindings/vim
|
||||||
|
|
||||||
|
If you're using pathogen and don't want Powerline functionality in any other
|
||||||
|
applications, simply add Powerline as a bundle and point the path above to the
|
||||||
|
Powerline bundle directory, e.g.
|
||||||
|
``~/.vim/bundle/powerline/powerline/bindings/vim``.
|
||||||
|
|
||||||
|
With Vundle you may instead use
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
|
||||||
|
|
||||||
|
(replace ``Bundle`` with ``NeoBundle`` for NeoBundle).
|
||||||
|
|
||||||
|
For vim-addon-manager it is even easier since you don’t need to write this big
|
||||||
|
path or install anything by hand: ``powerline`` is installed and run just like
|
||||||
|
any other plugin using
|
||||||
|
|
||||||
|
.. code-block:: vim
|
||||||
|
|
||||||
|
call vam#ActivateAddons(['powerline'])
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
*Never* install powerline with pathogen/VAM/Vundle/NeoBundle *and* with pip.
|
||||||
|
If you want powerline functionality in vim and other applications use
|
||||||
|
system-wide installation if your system has powerline package, pip-only or
|
||||||
|
``pip install --editable`` kind of installation performed on the repository
|
||||||
|
installed by Vim plugin manager.
|
||||||
|
|
||||||
|
If you have installed powerline with pip and with some of Vim package
|
||||||
|
managers do never report any errors to powerline bug tracker, especially
|
||||||
|
errors occurring after updates.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
If you use supplied :file:`powerline.vim` file to load powerline there are
|
||||||
|
additional configuration variables available: ``g:powerline_pycmd`` and
|
||||||
|
``g:powerline_pyeval``. First sets command used to load powerline: expected
|
||||||
|
values are ``"py"`` and ``"py3"``. Second sets function used in statusline,
|
||||||
|
expected values are ``"pyeval"`` and ``"py3eval"``.
|
||||||
|
|
||||||
|
If ``g:powerline_pycmd`` is set to the one of the expected values then
|
||||||
|
``g:powerline_pyeval`` will be set accordingly. If it is set to some other
|
||||||
|
value then you must also set ``g:powerline_pyeval``. Powerline will not
|
||||||
|
check that Vim is compiled with Python support if you set
|
||||||
|
``g:powerline_pycmd`` to an unexpected value.
|
||||||
|
|
||||||
|
These values are to be used to specify the only Python that is to be loaded
|
||||||
|
if you have both versions: Vim may disable loading one python version if
|
||||||
|
other was already loaded. They should also be used if you have two python
|
||||||
|
versions able to load simultaneously, but with powerline installed only for
|
||||||
|
python-3 version.
|
||||||
|
|
||||||
|
Tmux statusline
|
||||||
|
===============
|
||||||
|
|
||||||
|
Add the following lines to your :file:`.tmux.conf`, where ``{repository_root}``
|
||||||
|
is the absolute path to your Powerline installation directory::
|
||||||
|
|
||||||
|
source "{repository_root}/powerline/bindings/tmux/powerline.conf"
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
The availability of the ``powerline-config`` command is required for
|
||||||
|
powerline support. You may specify location of this script via
|
||||||
|
``$POWERLINE_CONFIG_COMMAND`` environment variable.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
It is advised that you run ``powerline-daemon`` before adding the above line
|
||||||
|
to tmux.conf. To do so add::
|
||||||
|
|
||||||
|
run-shell "powerline-daemon -q"
|
||||||
|
|
||||||
|
to :file:`.tmux.conf`.
|
||||||
|
|
||||||
|
IPython prompt
|
||||||
|
==============
|
||||||
|
|
||||||
|
For IPython<0.11 add the following lines to your
|
||||||
|
:file:`.ipython/ipy_user_conf.py`::
|
||||||
|
|
||||||
|
# top
|
||||||
|
from powerline.bindings.ipython.pre_0_11 import setup as powerline_setup
|
||||||
|
|
||||||
|
# main() function (assuming you launched ipython without configuration to
|
||||||
|
# create skeleton ipy_user_conf.py file):
|
||||||
|
powerline_setup()
|
||||||
|
|
||||||
|
For IPython>=0.11 add the following line to your :file:`ipython_config.py`
|
||||||
|
file in the profile you are using::
|
||||||
|
|
||||||
|
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).
|
114
docs/source/usage/shell-prompts.rst
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
*************
|
||||||
|
Shell prompts
|
||||||
|
*************
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Powerline daemon is not run automatically by any of my bindings. It is
|
||||||
|
advised that you add
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
powerline-daemon -q
|
||||||
|
|
||||||
|
before any other powerline-related code in your shell configuration file.
|
||||||
|
|
||||||
|
Bash prompt
|
||||||
|
===========
|
||||||
|
|
||||||
|
Add the following line to your :file:`bashrc`, where ``{repository_root}`` is
|
||||||
|
the absolute path to your Powerline installation directory:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
. {repository_root}/powerline/bindings/bash/powerline.sh
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Since without powerline daemon bash bindings are very slow PS2
|
||||||
|
(continuation) and PS3 (select) prompts are not set up. Thus it is advised
|
||||||
|
to use
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
powerline-daemon -q
|
||||||
|
POWERLINE_BASH_CONTINUATION=1
|
||||||
|
POWERLINE_BASH_SELECT=1
|
||||||
|
. {repository_root}/powerline/bindings/bash/powerline.sh
|
||||||
|
|
||||||
|
in your bash configuration file. Without ``POWERLINE_BASH_*`` variables PS2
|
||||||
|
and PS3 prompts are computed exactly once at bash startup.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
At maximum bash continuation PS2 and select PS3 prompts are computed each
|
||||||
|
time main PS1 prompt is computed. Do not expect it to work properly if you
|
||||||
|
e.g. put current time there.
|
||||||
|
|
||||||
|
At minimum they are computed once on startup.
|
||||||
|
|
||||||
|
Zsh prompt
|
||||||
|
==========
|
||||||
|
|
||||||
|
Add the following line to your :file:`zshrc`, where ``{repository_root}`` is the
|
||||||
|
absolute path to your Powerline installation directory:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
. {repository_root}/powerline/bindings/zsh/powerline.zsh
|
||||||
|
|
||||||
|
Fish prompt
|
||||||
|
===========
|
||||||
|
|
||||||
|
Add the following line to your :file:`config.fish`, where ``{repository_root}``
|
||||||
|
is the absolute path to your Powerline installation directory:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
set fish_function_path $fish_function_path "{repository_root}/powerline/bindings/fish"
|
||||||
|
powerline-setup
|
||||||
|
|
||||||
|
.. _tmux-statusline:
|
||||||
|
|
||||||
|
Busybox (ash), mksh and dash prompt
|
||||||
|
=====================================
|
||||||
|
|
||||||
|
After launching busybox run the following command:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
. {repository_root}/powerline/bindings/shell/powerline.sh
|
||||||
|
|
||||||
|
Mksh users may put this line into ``~/.mkshrc`` file. Dash users may use the
|
||||||
|
following in ``~/.profile``:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
if test "x$0" != "x${0#dash}" ; then
|
||||||
|
export ENV={repository_root}/powerline/bindings/shell/powerline.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
Dash users that already have ``$ENV`` defined should either put the ``.
|
||||||
|
…/shell/powerline.sh`` line in the ``$ENV`` file or create a new file which
|
||||||
|
will source (using ``.`` command) both former ``$ENV`` file and
|
||||||
|
:file:`powerline.sh` files and set ``$ENV`` to the path of this new file.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
Mksh users have to set ``$POWERLINE_SHELL_CONTINUATION`` and
|
||||||
|
``$POWERLINE_SHELL_SELECT`` to 1 to get PS2 and PS3 (continuation and
|
||||||
|
select) prompts support respectively: as command substitution is not
|
||||||
|
performed in these shells for these prompts they are updated once each time
|
||||||
|
PS1 prompt is displayed which may be slow.
|
||||||
|
|
||||||
|
It is also known that while PS2 and PS3 update is triggered at PS1 update it
|
||||||
|
is *actually performed* only *next* time PS1 is displayed which means that
|
||||||
|
PS2 and PS3 prompts will be outdated and may be incorrect for this reason.
|
||||||
|
|
||||||
|
Without these variables PS2 and PS3 prompts will be set once at startup.
|
||||||
|
This only touches mksh users: busybox and dash both have no such problem.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
Job count is using some weird hack that uses signals and temporary files for
|
||||||
|
interprocess communication. It may be wrong sometimes. Not the case in mksh.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
Busybox has two shells: ``ash`` and ``hush``. Second is known to segfault in
|
||||||
|
busybox 1.22.1 when using :file:`powerline.sh` script.
|
64
docs/source/usage/wm-widgets.rst
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
**********************
|
||||||
|
Window manager widgets
|
||||||
|
**********************
|
||||||
|
|
||||||
|
Awesome widget
|
||||||
|
==============
|
||||||
|
|
||||||
|
.. note:: Powerline currently only supports awesome 3.5.
|
||||||
|
|
||||||
|
.. note:: The Powerline widget will spawn a shell script that runs in the
|
||||||
|
background and updates the statusline with ``awesome-client``.
|
||||||
|
|
||||||
|
Add the following to your :file:`rc.lua`, where ``{repository_root}`` is the
|
||||||
|
absolute path to your Powerline installation directory:
|
||||||
|
|
||||||
|
.. code-block:: lua
|
||||||
|
|
||||||
|
package.path = package.path .. ';{repository_root}/powerline/bindings/awesome/?.lua'
|
||||||
|
require('powerline')
|
||||||
|
|
||||||
|
Then add the ``powerline_widget`` to your ``wibox``:
|
||||||
|
|
||||||
|
.. code-block:: lua
|
||||||
|
|
||||||
|
right_layout:add(powerline_widget)
|
||||||
|
|
||||||
|
Qtile widget
|
||||||
|
============
|
||||||
|
|
||||||
|
Add the following to your :file:`~/.config/qtile/config.py`:
|
||||||
|
|
||||||
|
.. code-block:: python
|
||||||
|
|
||||||
|
from powerline.bindings.qtile.widget import Powerline
|
||||||
|
|
||||||
|
screens = [
|
||||||
|
Screen(
|
||||||
|
top=bar.Bar([
|
||||||
|
# ...
|
||||||
|
Powerline(timeout=2),
|
||||||
|
# ...
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
|
I3 bar
|
||||||
|
======
|
||||||
|
|
||||||
|
.. note:: Until the patch is done in i3, you will need a custom ``i3bar`` build
|
||||||
|
called ``i3bgbar``. The source is available `here
|
||||||
|
<https://github.com/S0lll0s/i3bgbar>`_.
|
||||||
|
|
||||||
|
Add the following to your :file:`~/.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.
|
105
font/10-powerline-symbols.conf
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
|
||||||
|
|
||||||
|
<fontconfig>
|
||||||
|
<alias>
|
||||||
|
<family>monospace</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Droid Sans Mono</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Droid Sans Mono Slashed</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Droid Sans Mono Dotted</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>DejaVu Sans Mono</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>DejaVu Sans Mono</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Envy Code R</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Inconsolata</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Lucida Console</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Monaco</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Pragmata</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>PragmataPro</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Menlo</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Source Code Pro</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Consolas</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Anonymous pro</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Bitstream Vera Sans Mono</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Liberation Mono</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Ubuntu Mono</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Meslo LG L</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Meslo LG L DZ</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Meslo LG M</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Meslo LG M DZ</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Meslo LG S</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
<alias>
|
||||||
|
<family>Meslo LG S DZ</family>
|
||||||
|
<prefer><family>PowerlineSymbols</family></prefer>
|
||||||
|
</alias>
|
||||||
|
</fontconfig>
|
BIN
font/PowerlineSymbols.otf
Normal file
864
powerline/__init__.py
Normal file
@ -0,0 +1,864 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from locale import getpreferredencoding
|
||||||
|
from threading import Lock, Event
|
||||||
|
|
||||||
|
from powerline.colorscheme import Colorscheme
|
||||||
|
from powerline.lib.config import ConfigLoader
|
||||||
|
from powerline.lib.unicode import safe_unicode, FailedUnicode
|
||||||
|
from powerline.config import DEFAULT_SYSTEM_CONFIG_DIR
|
||||||
|
from powerline.lib import mergedicts
|
||||||
|
|
||||||
|
|
||||||
|
def _config_loader_condition(path):
|
||||||
|
if path and os.path.isfile(path):
|
||||||
|
return path
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _find_config_files(search_paths, config_file, config_loader=None, loader_callback=None):
|
||||||
|
config_file += '.json'
|
||||||
|
found = False
|
||||||
|
for path in search_paths:
|
||||||
|
config_file_path = os.path.join(path, config_file)
|
||||||
|
if os.path.isfile(config_file_path):
|
||||||
|
yield config_file_path
|
||||||
|
found = True
|
||||||
|
elif config_loader:
|
||||||
|
config_loader.register_missing(_config_loader_condition, loader_callback, config_file_path)
|
||||||
|
if not found:
|
||||||
|
raise IOError('Config file not found in search paths ({0}): {1}'.format(
|
||||||
|
', '.join(search_paths),
|
||||||
|
config_file
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
class PowerlineLogger(object):
|
||||||
|
'''Proxy class for logging.Logger instance
|
||||||
|
|
||||||
|
It emits messages in format ``{ext}:{prefix}:{message}`` where
|
||||||
|
|
||||||
|
``{ext}``
|
||||||
|
is a used powerline extension (e.g. “vim”, “shell”, “ipython”).
|
||||||
|
``{prefix}``
|
||||||
|
is a local prefix, usually a segment name.
|
||||||
|
``{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,
|
||||||
|
not in printf-like format.
|
||||||
|
|
||||||
|
Log is saved to the location :ref:`specified by user <config-common-log>`.
|
||||||
|
'''
|
||||||
|
|
||||||
|
def __init__(self, use_daemon_threads, logger, ext):
|
||||||
|
self.logger = logger
|
||||||
|
self.ext = ext
|
||||||
|
self.use_daemon_threads = use_daemon_threads
|
||||||
|
self.prefix = ''
|
||||||
|
self.last_msgs = {}
|
||||||
|
|
||||||
|
def _log(self, attr, msg, *args, **kwargs):
|
||||||
|
prefix = kwargs.get('prefix') or self.prefix
|
||||||
|
prefix = self.ext + ((':' + prefix) if prefix else '')
|
||||||
|
msg = safe_unicode(msg)
|
||||||
|
if args or kwargs:
|
||||||
|
args = [safe_unicode(s) if isinstance(s, bytes) else s for s in args]
|
||||||
|
kwargs = dict((
|
||||||
|
(k, safe_unicode(v) if isinstance(v, bytes) else v)
|
||||||
|
for k, v in kwargs.items()
|
||||||
|
))
|
||||||
|
msg = msg.format(*args, **kwargs)
|
||||||
|
msg = prefix + ':' + msg
|
||||||
|
key = attr + ':' + prefix
|
||||||
|
if msg != self.last_msgs.get(key):
|
||||||
|
getattr(self.logger, attr)(msg)
|
||||||
|
self.last_msgs[key] = msg
|
||||||
|
|
||||||
|
def critical(self, msg, *args, **kwargs):
|
||||||
|
self._log('critical', msg, *args, **kwargs)
|
||||||
|
|
||||||
|
def exception(self, msg, *args, **kwargs):
|
||||||
|
self._log('exception', msg, *args, **kwargs)
|
||||||
|
|
||||||
|
def info(self, msg, *args, **kwargs):
|
||||||
|
self._log('info', msg, *args, **kwargs)
|
||||||
|
|
||||||
|
def error(self, msg, *args, **kwargs):
|
||||||
|
self._log('error', msg, *args, **kwargs)
|
||||||
|
|
||||||
|
def warn(self, msg, *args, **kwargs):
|
||||||
|
self._log('warning', msg, *args, **kwargs)
|
||||||
|
|
||||||
|
def debug(self, msg, *args, **kwargs):
|
||||||
|
self._log('debug', msg, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
_fallback_logger = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_fallback_logger(stream=None):
|
||||||
|
global _fallback_logger
|
||||||
|
if _fallback_logger:
|
||||||
|
return _fallback_logger
|
||||||
|
|
||||||
|
log_format = '%(asctime)s:%(levelname)s:%(message)s'
|
||||||
|
formatter = logging.Formatter(log_format)
|
||||||
|
|
||||||
|
level = logging.WARNING
|
||||||
|
handler = logging.StreamHandler(stream)
|
||||||
|
handler.setLevel(level)
|
||||||
|
handler.setFormatter(formatter)
|
||||||
|
|
||||||
|
logger = logging.getLogger('powerline')
|
||||||
|
logger.setLevel(level)
|
||||||
|
logger.addHandler(handler)
|
||||||
|
_fallback_logger = PowerlineLogger(None, logger, '_fallback_')
|
||||||
|
return _fallback_logger
|
||||||
|
|
||||||
|
|
||||||
|
def _generate_change_callback(lock, key, dictionary):
|
||||||
|
def on_file_change(path):
|
||||||
|
with lock:
|
||||||
|
dictionary[key] = True
|
||||||
|
return on_file_change
|
||||||
|
|
||||||
|
|
||||||
|
def get_config_paths():
|
||||||
|
'''Get configuration paths from environment variables.
|
||||||
|
|
||||||
|
Uses $XDG_CONFIG_HOME and $XDG_CONFIG_DIRS according to the XDG specification.
|
||||||
|
|
||||||
|
:return: list of paths
|
||||||
|
'''
|
||||||
|
config_home = os.environ.get('XDG_CONFIG_HOME', os.path.join(os.path.expanduser('~'), '.config'))
|
||||||
|
config_path = os.path.join(config_home, 'powerline')
|
||||||
|
config_paths = [config_path]
|
||||||
|
config_dirs = os.environ.get('XDG_CONFIG_DIRS', DEFAULT_SYSTEM_CONFIG_DIR)
|
||||||
|
if config_dirs is not None:
|
||||||
|
config_paths[:0] = reversed([os.path.join(d, 'powerline') for d in config_dirs.split(':')])
|
||||||
|
plugin_path = os.path.join(os.path.realpath(os.path.dirname(__file__)), 'config_files')
|
||||||
|
config_paths.insert(0, plugin_path)
|
||||||
|
return config_paths
|
||||||
|
|
||||||
|
|
||||||
|
def generate_config_finder(get_config_paths=get_config_paths):
|
||||||
|
'''Generate find_config_files function
|
||||||
|
|
||||||
|
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
|
||||||
|
that should be searched for configuration files.
|
||||||
|
|
||||||
|
:return:
|
||||||
|
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()
|
||||||
|
return lambda *args: _find_config_files(config_paths, *args)
|
||||||
|
|
||||||
|
|
||||||
|
def load_config(cfg_path, find_config_files, config_loader, loader_callback=None):
|
||||||
|
'''Load configuration file and setup watches
|
||||||
|
|
||||||
|
Watches are only set up if loader_callback is not 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
|
||||||
|
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
|
||||||
|
configuration file is detected.
|
||||||
|
|
||||||
|
:return: Configuration file contents.
|
||||||
|
'''
|
||||||
|
found_files = find_config_files(cfg_path, config_loader, loader_callback)
|
||||||
|
ret = None
|
||||||
|
for path in found_files:
|
||||||
|
if loader_callback:
|
||||||
|
config_loader.register(loader_callback, path)
|
||||||
|
if ret is None:
|
||||||
|
ret = config_loader.load(path)
|
||||||
|
else:
|
||||||
|
mergedicts(ret, config_loader.load(path))
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
def _get_log_handler(common_config, stream=None):
|
||||||
|
'''Get log handler.
|
||||||
|
|
||||||
|
:param dict common_config:
|
||||||
|
Configuration dictionary used to create handler.
|
||||||
|
|
||||||
|
:return: logging.Handler subclass.
|
||||||
|
'''
|
||||||
|
log_file = common_config['log_file']
|
||||||
|
if log_file:
|
||||||
|
log_file = os.path.expanduser(log_file)
|
||||||
|
log_dir = os.path.dirname(log_file)
|
||||||
|
if not os.path.isdir(log_dir):
|
||||||
|
os.mkdir(log_dir)
|
||||||
|
return logging.FileHandler(log_file)
|
||||||
|
else:
|
||||||
|
return logging.StreamHandler(stream)
|
||||||
|
|
||||||
|
|
||||||
|
def create_logger(common_config, stream=None):
|
||||||
|
'''Create logger according to provided configuration
|
||||||
|
'''
|
||||||
|
log_format = common_config['log_format']
|
||||||
|
formatter = logging.Formatter(log_format)
|
||||||
|
|
||||||
|
level = getattr(logging, common_config['log_level'])
|
||||||
|
handler = _get_log_handler(common_config, stream)
|
||||||
|
handler.setLevel(level)
|
||||||
|
handler.setFormatter(formatter)
|
||||||
|
|
||||||
|
logger = logging.getLogger('powerline')
|
||||||
|
logger.setLevel(level)
|
||||||
|
logger.addHandler(handler)
|
||||||
|
return logger
|
||||||
|
|
||||||
|
|
||||||
|
def finish_common_config(encoding, common_config):
|
||||||
|
'''Add default values to common config and expand ~ in paths
|
||||||
|
|
||||||
|
:param dict common_config:
|
||||||
|
Common configuration, as it was just loaded.
|
||||||
|
|
||||||
|
:return:
|
||||||
|
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'
|
||||||
|
|
||||||
|
common_config = common_config.copy()
|
||||||
|
common_config.setdefault('default_top_theme', default_top_theme)
|
||||||
|
common_config.setdefault('paths', [])
|
||||||
|
common_config.setdefault('watcher', 'auto')
|
||||||
|
common_config.setdefault('log_level', 'WARNING')
|
||||||
|
common_config.setdefault('log_format', '%(asctime)s:%(levelname)s:%(message)s')
|
||||||
|
common_config.setdefault('term_truecolor', False)
|
||||||
|
common_config.setdefault('ambiwidth', 1)
|
||||||
|
common_config.setdefault('additional_escapes', None)
|
||||||
|
common_config.setdefault('reload_config', True)
|
||||||
|
common_config.setdefault('interval', None)
|
||||||
|
common_config.setdefault('log_file', None)
|
||||||
|
|
||||||
|
common_config['paths'] = [
|
||||||
|
os.path.expanduser(path) for path in common_config['paths']
|
||||||
|
]
|
||||||
|
|
||||||
|
return common_config
|
||||||
|
|
||||||
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
# `raise exception[0], None, exception[1]` is a SyntaxError in python-3*
|
||||||
|
# Not using ('''…''') because this syntax does not work in python-2.6
|
||||||
|
exec((
|
||||||
|
'def reraise(exception):\n'
|
||||||
|
' if type(exception) is tuple:\n'
|
||||||
|
' raise exception[0], None, exception[1]\n'
|
||||||
|
' else:\n'
|
||||||
|
' raise exception\n'
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
def reraise(exception):
|
||||||
|
if type(exception) is tuple:
|
||||||
|
raise exception[0].with_traceback(exception[1])
|
||||||
|
else:
|
||||||
|
raise exception
|
||||||
|
|
||||||
|
|
||||||
|
def gen_module_attr_getter(pl, import_paths, imported_modules):
|
||||||
|
def get_module_attr(module, attr, prefix='powerline'):
|
||||||
|
'''Import module and get its attribute.
|
||||||
|
|
||||||
|
Replaces ``from {module} import {attr}``.
|
||||||
|
|
||||||
|
: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
|
||||||
|
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.
|
||||||
|
'''
|
||||||
|
oldpath = sys.path
|
||||||
|
sys.path = import_paths + sys.path
|
||||||
|
module = str(module)
|
||||||
|
attr = str(attr)
|
||||||
|
try:
|
||||||
|
imported_modules.add(module)
|
||||||
|
return getattr(__import__(module, fromlist=(attr,)), attr)
|
||||||
|
except Exception as e:
|
||||||
|
pl.exception('Failed to import attr {0} from module {1}: {2}', attr, module, str(e), prefix=prefix)
|
||||||
|
return None
|
||||||
|
finally:
|
||||||
|
sys.path = oldpath
|
||||||
|
|
||||||
|
return get_module_attr
|
||||||
|
|
||||||
|
|
||||||
|
class Powerline(object):
|
||||||
|
'''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
|
||||||
|
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
|
||||||
|
``powerline.renderers.{ext}{renderer_module}``.
|
||||||
|
:param bool run_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
|
||||||
|
used.
|
||||||
|
:param bool use_daemon_threads:
|
||||||
|
When creating threads make them daemon ones.
|
||||||
|
:param Event shutdown_event:
|
||||||
|
Use this Event as shutdown_event instead of creating new event.
|
||||||
|
:param ConfigLoader config_loader:
|
||||||
|
Instance of the class that manages (re)loading of the configuration.
|
||||||
|
'''
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
self.init_args = (args, kwargs)
|
||||||
|
self.init(*args, **kwargs)
|
||||||
|
|
||||||
|
def init(self,
|
||||||
|
ext,
|
||||||
|
renderer_module=None,
|
||||||
|
run_once=False,
|
||||||
|
logger=None,
|
||||||
|
use_daemon_threads=True,
|
||||||
|
shutdown_event=None,
|
||||||
|
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
|
||||||
|
subclasses they must store actual arguments.
|
||||||
|
'''
|
||||||
|
self.ext = ext
|
||||||
|
self.run_once = run_once
|
||||||
|
self.logger = logger
|
||||||
|
self.use_daemon_threads = use_daemon_threads
|
||||||
|
|
||||||
|
if not renderer_module:
|
||||||
|
self.renderer_module = 'powerline.renderers.' + ext
|
||||||
|
elif '.' not in renderer_module:
|
||||||
|
self.renderer_module = 'powerline.renderers.' + renderer_module
|
||||||
|
elif renderer_module.startswith('.'):
|
||||||
|
self.renderer_module = 'powerline.renderers.' + ext + renderer_module
|
||||||
|
elif renderer_module.endswith('.'):
|
||||||
|
self.renderer_module = renderer_module[:-1]
|
||||||
|
else:
|
||||||
|
self.renderer_module = renderer_module
|
||||||
|
|
||||||
|
self.find_config_files = generate_config_finder(self.get_config_paths)
|
||||||
|
|
||||||
|
self.cr_kwargs_lock = Lock()
|
||||||
|
self.cr_kwargs = {}
|
||||||
|
self.cr_callbacks = {}
|
||||||
|
for key in ('main', 'colors', 'colorscheme', 'theme'):
|
||||||
|
self.cr_kwargs['load_' + key] = True
|
||||||
|
self.cr_callbacks[key] = _generate_change_callback(
|
||||||
|
self.cr_kwargs_lock,
|
||||||
|
'load_' + key,
|
||||||
|
self.cr_kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
self.shutdown_event = shutdown_event or Event()
|
||||||
|
self.config_loader = config_loader or ConfigLoader(shutdown_event=self.shutdown_event, run_once=run_once)
|
||||||
|
self.run_loader_update = False
|
||||||
|
|
||||||
|
self.renderer_options = {}
|
||||||
|
|
||||||
|
self.prev_common_config = None
|
||||||
|
self.prev_ext_config = None
|
||||||
|
self.pl = None
|
||||||
|
self.setup_args = ()
|
||||||
|
self.setup_kwargs = {}
|
||||||
|
self.imported_modules = set()
|
||||||
|
|
||||||
|
get_encoding = staticmethod(getpreferredencoding)
|
||||||
|
'''Get encoding used by the current application
|
||||||
|
|
||||||
|
Usually returns encoding of the current locale.
|
||||||
|
'''
|
||||||
|
|
||||||
|
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
|
||||||
|
``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
|
||||||
|
changed.
|
||||||
|
:param bool load_colors:
|
||||||
|
Determines whether colors configuration from :file:`colors.json`
|
||||||
|
should be (re)loaded.
|
||||||
|
:param bool load_colorscheme:
|
||||||
|
Determines whether colorscheme configuration should be (re)loaded.
|
||||||
|
:param bool load_theme:
|
||||||
|
Determines whether theme configuration should be reloaded.
|
||||||
|
'''
|
||||||
|
common_config_differs = False
|
||||||
|
ext_config_differs = False
|
||||||
|
if load_main:
|
||||||
|
self._purge_configs('main')
|
||||||
|
config = self.load_main_config()
|
||||||
|
self.common_config = finish_common_config(self.get_encoding(), config['common'])
|
||||||
|
if self.common_config != self.prev_common_config:
|
||||||
|
common_config_differs = True
|
||||||
|
|
||||||
|
load_theme = (load_theme
|
||||||
|
or not self.prev_common_config
|
||||||
|
or self.prev_common_config['default_top_theme'] != self.common_config['default_top_theme'])
|
||||||
|
|
||||||
|
self.prev_common_config = self.common_config
|
||||||
|
|
||||||
|
self.import_paths = self.common_config['paths']
|
||||||
|
|
||||||
|
if not self.logger:
|
||||||
|
self.logger = create_logger(self.common_config, self.default_log_stream)
|
||||||
|
|
||||||
|
if not self.pl:
|
||||||
|
self.pl = PowerlineLogger(self.use_daemon_threads, self.logger, self.ext)
|
||||||
|
self.config_loader.pl = self.pl
|
||||||
|
|
||||||
|
if not self.run_once:
|
||||||
|
self.config_loader.set_watcher(self.common_config['watcher'])
|
||||||
|
|
||||||
|
self.get_module_attr = gen_module_attr_getter(self.pl, self.import_paths, self.imported_modules)
|
||||||
|
|
||||||
|
mergedicts(self.renderer_options, dict(
|
||||||
|
pl=self.pl,
|
||||||
|
term_truecolor=self.common_config['term_truecolor'],
|
||||||
|
ambiwidth=self.common_config['ambiwidth'],
|
||||||
|
tmux_escape=self.common_config['additional_escapes'] == 'tmux',
|
||||||
|
screen_escape=self.common_config['additional_escapes'] == 'screen',
|
||||||
|
theme_kwargs={
|
||||||
|
'ext': self.ext,
|
||||||
|
'common_config': self.common_config,
|
||||||
|
'run_once': self.run_once,
|
||||||
|
'shutdown_event': self.shutdown_event,
|
||||||
|
'get_module_attr': self.get_module_attr,
|
||||||
|
},
|
||||||
|
))
|
||||||
|
|
||||||
|
if not self.run_once and self.common_config['reload_config']:
|
||||||
|
interval = self.common_config['interval']
|
||||||
|
self.config_loader.set_interval(interval)
|
||||||
|
self.run_loader_update = (interval is None)
|
||||||
|
if interval is not None and not self.config_loader.is_alive():
|
||||||
|
self.config_loader.start()
|
||||||
|
|
||||||
|
self.ext_config = config['ext'][self.ext]
|
||||||
|
|
||||||
|
top_theme = (
|
||||||
|
self.ext_config.get('top_theme')
|
||||||
|
or self.common_config['default_top_theme']
|
||||||
|
)
|
||||||
|
self.theme_levels = (
|
||||||
|
os.path.join('themes', top_theme),
|
||||||
|
os.path.join('themes', self.ext, '__main__'),
|
||||||
|
)
|
||||||
|
self.renderer_options['theme_kwargs']['top_theme'] = top_theme
|
||||||
|
|
||||||
|
if self.ext_config != self.prev_ext_config:
|
||||||
|
ext_config_differs = True
|
||||||
|
if (
|
||||||
|
not self.prev_ext_config
|
||||||
|
or self.ext_config.get('components') != self.prev_ext_config.get('components')
|
||||||
|
):
|
||||||
|
self.setup_components(self.ext_config.get('components'))
|
||||||
|
if (
|
||||||
|
not self.prev_ext_config
|
||||||
|
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'))
|
||||||
|
load_colorscheme = (
|
||||||
|
load_colorscheme
|
||||||
|
or not self.prev_ext_config
|
||||||
|
or self.prev_ext_config['colorscheme'] != self.ext_config['colorscheme']
|
||||||
|
)
|
||||||
|
load_theme = (
|
||||||
|
load_theme
|
||||||
|
or not self.prev_ext_config
|
||||||
|
or self.prev_ext_config['theme'] != self.ext_config['theme']
|
||||||
|
)
|
||||||
|
self.prev_ext_config = self.ext_config
|
||||||
|
|
||||||
|
create_renderer = load_colors or load_colorscheme or load_theme or common_config_differs or ext_config_differs
|
||||||
|
|
||||||
|
if load_colors:
|
||||||
|
self._purge_configs('colors')
|
||||||
|
self.colors_config = self.load_colors_config()
|
||||||
|
|
||||||
|
if load_colorscheme or load_colors:
|
||||||
|
self._purge_configs('colorscheme')
|
||||||
|
if load_colorscheme:
|
||||||
|
self.colorscheme_config = self.load_colorscheme_config(self.ext_config['colorscheme'])
|
||||||
|
self.renderer_options['theme_kwargs']['colorscheme'] = (
|
||||||
|
Colorscheme(self.colorscheme_config, self.colors_config))
|
||||||
|
|
||||||
|
if load_theme:
|
||||||
|
self._purge_configs('theme')
|
||||||
|
self.renderer_options['theme_config'] = self.load_theme_config(self.ext_config.get('theme', 'default'))
|
||||||
|
|
||||||
|
if create_renderer:
|
||||||
|
Renderer = self.get_module_attr(self.renderer_module, 'renderer')
|
||||||
|
if not Renderer:
|
||||||
|
if hasattr(self, 'renderer'):
|
||||||
|
return
|
||||||
|
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,
|
||||||
|
# but .render still uses old renderer.
|
||||||
|
try:
|
||||||
|
renderer = Renderer(**self.renderer_options)
|
||||||
|
except Exception as e:
|
||||||
|
self.exception('Failed to construct renderer object: {0}', str(e))
|
||||||
|
if not hasattr(self, 'renderer'):
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
self.renderer = renderer
|
||||||
|
|
||||||
|
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
|
||||||
|
to write to some file.
|
||||||
|
'''
|
||||||
|
|
||||||
|
def setup_components(self, components):
|
||||||
|
'''Run component-specific setup
|
||||||
|
|
||||||
|
:param set components:
|
||||||
|
Set of the enabled componets or None.
|
||||||
|
|
||||||
|
Should be overridden by subclasses.
|
||||||
|
'''
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_config_paths():
|
||||||
|
'''Get configuration paths.
|
||||||
|
|
||||||
|
Should be overridden in subclasses in order to provide a way to override
|
||||||
|
used paths.
|
||||||
|
|
||||||
|
:return: list of paths
|
||||||
|
'''
|
||||||
|
return get_config_paths()
|
||||||
|
|
||||||
|
def load_config(self, cfg_path, cfg_type):
|
||||||
|
'''Load configuration and setup watches
|
||||||
|
|
||||||
|
:param str cfg_path:
|
||||||
|
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``
|
||||||
|
file), ``colors``, ``colorscheme``, ``theme``.
|
||||||
|
|
||||||
|
:return: dictionary with loaded configuration.
|
||||||
|
'''
|
||||||
|
return load_config(
|
||||||
|
cfg_path,
|
||||||
|
self.find_config_files,
|
||||||
|
self.config_loader,
|
||||||
|
self.cr_callbacks[cfg_type]
|
||||||
|
)
|
||||||
|
|
||||||
|
def _purge_configs(self, cfg_type):
|
||||||
|
function = self.cr_callbacks[cfg_type]
|
||||||
|
self.config_loader.unregister_functions(set((function,)))
|
||||||
|
self.config_loader.unregister_missing(set(((self.find_config_files, function),)))
|
||||||
|
|
||||||
|
def load_main_config(self):
|
||||||
|
'''Get top-level configuration.
|
||||||
|
|
||||||
|
:return: dictionary with :ref:`top-level configuration <config-main>`.
|
||||||
|
'''
|
||||||
|
return self.load_config('config', 'main')
|
||||||
|
|
||||||
|
def _load_hierarhical_config(self, cfg_type, levels, ignore_levels):
|
||||||
|
'''Load and merge multiple configuration files
|
||||||
|
|
||||||
|
:param str cfg_type:
|
||||||
|
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
|
||||||
|
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
|
||||||
|
listed in this variable must be present.
|
||||||
|
'''
|
||||||
|
config = {}
|
||||||
|
loaded = 0
|
||||||
|
exceptions = []
|
||||||
|
for i, cfg_path in enumerate(levels):
|
||||||
|
try:
|
||||||
|
lvl_config = self.load_config(cfg_path, cfg_type)
|
||||||
|
except IOError as e:
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
tb = sys.exc_info()[2]
|
||||||
|
exceptions.append((e, tb))
|
||||||
|
else:
|
||||||
|
exceptions.append(e)
|
||||||
|
else:
|
||||||
|
if i not in ignore_levels:
|
||||||
|
loaded += 1
|
||||||
|
mergedicts(config, lvl_config)
|
||||||
|
if not loaded:
|
||||||
|
for exception in exceptions:
|
||||||
|
if type(exception) is tuple:
|
||||||
|
e = exception[0]
|
||||||
|
else:
|
||||||
|
e = exception
|
||||||
|
self.exception('Failed to load %s: {0}' % cfg_type, e, exception=exception)
|
||||||
|
raise e
|
||||||
|
return config
|
||||||
|
|
||||||
|
def load_colorscheme_config(self, name):
|
||||||
|
'''Get colorscheme.
|
||||||
|
|
||||||
|
:param str name:
|
||||||
|
Name of the colorscheme to load.
|
||||||
|
|
||||||
|
:return: dictionary with :ref:`colorscheme configuration <config-colorschemes>`.
|
||||||
|
'''
|
||||||
|
levels = (
|
||||||
|
os.path.join('colorschemes', name),
|
||||||
|
os.path.join('colorschemes', self.ext, '__main__'),
|
||||||
|
os.path.join('colorschemes', self.ext, name),
|
||||||
|
)
|
||||||
|
return self._load_hierarhical_config('colorscheme', levels, (1,))
|
||||||
|
|
||||||
|
def load_theme_config(self, name):
|
||||||
|
'''Get theme configuration.
|
||||||
|
|
||||||
|
:param str name:
|
||||||
|
Name of the theme to load.
|
||||||
|
|
||||||
|
:return: dictionary with :ref:`theme configuration <config-themes>`
|
||||||
|
'''
|
||||||
|
levels = self.theme_levels + (
|
||||||
|
os.path.join('themes', self.ext, name),
|
||||||
|
)
|
||||||
|
return self._load_hierarhical_config('theme', levels, (0, 1,))
|
||||||
|
|
||||||
|
def load_colors_config(self):
|
||||||
|
'''Get colorscheme.
|
||||||
|
|
||||||
|
:return: dictionary with :ref:`colors configuration <config-colors>`.
|
||||||
|
'''
|
||||||
|
return self.load_config('colors', 'colors')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_local_themes(local_themes):
|
||||||
|
'''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
|
||||||
|
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
|
||||||
|
``__init__`` arguments, refer to its documentation.
|
||||||
|
'''
|
||||||
|
return None
|
||||||
|
|
||||||
|
def update_renderer(self):
|
||||||
|
'''Updates/creates a renderer if needed.'''
|
||||||
|
if self.run_loader_update:
|
||||||
|
self.config_loader.update()
|
||||||
|
cr_kwargs = None
|
||||||
|
with self.cr_kwargs_lock:
|
||||||
|
if self.cr_kwargs:
|
||||||
|
cr_kwargs = self.cr_kwargs.copy()
|
||||||
|
if cr_kwargs:
|
||||||
|
try:
|
||||||
|
self.create_renderer(**cr_kwargs)
|
||||||
|
except Exception as e:
|
||||||
|
self.exception('Failed to create renderer: {0}', str(e))
|
||||||
|
if hasattr(self, 'renderer'):
|
||||||
|
with self.cr_kwargs_lock:
|
||||||
|
self.cr_kwargs.clear()
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
with self.cr_kwargs_lock:
|
||||||
|
self.cr_kwargs.clear()
|
||||||
|
|
||||||
|
def render(self, *args, **kwargs):
|
||||||
|
'''Update/create renderer if needed and pass all arguments further to
|
||||||
|
``self.renderer.render()``.
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
self.update_renderer()
|
||||||
|
return self.renderer.render(*args, **kwargs)
|
||||||
|
except Exception as e:
|
||||||
|
try:
|
||||||
|
self.exception('Failed to render: {0}', str(e))
|
||||||
|
except Exception as e:
|
||||||
|
# Updates e variable to new value, masking previous one.
|
||||||
|
# Normally it is the same exception (due to raise in case pl is
|
||||||
|
# unset), but it may also show error in logger. Note that latter
|
||||||
|
# is not logged by logger for obvious reasons, thus this also
|
||||||
|
# prevents us from seeing logger traceback.
|
||||||
|
pass
|
||||||
|
return FailedUnicode(safe_unicode(e))
|
||||||
|
|
||||||
|
def render_above_lines(self, *args, **kwargs):
|
||||||
|
'''Like .render(), but for ``self.renderer.render_above_lines()``
|
||||||
|
'''
|
||||||
|
try:
|
||||||
|
self.update_renderer()
|
||||||
|
for line in self.renderer.render_above_lines(*args, **kwargs):
|
||||||
|
yield line
|
||||||
|
except Exception as e:
|
||||||
|
try:
|
||||||
|
self.exception('Failed to render: {0}', str(e))
|
||||||
|
except Exception as e:
|
||||||
|
# Updates e variable to new value, masking previous one.
|
||||||
|
# Normally it is the same exception (due to raise in case pl is
|
||||||
|
# unset), but it may also show error in logger. Note that latter
|
||||||
|
# is not logged by logger for obvious reasons, thus this also
|
||||||
|
# prevents us from seeing logger traceback.
|
||||||
|
pass
|
||||||
|
yield FailedUnicode(safe_unicode(e))
|
||||||
|
|
||||||
|
def setup(self, *args, **kwargs):
|
||||||
|
'''Setup the environment to use powerline.
|
||||||
|
|
||||||
|
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()
|
||||||
|
self.setup_args = args
|
||||||
|
self.setup_kwargs.update(kwargs)
|
||||||
|
self.do_setup(*args, **kwargs)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def do_setup():
|
||||||
|
'''Function that does initialization
|
||||||
|
|
||||||
|
Should be overridden by subclasses. May accept any number of regular or
|
||||||
|
keyword arguments.
|
||||||
|
'''
|
||||||
|
pass
|
||||||
|
|
||||||
|
def reload(self):
|
||||||
|
'''Reload powerline after update.
|
||||||
|
|
||||||
|
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
|
||||||
|
updates reference to main powerline object.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
Not guaranteed to work properly, use it at your own risk. It
|
||||||
|
may break your python code.
|
||||||
|
'''
|
||||||
|
import sys
|
||||||
|
modules = self.imported_modules | set((module for module in sys.modules if module.startswith('powerline')))
|
||||||
|
modules_holder = []
|
||||||
|
for module in modules:
|
||||||
|
try:
|
||||||
|
# Needs to hold module to prevent garbage collecting until they
|
||||||
|
# are all reloaded.
|
||||||
|
modules_holder.append(sys.modules.pop(module))
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
PowerlineClass = getattr(__import__(self.__module__, fromlist=(self.__class__.__name__,)), self.__class__.__name__)
|
||||||
|
self.shutdown(set_event=True)
|
||||||
|
init_args, init_kwargs = self.init_args
|
||||||
|
powerline = PowerlineClass(*init_args, **init_kwargs)
|
||||||
|
powerline.setup(*self.setup_args, **self.setup_kwargs)
|
||||||
|
|
||||||
|
def shutdown(self, set_event=True):
|
||||||
|
'''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
|
||||||
|
application.
|
||||||
|
|
||||||
|
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:
|
||||||
|
self.shutdown_event.set()
|
||||||
|
try:
|
||||||
|
self.renderer.shutdown()
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
functions = tuple(self.cr_callbacks.values())
|
||||||
|
self.config_loader.unregister_functions(set(functions))
|
||||||
|
self.config_loader.unregister_missing(set(((self.find_config_files, function) for function in functions)))
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, *args):
|
||||||
|
self.shutdown()
|
||||||
|
|
||||||
|
def exception(self, msg, *args, **kwargs):
|
||||||
|
if 'prefix' not in kwargs:
|
||||||
|
kwargs['prefix'] = 'powerline'
|
||||||
|
exception = kwargs.pop('exception', None)
|
||||||
|
pl = getattr(self, 'pl', None) or get_fallback_logger(self.default_log_stream)
|
||||||
|
if exception:
|
||||||
|
try:
|
||||||
|
reraise(exception)
|
||||||
|
except Exception:
|
||||||
|
return pl.exception(msg, *args, **kwargs)
|
||||||
|
return pl.exception(msg, *args, **kwargs)
|
0
powerline/bindings/__init__.py
Normal file
41
powerline/bindings/awesome/powerline-awesome.py
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
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')
|
||||||
|
|
||||||
|
|
||||||
|
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))
|
11
powerline/bindings/awesome/powerline.lua
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
local wibox = require('wibox')
|
||||||
|
local awful = require('awful')
|
||||||
|
|
||||||
|
powerline_widget = wibox.widget.textbox()
|
||||||
|
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)
|
99
powerline/bindings/bash/powerline.sh
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
_powerline_columns_fallback() {
|
||||||
|
if which stty &>/dev/null ; then
|
||||||
|
local cols="$(stty size 2>/dev/null)"
|
||||||
|
if ! test -z "$cols" ; then
|
||||||
|
echo "${cols#* }"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo 0
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_tmux_setenv() {
|
||||||
|
TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`tmux display -p "#D" | tr -d %` "$2"
|
||||||
|
TMUX="$_POWERLINE_TMUX" tmux refresh -S
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_tmux_set_pwd() {
|
||||||
|
if test "x$_POWERLINE_SAVED_PWD" != "x$PWD" ; then
|
||||||
|
_POWERLINE_SAVED_PWD="$PWD"
|
||||||
|
_powerline_tmux_setenv PWD "$PWD"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_tmux_set_columns() {
|
||||||
|
_powerline_tmux_setenv COLUMNS "${COLUMNS:-`_powerline_columns_fallback`}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_init_tmux_support() {
|
||||||
|
if test -n "$TMUX" && tmux refresh -S &>/dev/null ; then
|
||||||
|
# TMUX variable may be unset to create new tmux session inside this one
|
||||||
|
_POWERLINE_TMUX="$TMUX"
|
||||||
|
|
||||||
|
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'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_local_prompt() {
|
||||||
|
# Arguments: side, renderer_module arg, last_exit_code, jobnum, local theme
|
||||||
|
$POWERLINE_COMMAND shell $1 \
|
||||||
|
$2 \
|
||||||
|
--last_exit_code=$3 \
|
||||||
|
--jobnum=$4 \
|
||||||
|
--renderer_arg="client_id=$$" \
|
||||||
|
--renderer_arg="local_theme=$5"
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_prompt() {
|
||||||
|
# Arguments: side, last_exit_code, jobnum
|
||||||
|
$POWERLINE_COMMAND shell $1 \
|
||||||
|
--width="${COLUMNS:-$(_powerline_columns_fallback)}" \
|
||||||
|
-r.bash \
|
||||||
|
--last_exit_code=$2 \
|
||||||
|
--jobnum=$3 \
|
||||||
|
--renderer_arg="client_id=$$"
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_set_prompt() {
|
||||||
|
local last_exit_code=$?
|
||||||
|
local jobnum="$(jobs -p|wc -l)"
|
||||||
|
PS1="$(_powerline_prompt aboveleft $last_exit_code $jobnum)"
|
||||||
|
if test -n "$POWERLINE_SHELL_CONTINUATION$POWERLINE_BASH_CONTINUATION" ; then
|
||||||
|
PS2="$(_powerline_local_prompt left -r.bash $last_exit_code $jobnum continuation)"
|
||||||
|
fi
|
||||||
|
if test -n "$POWERLINE_SHELL_SELECT$POWERLINE_BASH_SELECT" ; then
|
||||||
|
PS3="$(_powerline_local_prompt left '' $last_exit_code $jobnum select)"
|
||||||
|
fi
|
||||||
|
return $last_exit_code
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_setup_prompt() {
|
||||||
|
VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||||
|
if test -z "${POWERLINE_COMMAND}" ; then
|
||||||
|
POWERLINE_COMMAND="$("$POWERLINE_CONFIG" 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)"
|
||||||
|
}
|
||||||
|
|
||||||
|
if test -z "${POWERLINE_CONFIG}" ; then
|
||||||
|
if which powerline-config >/dev/null ; then
|
||||||
|
POWERLINE_CONFIG=powerline-config
|
||||||
|
else
|
||||||
|
POWERLINE_CONFIG="$(dirname "$BASH_SOURCE")/../../../scripts/powerline-config"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if "${POWERLINE_CONFIG}" shell --shell=bash uses prompt ; then
|
||||||
|
_powerline_setup_prompt
|
||||||
|
fi
|
||||||
|
if "${POWERLINE_CONFIG}" shell --shell=bash uses tmux ; then
|
||||||
|
_powerline_init_tmux_support
|
||||||
|
fi
|
149
powerline/bindings/config.py
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from locale import getpreferredencoding
|
||||||
|
|
||||||
|
from powerline.config import POWERLINE_ROOT, TMUX_CONFIG_DIRECTORY
|
||||||
|
from powerline.lib.config import ConfigLoader
|
||||||
|
from powerline import generate_config_finder, load_config, create_logger, PowerlineLogger, finish_common_config
|
||||||
|
from powerline.lib.shell import which
|
||||||
|
from powerline.bindings.tmux import TmuxVersionInfo, run_tmux_command, get_tmux_version
|
||||||
|
|
||||||
|
|
||||||
|
CONFIG_FILE_NAME = re.compile(r'powerline_tmux_(?P<major>\d+)\.(?P<minor>\d+)(?P<suffix>[a-z]+)?(?:_(?P<mod>plus|minus))?\.conf')
|
||||||
|
CONFIG_MATCHERS = {
|
||||||
|
None: (lambda a, b: a.major == b.major and a.minor == b.minor),
|
||||||
|
'plus': (lambda a, b: a[:2] <= b[:2]),
|
||||||
|
'minus': (lambda a, b: a[:2] >= b[:2]),
|
||||||
|
}
|
||||||
|
CONFIG_PRIORITY = {
|
||||||
|
None: 3,
|
||||||
|
'plus': 2,
|
||||||
|
'minus': 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def list_all_tmux_configs():
|
||||||
|
'''List all version-specific tmux configuration files'''
|
||||||
|
directory = TMUX_CONFIG_DIRECTORY
|
||||||
|
for root, dirs, files in os.walk(directory):
|
||||||
|
dirs[:] = ()
|
||||||
|
for fname in files:
|
||||||
|
match = CONFIG_FILE_NAME.match(fname)
|
||||||
|
if match:
|
||||||
|
assert match.group('suffix') is None
|
||||||
|
yield (
|
||||||
|
os.path.join(root, fname),
|
||||||
|
CONFIG_MATCHERS[match.group('mod')],
|
||||||
|
CONFIG_PRIORITY[match.group('mod')],
|
||||||
|
TmuxVersionInfo(
|
||||||
|
int(match.group('major')),
|
||||||
|
int(match.group('minor')),
|
||||||
|
match.group('suffix'),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_tmux_configs(version):
|
||||||
|
'''Get tmux configuration suffix given parsed tmux version
|
||||||
|
|
||||||
|
:param TmuxVersionInfo version: Parsed tmux version.
|
||||||
|
'''
|
||||||
|
for fname, matcher, priority, file_version in list_all_tmux_configs():
|
||||||
|
if matcher(file_version, version):
|
||||||
|
yield (fname, priority + file_version.minor * 10 + file_version.major * 10000)
|
||||||
|
|
||||||
|
|
||||||
|
def source_tmux_files(pl, args):
|
||||||
|
'''Source relevant version-specific tmux configuration files
|
||||||
|
|
||||||
|
Files are sourced in the following order:
|
||||||
|
* First relevant files with older versions are sourced.
|
||||||
|
* If files for same versions are to be sourced then first _minus files are
|
||||||
|
sourced, then _plus files and then files without _minus or _plus suffixes.
|
||||||
|
'''
|
||||||
|
version = get_tmux_version(pl)
|
||||||
|
for fname, priority in sorted(get_tmux_configs(version), key=(lambda v: v[1])):
|
||||||
|
run_tmux_command('source', fname)
|
||||||
|
if not os.environ.get('POWERLINE_COMMAND'):
|
||||||
|
cmd = deduce_command()
|
||||||
|
if cmd:
|
||||||
|
run_tmux_command('set-environment', '-g', 'POWERLINE_COMMAND', deduce_command())
|
||||||
|
run_tmux_command('refresh-client')
|
||||||
|
|
||||||
|
|
||||||
|
def get_main_config(args):
|
||||||
|
find_config_files = generate_config_finder()
|
||||||
|
config_loader = ConfigLoader(run_once=True)
|
||||||
|
return load_config('config', find_config_files, config_loader)
|
||||||
|
|
||||||
|
|
||||||
|
def create_powerline_logger(args):
|
||||||
|
config = get_main_config(args)
|
||||||
|
common_config = finish_common_config(getpreferredencoding(), config['common'])
|
||||||
|
logger = create_logger(common_config)
|
||||||
|
return PowerlineLogger(use_daemon_threads=True, logger=logger, ext='config')
|
||||||
|
|
||||||
|
|
||||||
|
def check_command(cmd):
|
||||||
|
if which(cmd):
|
||||||
|
return cmd
|
||||||
|
|
||||||
|
|
||||||
|
def deduce_command():
|
||||||
|
'''Deduce which command to use for ``powerline``
|
||||||
|
|
||||||
|
Candidates:
|
||||||
|
|
||||||
|
* ``powerline``. Present only when installed system-wide.
|
||||||
|
* ``{powerline_root}/scripts/powerline``. Present after ``pip install -e``
|
||||||
|
was run and C client was compiled (in this case ``pip`` does not install
|
||||||
|
binary file).
|
||||||
|
* ``{powerline_root}/client/powerline.sh``. Useful when ``sh``, ``sed`` and
|
||||||
|
``socat`` are present, but ``pip`` or ``setup.py`` was not run.
|
||||||
|
* ``{powerline_root}/client/powerline.py``. Like above, but when one of
|
||||||
|
``sh``, ``sed`` and ``socat`` was not present.
|
||||||
|
* ``powerline-render``. Should not really ever be used.
|
||||||
|
* ``{powerline_root}/scripts/powerline-render``. Same.
|
||||||
|
'''
|
||||||
|
return (
|
||||||
|
None
|
||||||
|
or check_command('powerline')
|
||||||
|
or check_command(os.path.join(POWERLINE_ROOT, 'scripts', 'powerline'))
|
||||||
|
or ((which('sh') and which('sed') and which('socat'))
|
||||||
|
and check_command(os.path.join(POWERLINE_ROOT, 'client', 'powerline.sh')))
|
||||||
|
or check_command(os.path.join(POWERLINE_ROOT, 'client', 'powerline.py'))
|
||||||
|
or check_command('powerline-render')
|
||||||
|
or check_command(os.path.join(POWERLINE_ROOT, 'scripts', 'powerline-render'))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def shell_command(pl, args):
|
||||||
|
cmd = deduce_command()
|
||||||
|
if cmd:
|
||||||
|
print(cmd)
|
||||||
|
else:
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def uses(pl, args):
|
||||||
|
component = args.component
|
||||||
|
if not component:
|
||||||
|
raise ValueError('Must specify component')
|
||||||
|
shell = args.shell
|
||||||
|
template = 'POWERLINE_NO_{shell}_{component}'
|
||||||
|
for sh in (shell, 'shell') if shell else ('shell'):
|
||||||
|
varname = template.format(shell=sh.upper(), component=component.upper())
|
||||||
|
if os.environ.get(varname):
|
||||||
|
print ('HERE')
|
||||||
|
sys.exit(1)
|
||||||
|
config = get_main_config(args)
|
||||||
|
if component in config.get('ext', {}).get('shell', {}).get('components', ('tmux', 'prompt')):
|
||||||
|
sys.exit(0)
|
||||||
|
else:
|
||||||
|
print ('THERE')
|
||||||
|
sys.exit(1)
|
103
powerline/bindings/fish/powerline-setup.fish
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
function powerline-setup
|
||||||
|
function _powerline_columns_fallback
|
||||||
|
if which stty >/dev/null
|
||||||
|
if stty size >/dev/null
|
||||||
|
stty size | cut -d' ' -f2
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
echo 0
|
||||||
|
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"
|
||||||
|
if which powerline-config >/dev/null
|
||||||
|
set -g POWERLINE_CONFIG powerline-config
|
||||||
|
else
|
||||||
|
set -g POWERLINE_CONFIG (dirname (status -f))/../../../scripts/powerline-config
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if eval $POWERLINE_CONFIG shell --shell=fish uses prompt
|
||||||
|
if test -z "$POWERLINE_COMMAND"
|
||||||
|
set -g POWERLINE_COMMAND (eval $POWERLINE_CONFIG shell command)
|
||||||
|
end
|
||||||
|
function --on-variable fish_bind_mode _powerline_bind_mode
|
||||||
|
set -g -x _POWERLINE_MODE $fish_bind_mode
|
||||||
|
end
|
||||||
|
function --on-variable fish_key_bindings _powerline_set_default_mode
|
||||||
|
if test x$fish_key_bindings != xfish_vi_key_bindings
|
||||||
|
set -g -x _POWERLINE_DEFAULT_MODE default
|
||||||
|
else
|
||||||
|
set -g -e _POWERLINE_DEFAULT_MODE
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function --on-variable POWERLINE_COMMAND _powerline_update
|
||||||
|
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
|
||||||
|
# the same value in two shells
|
||||||
|
set -l addargs "$addargs --renderer_arg=client_id="(random)
|
||||||
|
set -l addargs "$addargs --width=\$_POWERLINE_COLUMNS"
|
||||||
|
set -l promptside
|
||||||
|
set -l rpromptpast
|
||||||
|
set -l columnsexpr
|
||||||
|
if test -z "$POWERLINE_NO_FISH_ABOVE$POWERLINE_NO_SHELL_ABOVE"
|
||||||
|
set promptside aboveleft
|
||||||
|
set rpromptpast 'echo -n " "'
|
||||||
|
set columnsexpr '(math (_powerline_columns) - 1)'
|
||||||
|
else
|
||||||
|
set promptside left
|
||||||
|
set rpromptpast
|
||||||
|
set columnsexpr '(_powerline_columns)'
|
||||||
|
end
|
||||||
|
eval "
|
||||||
|
function fish_prompt
|
||||||
|
$POWERLINE_COMMAND shell $promptside $addargs
|
||||||
|
end
|
||||||
|
function fish_right_prompt
|
||||||
|
$POWERLINE_COMMAND shell right $addargs
|
||||||
|
$rpromptpast
|
||||||
|
end
|
||||||
|
function --on-signal WINCH _powerline_set_columns
|
||||||
|
set -g _POWERLINE_COLUMNS $columnsexpr
|
||||||
|
end
|
||||||
|
"
|
||||||
|
_powerline_set_columns
|
||||||
|
end
|
||||||
|
_powerline_bind_mode
|
||||||
|
_powerline_set_default_mode
|
||||||
|
_powerline_update
|
||||||
|
end
|
||||||
|
if eval $POWERLINE_CONFIG 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
|
||||||
|
end
|
||||||
|
function --on-variable PWD _powerline_tmux_set_pwd
|
||||||
|
_powerline_tmux_setenv PWD "$PWD"
|
||||||
|
end
|
||||||
|
function --on-signal WINCH _powerline_tmux_set_columns
|
||||||
|
_powerline_tmux_setenv COLUMNS (_powerline_columns)
|
||||||
|
end
|
||||||
|
_powerline_tmux_set_columns
|
||||||
|
_powerline_tmux_set_pwd
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# vim: ft=fish
|
45
powerline/bindings/i3/powerline-i3.py
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
from threading import Lock
|
||||||
|
|
||||||
|
import i3
|
||||||
|
|
||||||
|
from powerline import Powerline
|
||||||
|
from powerline.lib.monotonic import monotonic
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
name = 'wm'
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
name = sys.argv[1]
|
||||||
|
|
||||||
|
powerline = Powerline(name, renderer_module='i3bar')
|
||||||
|
powerline.update_renderer()
|
||||||
|
|
||||||
|
interval = 0.5
|
||||||
|
|
||||||
|
print ('{"version": 1, "custom_workspace": true}')
|
||||||
|
print ('[')
|
||||||
|
print ('\t[[],[]]')
|
||||||
|
|
||||||
|
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]')
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
sub = i3.Subscription(render, 'workspace')
|
||||||
|
|
||||||
|
while True:
|
||||||
|
start_time = monotonic()
|
||||||
|
render()
|
||||||
|
time.sleep(max(interval - (monotonic() - start_time), 0.1))
|
0
powerline/bindings/ipython/__init__.py
Normal file
106
powerline/bindings/ipython/post_0_11.py
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
from weakref import ref
|
||||||
|
|
||||||
|
from IPython.core.prompts import PromptManager
|
||||||
|
from IPython.core.magic import Magics, magics_class, line_magic
|
||||||
|
|
||||||
|
from powerline.ipython import IPythonPowerline, RewriteResult
|
||||||
|
|
||||||
|
|
||||||
|
@magics_class
|
||||||
|
class PowerlineMagics(Magics):
|
||||||
|
def __init__(self, ip, powerline):
|
||||||
|
super(PowerlineMagics, self).__init__(ip)
|
||||||
|
self._powerline = powerline
|
||||||
|
|
||||||
|
@line_magic
|
||||||
|
def powerline(self, line):
|
||||||
|
if line == 'reload':
|
||||||
|
self._powerline.reload()
|
||||||
|
else:
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
class ShutdownHook(object):
|
||||||
|
powerline = lambda: None
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
from IPython.core.hooks import TryNext
|
||||||
|
powerline = self.powerline()
|
||||||
|
if powerline is not None:
|
||||||
|
powerline.shutdown()
|
||||||
|
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.paths = config.get('paths')
|
||||||
|
super(ConfigurableIPythonPowerline, self).init()
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
ip.prompt_manager = prompt_manager
|
||||||
|
ip.register_magics(magics)
|
||||||
|
|
||||||
|
|
||||||
|
old_prompt_manager = None
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
def unload_ipython_extension(ip):
|
||||||
|
ip.prompt_manager = old_prompt_manager
|
146
powerline/bindings/ipython/pre_0_11.py
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
from weakref import ref
|
||||||
|
|
||||||
|
from IPython.Prompts import BasePrompt
|
||||||
|
from IPython.ipapi import get as get_ipython
|
||||||
|
from IPython.ipapi import TryNext
|
||||||
|
|
||||||
|
from powerline.ipython import IPythonPowerline, RewriteResult
|
||||||
|
from powerline.lib.unicode import string
|
||||||
|
|
||||||
|
|
||||||
|
class IPythonInfo(object):
|
||||||
|
def __init__(self, cache):
|
||||||
|
self._cache = cache
|
||||||
|
|
||||||
|
@property
|
||||||
|
def prompt_count(self):
|
||||||
|
return self._cache.prompt_count
|
||||||
|
|
||||||
|
|
||||||
|
class PowerlinePrompt(BasePrompt):
|
||||||
|
def __init__(self, powerline, powerline_last_in, old_prompt):
|
||||||
|
self.powerline = powerline
|
||||||
|
self.powerline_last_in = powerline_last_in
|
||||||
|
self.powerline_segment_info = IPythonInfo(old_prompt.cache)
|
||||||
|
self.cache = old_prompt.cache
|
||||||
|
if hasattr(old_prompt, 'sep'):
|
||||||
|
self.sep = old_prompt.sep
|
||||||
|
self.pad_left = False
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
self.set_p_str()
|
||||||
|
return string(self.p_str)
|
||||||
|
|
||||||
|
def set_p_str(self):
|
||||||
|
self.p_str, self.p_str_nocolor, self.powerline_prompt_width = (
|
||||||
|
self.powerline.render(
|
||||||
|
is_prompt=self.powerline_is_prompt,
|
||||||
|
side='left',
|
||||||
|
output_raw=True,
|
||||||
|
output_width=True,
|
||||||
|
segment_info=self.powerline_segment_info,
|
||||||
|
matcher_info=self.powerline_prompt_type,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def set_colors():
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class PowerlinePrompt1(PowerlinePrompt):
|
||||||
|
powerline_prompt_type = 'in'
|
||||||
|
powerline_is_prompt = True
|
||||||
|
rspace = re.compile(r'(\s*)$')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
self.cache.prompt_count += 1
|
||||||
|
self.set_p_str()
|
||||||
|
self.cache.last_prompt = self.p_str_nocolor.split('\n')[-1]
|
||||||
|
return string(self.p_str)
|
||||||
|
|
||||||
|
def set_p_str(self):
|
||||||
|
super(PowerlinePrompt1, self).set_p_str()
|
||||||
|
self.nrspaces = len(self.rspace.search(self.p_str_nocolor).group())
|
||||||
|
self.powerline_last_in['nrspaces'] = self.nrspaces
|
||||||
|
|
||||||
|
def auto_rewrite(self):
|
||||||
|
return RewriteResult(self.powerline.render(
|
||||||
|
is_prompt=False,
|
||||||
|
side='left',
|
||||||
|
matcher_info='rewrite',
|
||||||
|
segment_info=self.powerline_segment_info) + (' ' * self.nrspaces)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class PowerlinePromptOut(PowerlinePrompt):
|
||||||
|
powerline_prompt_type = 'out'
|
||||||
|
powerline_is_prompt = False
|
||||||
|
|
||||||
|
def set_p_str(self):
|
||||||
|
super(PowerlinePromptOut, self).set_p_str()
|
||||||
|
spaces = ' ' * self.powerline_last_in['nrspaces']
|
||||||
|
self.p_str += spaces
|
||||||
|
self.p_str_nocolor += spaces
|
||||||
|
|
||||||
|
|
||||||
|
class PowerlinePrompt2(PowerlinePromptOut):
|
||||||
|
powerline_prompt_type = 'in2'
|
||||||
|
powerline_is_prompt = True
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigurableIPythonPowerline(IPythonPowerline):
|
||||||
|
def init(self, config_overrides=None, theme_overrides={}, paths=None):
|
||||||
|
self.config_overrides = config_overrides
|
||||||
|
self.theme_overrides = theme_overrides
|
||||||
|
self.paths = paths
|
||||||
|
super(ConfigurableIPythonPowerline, self).init()
|
||||||
|
|
||||||
|
def ipython_magic(self, ip, parameter_s=''):
|
||||||
|
if parameter_s == 'reload':
|
||||||
|
self.reload()
|
||||||
|
else:
|
||||||
|
raise ValueError('Expected `reload`, but got {0}'.format(parameter_s))
|
||||||
|
|
||||||
|
def do_setup(self, ip, shutdown_hook):
|
||||||
|
last_in = {'nrspaces': 0}
|
||||||
|
for attr, prompt_class in (
|
||||||
|
('prompt1', PowerlinePrompt1),
|
||||||
|
('prompt2', PowerlinePrompt2),
|
||||||
|
('prompt_out', PowerlinePromptOut)
|
||||||
|
):
|
||||||
|
old_prompt = getattr(ip.IP.outputcache, attr)
|
||||||
|
prompt = prompt_class(self, last_in, old_prompt)
|
||||||
|
setattr(ip.IP.outputcache, attr, prompt)
|
||||||
|
ip.expose_magic('powerline', self.ipython_magic)
|
||||||
|
shutdown_hook.powerline = ref(self)
|
||||||
|
|
||||||
|
|
||||||
|
class ShutdownHook(object):
|
||||||
|
powerline = lambda: None
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
from IPython.ipapi import TryNext
|
||||||
|
powerline = self.powerline()
|
||||||
|
if powerline is not None:
|
||||||
|
powerline.shutdown()
|
||||||
|
raise TryNext()
|
||||||
|
|
||||||
|
|
||||||
|
def setup(**kwargs):
|
||||||
|
ip = get_ipython()
|
||||||
|
|
||||||
|
powerline = ConfigurableIPythonPowerline(**kwargs)
|
||||||
|
shutdown_hook = ShutdownHook()
|
||||||
|
|
||||||
|
def late_startup_hook():
|
||||||
|
powerline.setup(ip, shutdown_hook)
|
||||||
|
raise TryNext()
|
||||||
|
|
||||||
|
ip.IP.hooks.late_startup_hook.add(late_startup_hook)
|
||||||
|
ip.IP.hooks.shutdown_hook.add(shutdown_hook)
|
0
powerline/bindings/qtile/__init__.py
Normal file
37
powerline/bindings/qtile/widget.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
from libqtile import bar
|
||||||
|
from libqtile.widget import base
|
||||||
|
|
||||||
|
from powerline import Powerline as PowerlineCore
|
||||||
|
|
||||||
|
|
||||||
|
class Powerline(base._TextBox):
|
||||||
|
def __init__(self, timeout=2, text=" ", width=bar.CALCULATED, **config):
|
||||||
|
base._TextBox.__init__(self, text, width, **config)
|
||||||
|
self.timeout_add(timeout, self.update)
|
||||||
|
self.powerline = PowerlineCore(ext='wm', renderer_module='pango_markup')
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
if not self.configured:
|
||||||
|
return True
|
||||||
|
self.text = self.powerline.render(side='right')
|
||||||
|
self.bar.draw()
|
||||||
|
return True
|
||||||
|
|
||||||
|
def cmd_update(self, text):
|
||||||
|
self.update(text)
|
||||||
|
|
||||||
|
def cmd_get(self):
|
||||||
|
return self.text
|
||||||
|
|
||||||
|
def _configure(self, qtile, bar):
|
||||||
|
base._TextBox._configure(self, qtile, bar)
|
||||||
|
self.layout = self.drawer.textlayout(
|
||||||
|
self.text,
|
||||||
|
self.foreground,
|
||||||
|
self.font,
|
||||||
|
self.fontsize,
|
||||||
|
self.fontshadow,
|
||||||
|
markup=True)
|
235
powerline/bindings/shell/powerline.sh
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
_POWERLINE_SOURCED="$_"
|
||||||
|
_powerline_columns_fallback() {
|
||||||
|
if which stty >/dev/null ; then
|
||||||
|
# Ksh does not have “local” built-in
|
||||||
|
_powerline_cols="$(stty size 2>/dev/null)"
|
||||||
|
if ! test -z "$_powerline_cols" ; then
|
||||||
|
echo "${_powerline_cols#* }"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo 0
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_has_jobs_in_subshell() {
|
||||||
|
if test -n "$_POWERLINE_HAS_JOBS_IN_SUBSHELL" ; then
|
||||||
|
return $_POWERLINE_HAS_JOBS_IN_SUBSHELL
|
||||||
|
elif test -z "$1" ; then
|
||||||
|
sleep 1 &
|
||||||
|
# Check whether shell outputs anything in a subshell when using jobs
|
||||||
|
# built-in. Shells like dash will not output anything meaning that
|
||||||
|
# I have to bother with temporary files.
|
||||||
|
test "$(jobs -p|wc -l)" -gt 0
|
||||||
|
else
|
||||||
|
case "$1" in
|
||||||
|
dash|bb|ash) return 1 ;;
|
||||||
|
mksh|ksh|bash) return 0 ;;
|
||||||
|
*) _powerline_has_jobs_in_subshell ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
_POWERLINE_HAS_JOBS_IN_SUBSHELL=$?
|
||||||
|
return $_POWERLINE_HAS_JOBS_IN_SUBSHELL
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_set_append_trap() {
|
||||||
|
if _powerline_has_jobs_in_subshell "$@" ; then
|
||||||
|
_powerline_append_trap() {
|
||||||
|
# Arguments: command, signal
|
||||||
|
# Ksh does not have “local” built-in
|
||||||
|
_powerline_traps="$(trap)"
|
||||||
|
if echo "$_powerline_traps" | grep -cm1 $2'$' >/dev/null ; then
|
||||||
|
_powerline_traps="$(echo "$_powerline_traps" | sed "s/ $2/'\\n$1' $2/")"
|
||||||
|
eval "$_powerline_traps"
|
||||||
|
else
|
||||||
|
trap "$1" $2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_powerline_append_trap() {
|
||||||
|
# Arguments: command, signal
|
||||||
|
_powerline_create_temp
|
||||||
|
trap > $_POWERLINE_TEMP
|
||||||
|
if grep -cm1 $2'$' $_POWERLINE_TEMP >/dev/null ; then
|
||||||
|
sed -i -e "s/ $2/'\\n$1' $2/"
|
||||||
|
. $_POWERLINE_TEMP
|
||||||
|
else
|
||||||
|
trap "$1" $2
|
||||||
|
fi
|
||||||
|
echo -n > $_POWERLINE_TEMP
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
_powerline_set_append_trap() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_create_temp() {
|
||||||
|
if test -z "$_POWERLINE_TEMP" || ! test -e "$_POWERLINE_TEMP" ; then
|
||||||
|
_POWERLINE_TEMP="$(mktemp)"
|
||||||
|
_powerline_append_trap 'rm $_POWERLINE_TEMP' EXIT
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_set_set_jobs() {
|
||||||
|
if _powerline_has_jobs_in_subshell "$@" ; then
|
||||||
|
_powerline_set_jobs() {
|
||||||
|
_POWERLINE_JOBS="$(jobs -p|wc -l)"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_powerline_set_append_trap "$@"
|
||||||
|
_POWERLINE_PID=$$
|
||||||
|
_powerline_append_trap '_powerline_do_set_jobs' USR1
|
||||||
|
_powerline_do_set_jobs() {
|
||||||
|
_powerline_create_temp
|
||||||
|
jobs -p > $_POWERLINE_TEMP
|
||||||
|
}
|
||||||
|
# This command will always be launched from a subshell, thus a hack is
|
||||||
|
# needed to run `jobs -p` outside of the subshell.
|
||||||
|
_powerline_set_jobs() {
|
||||||
|
kill -USR1 $_POWERLINE_PID
|
||||||
|
# Note: most likely this will read data from the previous run. Tests
|
||||||
|
# show that it is OK for some reasons.
|
||||||
|
_POWERLINE_JOBS="$(wc -l < $_POWERLINE_TEMP)"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
_powerline_set_set_jobs() {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_set_command() {
|
||||||
|
if test -z "${POWERLINE_COMMAND}" ; then
|
||||||
|
POWERLINE_COMMAND="$("$POWERLINE_CONFIG" shell command)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_tmux_setenv() {
|
||||||
|
TMUX="$_POWERLINE_TMUX" tmux setenv -g TMUX_"$1"_`tmux display -p "#D" | tr -d %` "$2"
|
||||||
|
TMUX="$_POWERLINE_TMUX" tmux refresh -S
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_tmux_set_pwd() {
|
||||||
|
if test "x$_POWERLINE_SAVED_PWD" != "x$PWD" ; then
|
||||||
|
_POWERLINE_SAVED_PWD="$PWD"
|
||||||
|
_powerline_tmux_setenv PWD "$PWD"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_tmux_set_columns() {
|
||||||
|
_powerline_tmux_setenv COLUMNS "${COLUMNS:-$(_powerline_columns_fallback)}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_set_renderer_arg() {
|
||||||
|
case "$1" in
|
||||||
|
bb|ash) _POWERLINE_RENDERER_ARG="-r .bash" ;;
|
||||||
|
mksh|ksh) _POWERLINE_RENDERER_ARG="-r .ksh" ;;
|
||||||
|
bash|dash) _POWERLINE_RENDERER_ARG= ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_set_jobs() {
|
||||||
|
_powerline_set_set_jobs
|
||||||
|
_powerline_set_jobs
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_local_prompt() {
|
||||||
|
# Arguments: side, exit_code, local theme
|
||||||
|
_powerline_set_jobs
|
||||||
|
$POWERLINE_COMMAND shell $1 \
|
||||||
|
$_POWERLINE_RENDERER_ARG \
|
||||||
|
--renderer_arg="client_id=$$" \
|
||||||
|
--last_exit_code=$2 \
|
||||||
|
--jobnum=$_POWERLINE_JOBS \
|
||||||
|
--renderer_arg="local_theme=$3"
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_prompt() {
|
||||||
|
# Arguments: side, exit_code
|
||||||
|
_powerline_set_jobs
|
||||||
|
$POWERLINE_COMMAND shell $1 \
|
||||||
|
--width="${COLUMNS:-$(_powerline_columns_fallback)}" \
|
||||||
|
$_POWERLINE_RENDERER_ARG \
|
||||||
|
--renderer_arg="client_id=$$" \
|
||||||
|
--last_exit_code=$2 \
|
||||||
|
--jobnum=$_POWERLINE_JOBS
|
||||||
|
_powerline_update_psN
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_setup_psN() {
|
||||||
|
case "$1" in
|
||||||
|
mksh|ksh|bash)
|
||||||
|
_POWERLINE_PID=$$
|
||||||
|
_powerline_update_psN() {
|
||||||
|
kill -USR1 $_POWERLINE_PID
|
||||||
|
}
|
||||||
|
# No command substitution in PS2 and PS3
|
||||||
|
_powerline_set_psN() {
|
||||||
|
if test -n "$POWERLINE_SHELL_CONTINUATION" ; then
|
||||||
|
PS2="$(_powerline_local_prompt left $? continuation)"
|
||||||
|
fi
|
||||||
|
if test -n "$POWERLINE_SHELL_SELECT" ; then
|
||||||
|
PS3="$(_powerline_local_prompt left $? select)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
_powerline_append_trap '_powerline_set_psN' USR1
|
||||||
|
_powerline_set_psN
|
||||||
|
;;
|
||||||
|
bb|ash|dash)
|
||||||
|
_powerline_update_psN() {
|
||||||
|
# Do nothing
|
||||||
|
return
|
||||||
|
}
|
||||||
|
PS2='$(_powerline_local_prompt left $? continuation)'
|
||||||
|
# No select support
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_setup_prompt() {
|
||||||
|
VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||||
|
_powerline_set_append_trap "$@"
|
||||||
|
_powerline_set_set_jobs "$@"
|
||||||
|
_powerline_set_command "$@"
|
||||||
|
_powerline_set_renderer_arg "$@"
|
||||||
|
PS1='$(_powerline_prompt aboveleft $?)'
|
||||||
|
PS2="$(_powerline_local_prompt left 0 continuation)"
|
||||||
|
PS3="$(_powerline_local_prompt left 0 select)"
|
||||||
|
_powerline_setup_psN "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_init_tmux_support() {
|
||||||
|
# Dash does not have &>/dev/null
|
||||||
|
if test -n "$TMUX" && tmux refresh -S >/dev/null 2>/dev/null ; then
|
||||||
|
# TMUX variable may be unset to create new tmux session inside this one
|
||||||
|
_POWERLINE_TMUX="$TMUX"
|
||||||
|
|
||||||
|
_powerline_set_append_trap "$@"
|
||||||
|
|
||||||
|
# If _powerline_tmux_set_pwd is used before _powerline_prompt it sets $?
|
||||||
|
# to zero in ksh.
|
||||||
|
PS1="$PS1"'$(_powerline_tmux_set_pwd)'
|
||||||
|
_powerline_append_trap '_powerline_tmux_set_columns' WINCH
|
||||||
|
_powerline_tmux_set_columns
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if test -z "${POWERLINE_CONFIG}" ; then
|
||||||
|
if which powerline-config >/dev/null ; then
|
||||||
|
POWERLINE_CONFIG=powerline-config
|
||||||
|
else
|
||||||
|
POWERLINE_CONFIG="$(dirname "$_POWERLINE_SOURCED")/../../../scripts/powerline-config"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Strips the leading `-`: it may be present when shell is a login shell
|
||||||
|
_POWERLINE_USED_SHELL=${0#-}
|
||||||
|
_POWERLINE_USED_SHELL=${_POWERLINE_USED_SHELL#/usr}
|
||||||
|
_POWERLINE_USED_SHELL=${_POWERLINE_USED_SHELL#/bin/}
|
||||||
|
|
||||||
|
if "${POWERLINE_CONFIG}" shell uses tmux ; then
|
||||||
|
_powerline_init_tmux_support $_POWERLINE_USED_SHELL
|
||||||
|
fi
|
||||||
|
if "${POWERLINE_CONFIG}" shell --shell=bash uses prompt ; then
|
||||||
|
_powerline_setup_prompt $_POWERLINE_USED_SHELL
|
||||||
|
fi
|
47
powerline/bindings/tcsh/powerline.tcsh
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# http://unix.stackexchange.com/questions/4650/determining-path-to-sourced-shell-script:
|
||||||
|
# > In tcsh, $_ at the beginning of the script will contain the location if the
|
||||||
|
# > file was sourced and $0 contains it if it was run.
|
||||||
|
#
|
||||||
|
# Guess this relies on `$_` being set as to last argument to previous command
|
||||||
|
# which must be `.` or `source` in this case
|
||||||
|
set POWERLINE_SOURCED=($_)
|
||||||
|
if ! $?POWERLINE_CONFIG then
|
||||||
|
if ( { which powerline-config > /dev/null } ) then
|
||||||
|
set POWERLINE_CONFIG="powerline-config"
|
||||||
|
else
|
||||||
|
set POWERLINE_CONFIG="$POWERLINE_SOURCED[2]:h:h:h:h/scripts/powerline-config"
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if "$POWERLINE_CONFIG" == "" then
|
||||||
|
if ( { which powerline-config > /dev/null } ) then
|
||||||
|
set POWERLINE_CONFIG="powerline-config"
|
||||||
|
else
|
||||||
|
set POWERLINE_CONFIG="$POWERLINE_SOURCED[2]:h:h:h:h/scripts/powerline-config"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if ( { $POWERLINE_CONFIG 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'
|
||||||
|
alias cwdcmd "`alias cwdcmd` ; _powerline_tmux_set_pwd"
|
||||||
|
endif
|
||||||
|
if ( { $POWERLINE_CONFIG shell --shell=tcsh uses prompt } ) then
|
||||||
|
if ! $?POWERLINE_COMMAND then
|
||||||
|
set POWERLINE_COMMAND="`$POWERLINE_CONFIG:q shell command`"
|
||||||
|
else
|
||||||
|
if "$POWERLINE_COMMAND" == "" then
|
||||||
|
set POWERLINE_COMMAND="`$POWERLINE_CONFIG:q shell command`"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if ( $?POWERLINE_NO_TCSH_ABOVE || $?POWERLINE_NO_SHELL_ABOVE ) then
|
||||||
|
alias _powerline_above true
|
||||||
|
else
|
||||||
|
alias _powerline_above '$POWERLINE_COMMAND shell above --renderer_arg=client_id=$$ --last_exit_code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS'
|
||||||
|
endif
|
||||||
|
|
||||||
|
alias _powerline_set_prompt 'set prompt="`$POWERLINE_COMMAND shell left -r .tcsh --renderer_arg=client_id=$$ --last_exit_code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS`"'
|
||||||
|
alias _powerline_set_rprompt 'set rprompt="`$POWERLINE_COMMAND shell right -r .tcsh --renderer_arg=client_id=$$ --last_exit_code=$POWERLINE_STATUS --width=$POWERLINE_COLUMNS` "'
|
||||||
|
alias _powerline_set_columns 'set POWERLINE_COLUMNS=`stty size|cut -d" " -f2` ; set POWERLINE_COLUMNS=`expr $POWERLINE_COLUMNS - 2`'
|
||||||
|
|
||||||
|
alias precmd 'set POWERLINE_STATUS=$? ; '"`alias precmd`"' ; _powerline_set_columns ; _powerline_above ; _powerline_set_prompt ; _powerline_set_rprompt'
|
||||||
|
endif
|
52
powerline/bindings/tmux/__init__.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
|
from powerline.lib.shell import run_cmd
|
||||||
|
|
||||||
|
|
||||||
|
TmuxVersionInfo = namedtuple('TmuxVersionInfo', ('major', 'minor', 'suffix'))
|
||||||
|
|
||||||
|
|
||||||
|
def get_tmux_executable_name():
|
||||||
|
'''Returns tmux executable name
|
||||||
|
|
||||||
|
It should be defined in POWERLINE_TMUX_EXE environment variable, otherwise
|
||||||
|
it is simply “tmux”.
|
||||||
|
'''
|
||||||
|
|
||||||
|
return os.environ.get('POWERLINE_TMUX_EXE', 'tmux')
|
||||||
|
|
||||||
|
|
||||||
|
def _run_tmux(runner, args):
|
||||||
|
return runner([get_tmux_executable_name()] + list(args))
|
||||||
|
|
||||||
|
|
||||||
|
def run_tmux_command(*args):
|
||||||
|
'''Run tmux command, ignoring the output'''
|
||||||
|
_run_tmux(subprocess.check_call, args)
|
||||||
|
|
||||||
|
|
||||||
|
def get_tmux_output(pl, *args):
|
||||||
|
'''Run tmux command and return its output'''
|
||||||
|
return _run_tmux(lambda cmd: run_cmd(pl, cmd), args)
|
||||||
|
|
||||||
|
|
||||||
|
NON_DIGITS = re.compile('[^0-9]+')
|
||||||
|
DIGITS = re.compile('[0-9]+')
|
||||||
|
NON_LETTERS = re.compile('[^a-z]+')
|
||||||
|
|
||||||
|
|
||||||
|
def get_tmux_version(pl):
|
||||||
|
version_string = get_tmux_output(pl, '-V')
|
||||||
|
_, version_string = version_string.split(' ')
|
||||||
|
version_string = version_string.strip()
|
||||||
|
major, minor = version_string.split('.')
|
||||||
|
suffix = DIGITS.subn('', minor)[0] or None
|
||||||
|
minor = NON_DIGITS.subn('', minor)[0]
|
||||||
|
return TmuxVersionInfo(int(major), int(minor), suffix)
|
21
powerline/bindings/tmux/powerline.conf
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
if-shell 'test -z "$POWERLINE_CONFIG_COMMAND"' 'set-environment -g POWERLINE_CONFIG_COMMAND powerline-config'
|
||||||
|
|
||||||
|
# Don't version-check for this core functionality -- anything too old to
|
||||||
|
# support these options likely won't work well with powerline
|
||||||
|
set -g status on
|
||||||
|
set -g status-utf8 on
|
||||||
|
set -g status-interval 2
|
||||||
|
set -g status-left-length 20
|
||||||
|
set -g status-right '#(eval $POWERLINE_COMMAND tmux right -R pane_id=`tmux display -p "#D"`)'
|
||||||
|
set -g status-right-length 150
|
||||||
|
set -g window-status-format "#[fg=colour244,bg=colour234] #I #[fg=colour240] #[default]#W "
|
||||||
|
set -g window-status-current-format "#[fg=colour234,bg=colour31]#[fg=colour117,bg=colour31] #I #[fg=colour231,bold]#W #[fg=colour31,bg=colour234,nobold]"
|
||||||
|
|
||||||
|
# Legacy status-left definition to be overwritten for tmux Versions 1.8+
|
||||||
|
set -g status-left '#[fg=colour16,bg=colour254,bold] #S #[fg=colour254,bg=colour234,nobold]#(eval $POWERLINE_COMMAND tmux left)'
|
||||||
|
|
||||||
|
# Simplify tmux version checking by using multiple config files. Source these
|
||||||
|
# config files based on the version in which tmux features were added and/or
|
||||||
|
# deprecated. By splitting these configuration options into separate files,
|
||||||
|
run-shell 'eval $POWERLINE_CONFIG_COMMAND tmux source'
|
||||||
|
# vim: ft=tmux
|
5
powerline/bindings/tmux/powerline_tmux_1.8.conf
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# powerline_tmux_1.8.conf
|
||||||
|
# tmux Version 1.8 introduces window-status-last-{attr,bg,fg}, which is
|
||||||
|
# deprecated for versions 1.9+, thus only applicable to version 1.8.
|
||||||
|
set -qg window-status-last-fg colour31
|
||||||
|
# vim: ft=tmux
|
11
powerline/bindings/tmux/powerline_tmux_1.8_minus.conf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# powerline_tmux_legacy_common.conf
|
||||||
|
# tmux Version 1.8 and earlier (legacy) common options. The foo-{attr,bg,fg}
|
||||||
|
# options are deprecated starting with tmux Version 1.9.
|
||||||
|
set -g status-fg colour231
|
||||||
|
set -g status-bg colour234
|
||||||
|
set-window-option -g window-status-fg colour249
|
||||||
|
set-window-option -g window-status-activity-attr none
|
||||||
|
set-window-option -g window-status-bell-attr none
|
||||||
|
set-window-option -g window-status-activity-fg yellow
|
||||||
|
set-window-option -g window-status-bell-fg red
|
||||||
|
# vim: ft=tmux
|
5
powerline/bindings/tmux/powerline_tmux_1.8_plus.conf
Normal file
@ -0,0 +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=colour254]#[bg=colour31]#[bold],#[fg=colour16]#[bg=colour254]#[bold]} #S #{?client_prefix,#[fg=colour31]#[bg=colour234]#[nobold],#[fg=colour254]#[bg=colour234]#[nobold]}#(eval $POWERLINE_COMMAND tmux left)'
|
||||||
|
# vim: ft=tmux
|
8
powerline/bindings/tmux/powerline_tmux_1.9_plus.conf
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# powerline_tmux_1.9_plus.conf
|
||||||
|
# Version 1.9 introduces the foo-style options, applicable to version 1.9+
|
||||||
|
set -qg status-style fg=colour231,bg=colour234
|
||||||
|
set -qg window-status-last-style fg=colour31
|
||||||
|
set-window-option -qg window-status-style fg=colour249
|
||||||
|
set-window-option -qg window-status-activity-style fg=yellow,none
|
||||||
|
set-window-option -qg window-status-bell-style fg=red,none
|
||||||
|
# vim: ft=tmux
|
315
powerline/bindings/vim/__init__.py
Normal file
@ -0,0 +1,315 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import codecs
|
||||||
|
|
||||||
|
try:
|
||||||
|
import vim
|
||||||
|
except ImportError:
|
||||||
|
vim = {}
|
||||||
|
|
||||||
|
if not hasattr(vim, 'bindeval'):
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
if hasattr(vim, 'bindeval'):
|
||||||
|
def vim_get_func(f, rettype=None):
|
||||||
|
'''Return a vim function binding.'''
|
||||||
|
try:
|
||||||
|
func = vim.bindeval('function("' + f + '")')
|
||||||
|
if sys.version_info >= (3,) and rettype is str:
|
||||||
|
return (lambda *args, **kwargs: func(*args, **kwargs).decode('utf-8', errors='replace'))
|
||||||
|
return func
|
||||||
|
except vim.error:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
class VimFunc(object):
|
||||||
|
'''Evaluate a vim function using vim.eval().
|
||||||
|
|
||||||
|
This is a fallback class for older vim versions.
|
||||||
|
'''
|
||||||
|
__slots__ = ('f', 'rettype')
|
||||||
|
|
||||||
|
def __init__(self, f, rettype=None):
|
||||||
|
self.f = f
|
||||||
|
self.rettype = rettype
|
||||||
|
|
||||||
|
def __call__(self, *args):
|
||||||
|
r = vim.eval(self.f + '(' + json.dumps(args)[1:-1] + ')')
|
||||||
|
if self.rettype:
|
||||||
|
return self.rettype(r)
|
||||||
|
return r
|
||||||
|
|
||||||
|
vim_get_func = VimFunc
|
||||||
|
|
||||||
|
|
||||||
|
_getbufvar = vim_get_func('getbufvar')
|
||||||
|
|
||||||
|
|
||||||
|
# It may crash on some old vim versions and I do not remember in which patch
|
||||||
|
# I fixed this crash.
|
||||||
|
if hasattr(vim, 'vvars') and vim.vvars['version'] > 703:
|
||||||
|
_vim_to_python_types = {
|
||||||
|
getattr(vim, 'Dictionary', None) or type(vim.bindeval('{}')):
|
||||||
|
lambda value: dict(((key, _vim_to_python(value[key])) for key in value.keys())),
|
||||||
|
getattr(vim, 'List', None) or type(vim.bindeval('[]')):
|
||||||
|
lambda value: [_vim_to_python(item) for item in value],
|
||||||
|
getattr(vim, 'Function', None) or type(vim.bindeval('function("mode")')):
|
||||||
|
lambda _: None,
|
||||||
|
}
|
||||||
|
|
||||||
|
def vim_getvar(varname):
|
||||||
|
return _vim_to_python(vim.vars[str(varname)])
|
||||||
|
|
||||||
|
def bufvar_exists(buffer, varname):
|
||||||
|
buffer = buffer or vim.current.buffer
|
||||||
|
return varname in buffer.vars
|
||||||
|
|
||||||
|
def vim_getwinvar(segment_info, varname):
|
||||||
|
return _vim_to_python(segment_info['window'].vars[str(varname)])
|
||||||
|
else:
|
||||||
|
_vim_to_python_types = {
|
||||||
|
dict: (lambda value: dict(((k, _vim_to_python(v)) for k, v in value.items()))),
|
||||||
|
list: (lambda value: [_vim_to_python(i) for i in value]),
|
||||||
|
}
|
||||||
|
|
||||||
|
_vim_exists = vim_get_func('exists', rettype=int)
|
||||||
|
|
||||||
|
def vim_getvar(varname):
|
||||||
|
varname = 'g:' + varname
|
||||||
|
if _vim_exists(varname):
|
||||||
|
return vim.eval(varname)
|
||||||
|
else:
|
||||||
|
raise KeyError(varname)
|
||||||
|
|
||||||
|
def bufvar_exists(buffer, varname):
|
||||||
|
if not buffer or buffer.number == vim.current.buffer.number:
|
||||||
|
return int(vim.eval('exists("b:{0}")'.format(varname)))
|
||||||
|
else:
|
||||||
|
return int(vim.eval(
|
||||||
|
'has_key(getbufvar({0}, ""), {1})'.format(buffer.number, varname)
|
||||||
|
))
|
||||||
|
|
||||||
|
def vim_getwinvar(segment_info, varname):
|
||||||
|
result = vim.eval('getwinvar({0}, "{1}")'.format(segment_info['winnr'], varname))
|
||||||
|
if result == '':
|
||||||
|
if not int(vim.eval('has_key(getwinvar({0}, ""), "{1}")'.format(segment_info['winnr'], varname))):
|
||||||
|
raise KeyError(varname)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
getbufvar = _getbufvar
|
||||||
|
else:
|
||||||
|
_vim_to_python_types[bytes] = lambda value: value.decode('utf-8')
|
||||||
|
|
||||||
|
def getbufvar(*args):
|
||||||
|
return _vim_to_python(_getbufvar(*args))
|
||||||
|
|
||||||
|
|
||||||
|
_id = lambda value: value
|
||||||
|
|
||||||
|
|
||||||
|
def _vim_to_python(value):
|
||||||
|
return _vim_to_python_types.get(type(value), _id)(value)
|
||||||
|
|
||||||
|
|
||||||
|
if hasattr(vim, 'options'):
|
||||||
|
def vim_getbufoption(info, option):
|
||||||
|
return info['buffer'].options[str(option)]
|
||||||
|
|
||||||
|
def vim_getoption(option):
|
||||||
|
return vim.options[str(option)]
|
||||||
|
|
||||||
|
def vim_setoption(option, value):
|
||||||
|
vim.options[str(option)] = value
|
||||||
|
else:
|
||||||
|
def vim_getbufoption(info, option):
|
||||||
|
return getbufvar(info['bufnr'], '&' + option)
|
||||||
|
|
||||||
|
def vim_getoption(option):
|
||||||
|
return vim.eval('&g:' + option)
|
||||||
|
|
||||||
|
def vim_setoption(option, value):
|
||||||
|
vim.command('let &g:{option} = {value}'.format(
|
||||||
|
option=option, value=json.encode(value)))
|
||||||
|
|
||||||
|
|
||||||
|
if hasattr(vim, 'tabpages'):
|
||||||
|
current_tabpage = lambda: vim.current.tabpage
|
||||||
|
list_tabpages = lambda: vim.tabpages
|
||||||
|
|
||||||
|
def list_tabpage_buffers_segment_info(segment_info):
|
||||||
|
return (
|
||||||
|
{'buffer': window.buffer, 'bufnr': window.buffer.number}
|
||||||
|
for window in segment_info['tabpage'].windows
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
class FalseObject(object):
|
||||||
|
@staticmethod
|
||||||
|
def __nonzero__():
|
||||||
|
return False
|
||||||
|
|
||||||
|
__bool__ = __nonzero__
|
||||||
|
|
||||||
|
def get_buffer(number):
|
||||||
|
for buffer in vim.buffers:
|
||||||
|
if buffer.number == number:
|
||||||
|
return buffer
|
||||||
|
raise KeyError(number)
|
||||||
|
|
||||||
|
class WindowVars(object):
|
||||||
|
__slots__ = ('tabnr', 'winnr')
|
||||||
|
|
||||||
|
def __init__(self, window):
|
||||||
|
self.tabnr = window.tabnr
|
||||||
|
self.winnr = window.number
|
||||||
|
|
||||||
|
def __getitem__(self, key):
|
||||||
|
has_key = vim.eval('has_key(gettabwinvar({0}, {1}, ""), "{2}")'.format(self.tabnr, self.winnr, key))
|
||||||
|
if has_key == '0':
|
||||||
|
raise KeyError
|
||||||
|
return vim.eval('gettabwinvar({0}, {1}, "{2}")'.format(self.tabnr, self.winnr, key))
|
||||||
|
|
||||||
|
def get(self, key, default=None):
|
||||||
|
try:
|
||||||
|
return self[key]
|
||||||
|
except KeyError:
|
||||||
|
return default
|
||||||
|
|
||||||
|
class Window(FalseObject):
|
||||||
|
__slots__ = ('tabnr', 'number', '_vars')
|
||||||
|
|
||||||
|
def __init__(self, tabnr, number):
|
||||||
|
self.tabnr = tabnr
|
||||||
|
self.number = number
|
||||||
|
self.vars = WindowVars(self)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def buffer(self):
|
||||||
|
return get_buffer(int(vim.eval('tabpagebuflist({0})[{1}]'.format(self.tabnr, self.number - 1))))
|
||||||
|
|
||||||
|
class Tabpage(FalseObject):
|
||||||
|
__slots__ = ('number',)
|
||||||
|
|
||||||
|
def __init__(self, number):
|
||||||
|
self.number = number
|
||||||
|
|
||||||
|
def __eq__(self, tabpage):
|
||||||
|
if not isinstance(tabpage, Tabpage):
|
||||||
|
raise NotImplementedError
|
||||||
|
return self.number == tabpage.number
|
||||||
|
|
||||||
|
@property
|
||||||
|
def window(self):
|
||||||
|
return Window(self.number, int(vim.eval('tabpagewinnr({0})'.format(self.number))))
|
||||||
|
|
||||||
|
def _last_tab_nr():
|
||||||
|
return int(vim.eval('tabpagenr("$")'))
|
||||||
|
|
||||||
|
def current_tabpage():
|
||||||
|
return Tabpage(int(vim.eval('tabpagenr()')))
|
||||||
|
|
||||||
|
def list_tabpages():
|
||||||
|
return [Tabpage(nr) for nr in range(1, _last_tab_nr() + 1)]
|
||||||
|
|
||||||
|
class TabBufSegmentInfo(dict):
|
||||||
|
def __getitem__(self, key):
|
||||||
|
try:
|
||||||
|
return super(TabBufSegmentInfo, self).__getitem__(key)
|
||||||
|
except KeyError:
|
||||||
|
if key != 'buffer':
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
buffer = get_buffer(super(TabBufSegmentInfo, self).__getitem__('bufnr'))
|
||||||
|
self['buffer'] = buffer
|
||||||
|
return buffer
|
||||||
|
|
||||||
|
def list_tabpage_buffers_segment_info(segment_info):
|
||||||
|
return (
|
||||||
|
TabBufSegmentInfo(bufnr=int(bufnrstr))
|
||||||
|
for bufnrstr in vim.eval('tabpagebuflist({0})'.format(segment_info['tabnr']))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class VimEnviron(object):
|
||||||
|
@staticmethod
|
||||||
|
def __getitem__(key):
|
||||||
|
return vim.eval('$' + key)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get(key, default=None):
|
||||||
|
return vim.eval('$' + key) or default
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def __setitem__(key, value):
|
||||||
|
return vim.command(
|
||||||
|
'let ${0}="{1}"'.format(
|
||||||
|
key,
|
||||||
|
value.replace('"', '\\"')
|
||||||
|
.replace('\\', '\\\\')
|
||||||
|
.replace('\n', '\\n')
|
||||||
|
.replace('\0', '')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
def buffer_name(buf):
|
||||||
|
return buf.name
|
||||||
|
else:
|
||||||
|
vim_bufname = vim_get_func('bufname')
|
||||||
|
|
||||||
|
def buffer_name(buf):
|
||||||
|
try:
|
||||||
|
name = buf.name
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
return vim_bufname(buf.number)
|
||||||
|
else:
|
||||||
|
return name.encode('utf-8') if name else None
|
||||||
|
|
||||||
|
|
||||||
|
vim_strtrans = vim_get_func('strtrans')
|
||||||
|
|
||||||
|
|
||||||
|
def powerline_vim_strtrans_error(e):
|
||||||
|
if not isinstance(e, UnicodeDecodeError):
|
||||||
|
raise NotImplementedError
|
||||||
|
# Assuming &encoding is utf-8 strtrans should not return anything but ASCII
|
||||||
|
# under current circumstances
|
||||||
|
text = vim_strtrans(e.object[e.start:e.end]).decode()
|
||||||
|
return (text, e.end)
|
||||||
|
|
||||||
|
|
||||||
|
codecs.register_error('powerline_vim_strtrans_error', powerline_vim_strtrans_error)
|
||||||
|
|
||||||
|
|
||||||
|
did_autocmd = False
|
||||||
|
buffer_caches = []
|
||||||
|
|
||||||
|
|
||||||
|
def register_buffer_cache(cachedict):
|
||||||
|
global did_autocmd
|
||||||
|
global buffer_caches
|
||||||
|
from powerline.vim import get_default_pycmd, pycmd
|
||||||
|
if not did_autocmd:
|
||||||
|
import __main__
|
||||||
|
__main__.powerline_on_bwipe = on_bwipe
|
||||||
|
vim.command('augroup Powerline')
|
||||||
|
vim.command(' autocmd! BufWipeout * :{pycmd} powerline_on_bwipe()'.format(
|
||||||
|
pycmd=(pycmd or get_default_pycmd())))
|
||||||
|
vim.command('augroup END')
|
||||||
|
did_autocmd = True
|
||||||
|
buffer_caches.append(cachedict)
|
||||||
|
return cachedict
|
||||||
|
|
||||||
|
|
||||||
|
def on_bwipe():
|
||||||
|
global buffer_caches
|
||||||
|
bufnr = int(vim.eval('expand("<abuf>")'))
|
||||||
|
for cachedict in buffer_caches:
|
||||||
|
cachedict.pop(bufnr, None)
|
||||||
|
|
||||||
|
|
||||||
|
environ = VimEnviron()
|
20
powerline/bindings/vim/autoload/powerline/debug.vim
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
python import cProfile
|
||||||
|
python powerline_pr = cProfile.Profile()
|
||||||
|
|
||||||
|
function powerline#debug#profile_pyeval(s)
|
||||||
|
python powerline_pr.enable()
|
||||||
|
try
|
||||||
|
let ret = pyeval(a:s)
|
||||||
|
finally
|
||||||
|
python powerline_pr.disable()
|
||||||
|
endtry
|
||||||
|
return ret
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function powerline#debug#write_profile(fname)
|
||||||
|
python import vim
|
||||||
|
python powerline_pr.dump_stats(vim.eval('a:fname'))
|
||||||
|
python powerline_pr = cProfile.Profile()
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
command -nargs=1 -complete=file WriteProfiling :call powerline#debug#write_profile(<q-args>)
|
154
powerline/bindings/vim/plugin/powerline.vim
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
if exists('g:powerline_loaded')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let g:powerline_loaded = 1
|
||||||
|
|
||||||
|
if exists('g:powerline_pycmd')
|
||||||
|
let s:pycmd = substitute(g:powerline_pycmd, '\v\C^(py)%[thon](3?)$', '\1\2', '')
|
||||||
|
if s:pycmd is# 'py'
|
||||||
|
let s:has_python = has('python')
|
||||||
|
let s:pyeval = get(g:, 'powerline_pyeval', 'pyeval')
|
||||||
|
elseif s:pycmd is# 'py3'
|
||||||
|
let s:has_python = has('python3')
|
||||||
|
let s:pyeval = 'py3eval'
|
||||||
|
let s:pyeval = get(g:, 'powerline_pyeval', 'py3eval')
|
||||||
|
else
|
||||||
|
if !exists('g:powerline_pyeval')
|
||||||
|
echohl ErrorMsg
|
||||||
|
echomsg 'g:powerline_pycmd was set to an unknown values, but g:powerline_pyeval'
|
||||||
|
echomsg 'was not set. You should either set g:powerline_pycmd to "py3" or "py",'
|
||||||
|
echomsg 'specify g:powerline_pyeval explicitly or unset both and let powerline'
|
||||||
|
echomsg 'figure them out.'
|
||||||
|
echohl None
|
||||||
|
unlet s:pycmd
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
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')
|
||||||
|
else
|
||||||
|
let s:has_python = 0
|
||||||
|
endif
|
||||||
|
|
||||||
|
if !s:has_python
|
||||||
|
if !exists('g:powerline_no_python_error')
|
||||||
|
echohl ErrorMsg
|
||||||
|
echomsg 'You need vim compiled with Python 2.6, 2.7 or 3.2 and later support'
|
||||||
|
echomsg 'for Powerline to work. Please consult the documentation for more'
|
||||||
|
echomsg 'details.'
|
||||||
|
echohl None
|
||||||
|
endif
|
||||||
|
unlet s:has_python
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
unlet s:has_python
|
||||||
|
|
||||||
|
let s:import_cmd = 'from powerline.vim import VimPowerline'
|
||||||
|
function s:rcmd(s)
|
||||||
|
if !exists('s:pystr')
|
||||||
|
let s:pystr = a:s . "\n"
|
||||||
|
else
|
||||||
|
let s:pystr = s:pystr . a:s . "\n"
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
try
|
||||||
|
let s:can_replace_pyeval = !exists('g:powerline_pyeval')
|
||||||
|
call s:rcmd("try:")
|
||||||
|
call s:rcmd(" powerline_appended_path = None")
|
||||||
|
call s:rcmd(" try:")
|
||||||
|
call s:rcmd(" ".s:import_cmd."")
|
||||||
|
call s:rcmd(" except ImportError:")
|
||||||
|
call s:rcmd(" import sys, vim")
|
||||||
|
call s:rcmd(" powerline_appended_path = vim.eval('expand(\"<sfile>:h:h:h:h:h\")')")
|
||||||
|
call s:rcmd(" sys.path.append(powerline_appended_path)")
|
||||||
|
call s:rcmd(" ".s:import_cmd."")
|
||||||
|
call s:rcmd(" import vim")
|
||||||
|
call s:rcmd(" VimPowerline().setup(pyeval=vim.eval('s:pyeval'), pycmd=vim.eval('s:pycmd'), can_replace_pyeval=int(vim.eval('s:can_replace_pyeval')))")
|
||||||
|
call s:rcmd(" del VimPowerline")
|
||||||
|
call s:rcmd("except Exception:")
|
||||||
|
call s:rcmd(" import traceback, sys")
|
||||||
|
call s:rcmd(" traceback.print_exc(file=sys.stdout)")
|
||||||
|
call s:rcmd(" raise")
|
||||||
|
execute s:pycmd s:pystr
|
||||||
|
unlet s:pystr
|
||||||
|
let s:launched = 1
|
||||||
|
finally
|
||||||
|
unlet s:can_replace_pyeval
|
||||||
|
unlet s:import_cmd
|
||||||
|
if !exists('s:launched')
|
||||||
|
unlet s:pystr
|
||||||
|
echohl ErrorMsg
|
||||||
|
echomsg 'An error occurred while importing powerline package.'
|
||||||
|
echomsg 'This could be caused by invalid sys.path setting,'
|
||||||
|
echomsg 'or by an incompatible Python version (powerline requires'
|
||||||
|
echomsg 'Python 2.6, 2.7 or 3.2 and later to work). Please consult'
|
||||||
|
echomsg 'the troubleshooting section in the documentation for'
|
||||||
|
echomsg 'possible solutions.'
|
||||||
|
if s:pycmd is# 'py' && has('python3')
|
||||||
|
echomsg 'If powerline on your system is installed for python 3 only you'
|
||||||
|
echomsg 'should set g:powerline_pycmd to "py3" to make it load correctly.'
|
||||||
|
endif
|
||||||
|
echohl None
|
||||||
|
call s:rcmd("def powerline_troubleshoot():")
|
||||||
|
call s:rcmd(" import sys")
|
||||||
|
call s:rcmd(" import vim")
|
||||||
|
call s:rcmd(" if sys.version_info < (2, 6):")
|
||||||
|
call s:rcmd(" print('Too old python version: ' + sys.version + ' (first supported is 2.6)')")
|
||||||
|
call s:rcmd(" elif sys.version_info[0] == 3 and sys.version_info[1] < 2:")
|
||||||
|
call s:rcmd(" print('Too old python 3 version: ' + sys.version + ' (first supported is 3.2)')")
|
||||||
|
call s:rcmd(" try:")
|
||||||
|
call s:rcmd(" import powerline")
|
||||||
|
call s:rcmd(" except ImportError:")
|
||||||
|
call s:rcmd(" print('Unable to import powerline, is it installed?')")
|
||||||
|
call s:rcmd(" else:")
|
||||||
|
call s:rcmd(" if not vim.eval('expand(\"<sfile>\")').startswith('/usr/'):")
|
||||||
|
call s:rcmd(" import os")
|
||||||
|
call s:rcmd(" powerline_dir = os.path.realpath(os.path.normpath(powerline.__file__))")
|
||||||
|
call s:rcmd(" powerline_dir = os.path.dirname(powerline.__file__)")
|
||||||
|
call s:rcmd(" this_dir = os.path.realpath(os.path.normpath(vim.eval('expand(\"<sfile>:p\")')))")
|
||||||
|
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline/bindings/vim/plugin
|
||||||
|
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline/bindings/vim
|
||||||
|
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline/bindings
|
||||||
|
call s:rcmd(" this_dir = os.path.dirname(this_dir)") " powerline
|
||||||
|
call s:rcmd(" if os.path.basename(this_dir) != 'powerline':")
|
||||||
|
call s:rcmd(" print('Check your installation:')")
|
||||||
|
call s:rcmd(" print('this script is not in powerline[/bindings/vim/plugin] directory,')")
|
||||||
|
call s:rcmd(" print('neither it is installed system-wide')")
|
||||||
|
call s:rcmd(" real_powerline_dir = os.path.realpath(powerline_dir)")
|
||||||
|
call s:rcmd(" real_this_dir = os.path.realpath(this_dir)")
|
||||||
|
call s:rcmd(" this_dir_par = os.path.dirname(real_this_dir)")
|
||||||
|
call s:rcmd(" powerline_appended_path = globals().get('powerline_appended_path')")
|
||||||
|
call s:rcmd(" if powerline_appended_path is not None and this_dir_par != powerline_appended_path:")
|
||||||
|
call s:rcmd(" print('Check your installation: this script is symlinked somewhere')")
|
||||||
|
call s:rcmd(" print('where powerline is not present: {0!r} != {1!r}.'.format(")
|
||||||
|
call s:rcmd(" real_this_dir, powerline_appended_path))")
|
||||||
|
call s:rcmd(" elif real_powerline_dir != real_this_dir:")
|
||||||
|
call s:rcmd(" print('It appears that you have two powerline versions installed:')")
|
||||||
|
call s:rcmd(" print('one in ' + real_powerline_dir + ', other in ' + real_this_dir + '.')")
|
||||||
|
call s:rcmd(" print('You should remove one of this. Check out troubleshooting section,')")
|
||||||
|
call s:rcmd(" print('it contains some information about the alternatives.')")
|
||||||
|
call s:rcmd("try:")
|
||||||
|
call s:rcmd(" powerline_troubleshoot()")
|
||||||
|
call s:rcmd("finally:")
|
||||||
|
call s:rcmd(" del powerline_troubleshoot")
|
||||||
|
execute s:pycmd s:pystr
|
||||||
|
unlet s:pystr
|
||||||
|
unlet s:pycmd
|
||||||
|
unlet s:pyeval
|
||||||
|
delfunction s:rcmd
|
||||||
|
finish
|
||||||
|
else
|
||||||
|
unlet s:launched
|
||||||
|
endif
|
||||||
|
unlet s:pycmd
|
||||||
|
unlet s:pyeval
|
||||||
|
delfunction s:rcmd
|
||||||
|
endtry
|
186
powerline/bindings/zsh/__init__.py
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import atexit
|
||||||
|
|
||||||
|
from weakref import WeakValueDictionary, ref
|
||||||
|
|
||||||
|
import zsh
|
||||||
|
|
||||||
|
from powerline.shell import ShellPowerline
|
||||||
|
from powerline.lib import parsedotval
|
||||||
|
from powerline.lib.unicode import unicode
|
||||||
|
|
||||||
|
|
||||||
|
used_powerlines = WeakValueDictionary()
|
||||||
|
|
||||||
|
|
||||||
|
def shutdown():
|
||||||
|
for powerline in tuple(used_powerlines.values()):
|
||||||
|
powerline.shutdown()
|
||||||
|
|
||||||
|
|
||||||
|
def get_var_config(var):
|
||||||
|
try:
|
||||||
|
return [parsedotval(i) for i in zsh.getvalue(var).items()]
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class Args(object):
|
||||||
|
__slots__ = ('last_pipe_status', 'last_exit_code')
|
||||||
|
ext = ['shell']
|
||||||
|
renderer_module = '.zsh'
|
||||||
|
|
||||||
|
@property
|
||||||
|
def config(self):
|
||||||
|
try:
|
||||||
|
return get_var_config('POWERLINE_CONFIG')
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def theme_option(self):
|
||||||
|
try:
|
||||||
|
return get_var_config('POWERLINE_THEME_CONFIG')
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def config_path(self):
|
||||||
|
try:
|
||||||
|
ret = zsh.getvalue('POWERLINE_CONFIG_PATHS')
|
||||||
|
except IndexError:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
if isinstance(ret, (unicode, str, bytes)):
|
||||||
|
return ret.split(type(ret)(':'))
|
||||||
|
else:
|
||||||
|
return ret
|
||||||
|
|
||||||
|
@property
|
||||||
|
def jobnum(self):
|
||||||
|
return zsh.getvalue('_POWERLINE_JOBNUM')
|
||||||
|
|
||||||
|
|
||||||
|
def string(s):
|
||||||
|
if type(s) is bytes:
|
||||||
|
return s.decode('utf-8', 'replace')
|
||||||
|
else:
|
||||||
|
return str(s)
|
||||||
|
|
||||||
|
|
||||||
|
class Environment(object):
|
||||||
|
@staticmethod
|
||||||
|
def __getitem__(key):
|
||||||
|
try:
|
||||||
|
return string(zsh.getvalue(key))
|
||||||
|
except IndexError as e:
|
||||||
|
raise KeyError(*e.args)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get(key, default=None):
|
||||||
|
try:
|
||||||
|
return string(zsh.getvalue(key))
|
||||||
|
except IndexError:
|
||||||
|
return default
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def __contains__(key):
|
||||||
|
try:
|
||||||
|
zsh.getvalue(key)
|
||||||
|
return True
|
||||||
|
except IndexError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
environ = Environment()
|
||||||
|
|
||||||
|
|
||||||
|
class ZshPowerline(ShellPowerline):
|
||||||
|
def init(self, **kwargs):
|
||||||
|
super(ZshPowerline, self).init(Args(), **kwargs)
|
||||||
|
|
||||||
|
def precmd(self):
|
||||||
|
self.args.last_pipe_status = zsh.pipestatus()
|
||||||
|
self.args.last_exit_code = zsh.last_exit_code()
|
||||||
|
|
||||||
|
def do_setup(self, zsh_globals):
|
||||||
|
set_prompt(self, 'PS1', 'left', None, above=True)
|
||||||
|
set_prompt(self, 'RPS1', 'right', None)
|
||||||
|
set_prompt(self, 'PS2', 'left', 'continuation')
|
||||||
|
set_prompt(self, 'RPS2', 'right', 'continuation')
|
||||||
|
set_prompt(self, 'PS3', 'left', 'select')
|
||||||
|
used_powerlines[id(self)] = self
|
||||||
|
zsh_globals['_powerline'] = self
|
||||||
|
|
||||||
|
|
||||||
|
class Prompt(object):
|
||||||
|
__slots__ = ('powerline', 'side', 'savedpsvar', 'savedps', 'args', 'theme', 'above', '__weakref__')
|
||||||
|
|
||||||
|
def __init__(self, powerline, side, theme, savedpsvar=None, savedps=None, above=False):
|
||||||
|
self.powerline = powerline
|
||||||
|
self.side = side
|
||||||
|
self.above = above
|
||||||
|
self.savedpsvar = savedpsvar
|
||||||
|
self.savedps = savedps
|
||||||
|
self.args = powerline.args
|
||||||
|
self.theme = theme
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
zsh.eval('_POWERLINE_PARSER_STATE="${(%):-%_}"')
|
||||||
|
segment_info = {
|
||||||
|
'args': self.args,
|
||||||
|
'environ': environ,
|
||||||
|
'client_id': 1,
|
||||||
|
'local_theme': self.theme,
|
||||||
|
'parser_state': zsh.getvalue('_POWERLINE_PARSER_STATE'),
|
||||||
|
'shortened_path': zsh.getvalue('_POWERLINE_SHORTENED_PATH'),
|
||||||
|
}
|
||||||
|
r = ''
|
||||||
|
if self.above:
|
||||||
|
for line in self.powerline.render_above_lines(
|
||||||
|
width=zsh.columns() - 1,
|
||||||
|
segment_info=segment_info,
|
||||||
|
):
|
||||||
|
r += line + '\n'
|
||||||
|
r += self.powerline.render(
|
||||||
|
width=zsh.columns(),
|
||||||
|
side=self.side,
|
||||||
|
segment_info=segment_info,
|
||||||
|
)
|
||||||
|
if type(r) is not str:
|
||||||
|
if type(r) is bytes:
|
||||||
|
return r.decode('utf-8')
|
||||||
|
else:
|
||||||
|
return r.encode('utf-8')
|
||||||
|
return r
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
if self.savedps:
|
||||||
|
zsh.setvalue(self.savedpsvar, self.savedps)
|
||||||
|
self.powerline.shutdown()
|
||||||
|
|
||||||
|
|
||||||
|
def set_prompt(powerline, psvar, side, theme, above=False):
|
||||||
|
try:
|
||||||
|
savedps = zsh.getvalue(psvar)
|
||||||
|
except IndexError:
|
||||||
|
savedps = None
|
||||||
|
zpyvar = 'ZPYTHON_POWERLINE_' + psvar
|
||||||
|
prompt = Prompt(powerline, side, theme, psvar, savedps, above)
|
||||||
|
zsh.eval('unset ' + zpyvar)
|
||||||
|
zsh.set_special_string(zpyvar, prompt)
|
||||||
|
zsh.setvalue(psvar, '${' + zpyvar + '}')
|
||||||
|
return ref(prompt)
|
||||||
|
|
||||||
|
|
||||||
|
def reload():
|
||||||
|
for powerline in tuple(used_powerlines.values()):
|
||||||
|
powerline.reload()
|
||||||
|
|
||||||
|
|
||||||
|
def setup(zsh_globals):
|
||||||
|
powerline = ZshPowerline()
|
||||||
|
powerline.setup(zsh_globals)
|
||||||
|
atexit.register(shutdown)
|
204
powerline/bindings/zsh/powerline.zsh
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
_POWERLINE_SOURCED="$0:A"
|
||||||
|
|
||||||
|
_powerline_columns_fallback() {
|
||||||
|
if which stty &>/dev/null ; then
|
||||||
|
local cols="$(stty size 2>/dev/null)"
|
||||||
|
if ! test -z "$cols" ; then
|
||||||
|
echo "${cols#* }"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo 0
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
integer _POWERLINE_JOBNUM
|
||||||
|
|
||||||
|
_powerline_init_tmux_support() {
|
||||||
|
emulate -L zsh
|
||||||
|
if test -n "$TMUX" && tmux refresh -S &>/dev/null ; then
|
||||||
|
# TMUX variable may be unset to create new tmux session inside this one
|
||||||
|
typeset -g _POWERLINE_TMUX="$TMUX"
|
||||||
|
|
||||||
|
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 refresh -S
|
||||||
|
}
|
||||||
|
|
||||||
|
function -g _powerline_tmux_set_pwd() {
|
||||||
|
_powerline_tmux_setenv PWD "$PWD"
|
||||||
|
}
|
||||||
|
|
||||||
|
function -g _powerline_tmux_set_columns() {
|
||||||
|
_powerline_tmux_setenv COLUMNS "${COLUMNS:-$(_powerline_columns_fallback)}"
|
||||||
|
}
|
||||||
|
|
||||||
|
chpwd_functions+=( _powerline_tmux_set_pwd )
|
||||||
|
trap "_powerline_tmux_set_columns" SIGWINCH
|
||||||
|
_powerline_tmux_set_columns
|
||||||
|
_powerline_tmux_set_pwd
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_init_modes_support() {
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
test -z "$ZSH_VERSION" && return 0
|
||||||
|
|
||||||
|
typeset -ga 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
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
function -g _powerline_get_main_keymap_name() {
|
||||||
|
REPLY="${${(Q)${${(z)${"$(bindkey -lL main)"}}[3]}}:-.safe}"
|
||||||
|
}
|
||||||
|
|
||||||
|
function -g _powerline_set_true_keymap_name() {
|
||||||
|
export _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]}}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function -g _powerline_zle_keymap_select() {
|
||||||
|
_powerline_set_true_keymap_name $KEYMAP
|
||||||
|
zle reset-prompt
|
||||||
|
test -z "$_POWERLINE_SAVE_WIDGET" || zle $_POWERLINE_SAVE_WIDGET
|
||||||
|
}
|
||||||
|
|
||||||
|
function -g _powerline_set_main_keymap_name() {
|
||||||
|
local REPLY
|
||||||
|
_powerline_get_main_keymap_name
|
||||||
|
_powerline_set_true_keymap_name "$REPLY"
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_add_widget zle-keymap-select _powerline_zle_keymap_select
|
||||||
|
_powerline_set_main_keymap_name
|
||||||
|
|
||||||
|
if [[ "$_POWERLINE_MODE" != vi* ]] ; then
|
||||||
|
export _POWERLINE_DEFAULT_MODE="$_POWERLINE_MODE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
precmd_functions+=( _powerline_set_main_keymap_name )
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_set_jobnum() {
|
||||||
|
# If you are wondering why I am not using the same code as I use for bash
|
||||||
|
# ($(jobs|wc -l)): consider the following test:
|
||||||
|
# echo abc | less
|
||||||
|
# <C-z>
|
||||||
|
# . This way jobs will print
|
||||||
|
# [1] + done echo abc |
|
||||||
|
# suspended less -M
|
||||||
|
# ([ 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}
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_set_shortened_path() {
|
||||||
|
_POWERLINE_SHORTENED_PATH="${(%):-%~}"
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_update_counter() {
|
||||||
|
zpython '_powerline.precmd()'
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_setup_prompt() {
|
||||||
|
emulate -L zsh
|
||||||
|
|
||||||
|
for f in "${precmd_functions[@]}"; do
|
||||||
|
if [[ "$f" = "_powerline_set_jobnum" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
precmd_functions+=( _powerline_set_jobnum )
|
||||||
|
chpwd_functions+=( _powerline_set_shortened_path )
|
||||||
|
_powerline_set_shortened_path
|
||||||
|
|
||||||
|
VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||||
|
|
||||||
|
if test -z "${POWERLINE_NO_ZSH_ZPYTHON}" && { zmodload libzpython || zmodload zsh/zpython } &>/dev/null ; then
|
||||||
|
precmd_functions+=( _powerline_update_counter )
|
||||||
|
zpython 'from powerline.bindings.zsh import setup as _powerline_setup'
|
||||||
|
zpython '_powerline_setup(globals())'
|
||||||
|
zpython 'del _powerline_setup'
|
||||||
|
powerline-reload() {
|
||||||
|
zpython 'from powerline.bindings.zsh import reload as _powerline_reload'
|
||||||
|
zpython '_powerline_reload()'
|
||||||
|
zpython 'del _powerline_reload'
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if test -z "${POWERLINE_COMMAND}" ; then
|
||||||
|
POWERLINE_COMMAND="$($POWERLINE_CONFIG shell command)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local add_args='-r .zsh'
|
||||||
|
add_args+=' --last_exit_code=$?'
|
||||||
|
add_args+=' --last_pipe_status="$pipestatus"'
|
||||||
|
add_args+=' --renderer_arg="client_id=$$"'
|
||||||
|
add_args+=' --renderer_arg="shortened_path=$_POWERLINE_SHORTENED_PATH"'
|
||||||
|
add_args+=' --jobnum=$_POWERLINE_JOBNUM'
|
||||||
|
local new_args_2=' --renderer_arg="parser_state=${(%%):-%_}"'
|
||||||
|
new_args_2+=' --renderer_arg="local_theme=continuation"'
|
||||||
|
local add_args_3=$add_args' --renderer_arg="local_theme=select"'
|
||||||
|
local add_args_2=$add_args$new_args_2
|
||||||
|
add_args+=' --width=$(( ${COLUMNS:-$(_powerline_columns_fallback)} - 1 ))'
|
||||||
|
local add_args_r2=$add_args$new_args_2
|
||||||
|
PS1='$($=POWERLINE_COMMAND shell aboveleft '$add_args')'
|
||||||
|
RPS1='$($=POWERLINE_COMMAND shell right '$add_args')'
|
||||||
|
PS2='$($=POWERLINE_COMMAND shell left '$add_args_2')'
|
||||||
|
RPS2='$($=POWERLINE_COMMAND shell right '$add_args_r2')'
|
||||||
|
PS3='$($=POWERLINE_COMMAND shell left '$add_args_3')'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_powerline_add_widget() {
|
||||||
|
local widget="$1"
|
||||||
|
local function="$2"
|
||||||
|
local old_widget_command="$(zle -l -L $widget)"
|
||||||
|
if [[ "$old_widget_command" = "zle -N $widget $function" ]] ; then
|
||||||
|
return 0
|
||||||
|
elif [[ -z "$old_widget_command" ]] ; then
|
||||||
|
zle -N $widget $function
|
||||||
|
else
|
||||||
|
local save_widget="_powerline_save_$widget"
|
||||||
|
local -i i=0
|
||||||
|
while ! test -z "$(zle -l -L $save_widget)" ; do
|
||||||
|
save_widget="${save_widget}_$i"
|
||||||
|
(( i++ ))
|
||||||
|
done
|
||||||
|
# If widget was defined with `zle -N widget` (without `function`
|
||||||
|
# argument) then this function will be handy.
|
||||||
|
eval "function $save_widget() { emulate -L zsh; $widget \$@ }"
|
||||||
|
eval "${old_widget_command/$widget/$save_widget}"
|
||||||
|
zle -N $widget $function
|
||||||
|
export _POWERLINE_SAVE_WIDGET="$save_widget"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if test -z "${POWERLINE_CONFIG}" ; then
|
||||||
|
if which powerline-config >/dev/null ; then
|
||||||
|
export POWERLINE_CONFIG=powerline-config
|
||||||
|
else
|
||||||
|
export POWERLINE_CONFIG="$_POWERLINE_SOURCED:h:h:h:h/scripts/powerline-config"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
setopt promptpercent
|
||||||
|
setopt promptsubst
|
||||||
|
|
||||||
|
if ${POWERLINE_CONFIG} shell --shell=zsh uses prompt ; then
|
||||||
|
_powerline_setup_prompt
|
||||||
|
_powerline_init_modes_support
|
||||||
|
fi
|
||||||
|
if ${POWERLINE_CONFIG} shell --shell=zsh uses tmux ; then
|
||||||
|
_powerline_init_tmux_support
|
||||||
|
fi
|
147
powerline/colorscheme.py
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
from copy import copy
|
||||||
|
|
||||||
|
from powerline.lib.unicode import unicode
|
||||||
|
|
||||||
|
|
||||||
|
DEFAULT_MODE_KEY = None
|
||||||
|
ATTR_BOLD = 1
|
||||||
|
ATTR_ITALIC = 2
|
||||||
|
ATTR_UNDERLINE = 4
|
||||||
|
|
||||||
|
|
||||||
|
def get_attr_flag(attributes):
|
||||||
|
'''Convert an attribute array to a renderer flag.'''
|
||||||
|
attr_flag = 0
|
||||||
|
if 'bold' in attributes:
|
||||||
|
attr_flag |= ATTR_BOLD
|
||||||
|
if 'italic' in attributes:
|
||||||
|
attr_flag |= ATTR_ITALIC
|
||||||
|
if 'underline' in attributes:
|
||||||
|
attr_flag |= ATTR_UNDERLINE
|
||||||
|
return attr_flag
|
||||||
|
|
||||||
|
|
||||||
|
def pick_gradient_value(grad_list, gradient_level):
|
||||||
|
'''Given a list of colors and gradient percent, return a color that should be used.
|
||||||
|
|
||||||
|
Note: gradient level is not checked for being inside [0, 100] interval.
|
||||||
|
'''
|
||||||
|
return grad_list[int(round(gradient_level * (len(grad_list) - 1) / 100))]
|
||||||
|
|
||||||
|
|
||||||
|
class Colorscheme(object):
|
||||||
|
def __init__(self, colorscheme_config, colors_config):
|
||||||
|
'''Initialize a colorscheme.'''
|
||||||
|
self.colors = {}
|
||||||
|
self.gradients = {}
|
||||||
|
|
||||||
|
self.groups = colorscheme_config['groups']
|
||||||
|
self.translations = colorscheme_config.get('mode_translations', {})
|
||||||
|
|
||||||
|
# Create a dict of color tuples with both a cterm and hex value
|
||||||
|
for color_name, color in colors_config['colors'].items():
|
||||||
|
try:
|
||||||
|
self.colors[color_name] = (color[0], int(color[1], 16))
|
||||||
|
except TypeError:
|
||||||
|
self.colors[color_name] = (color, cterm_to_hex[color])
|
||||||
|
|
||||||
|
# Create a dict of gradient names with two lists: for cterm and hex
|
||||||
|
# values. Two lists in place of one list of pairs were chosen because
|
||||||
|
# true colors allow more precise gradients.
|
||||||
|
for gradient_name, gradient in colors_config['gradients'].items():
|
||||||
|
if len(gradient) == 2:
|
||||||
|
self.gradients[gradient_name] = (
|
||||||
|
(gradient[0], [int(color, 16) for color in gradient[1]]))
|
||||||
|
else:
|
||||||
|
self.gradients[gradient_name] = (
|
||||||
|
(gradient[0], [cterm_to_hex[color] for color in gradient[0]]))
|
||||||
|
|
||||||
|
def get_gradient(self, gradient, gradient_level):
|
||||||
|
if gradient in self.gradients:
|
||||||
|
return tuple((pick_gradient_value(grad_list, gradient_level) for grad_list in self.gradients[gradient]))
|
||||||
|
else:
|
||||||
|
return self.colors[gradient]
|
||||||
|
|
||||||
|
def get_group_props(self, mode, trans, group, translate_colors=True):
|
||||||
|
if isinstance(group, (str, unicode)):
|
||||||
|
try:
|
||||||
|
group_props = trans['groups'][group]
|
||||||
|
except KeyError:
|
||||||
|
try:
|
||||||
|
group_props = self.groups[group]
|
||||||
|
except KeyError:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return self.get_group_props(mode, trans, group_props, True)
|
||||||
|
else:
|
||||||
|
return self.get_group_props(mode, trans, group_props, False)
|
||||||
|
else:
|
||||||
|
if translate_colors:
|
||||||
|
group_props = copy(group)
|
||||||
|
try:
|
||||||
|
ctrans = trans['colors']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
for key in ('fg', 'bg'):
|
||||||
|
try:
|
||||||
|
group_props[key] = ctrans[group_props[key]]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
return group_props
|
||||||
|
else:
|
||||||
|
return group
|
||||||
|
|
||||||
|
def get_highlighting(self, groups, mode, gradient_level=None):
|
||||||
|
trans = self.translations.get(mode, {})
|
||||||
|
for group in groups:
|
||||||
|
group_props = self.get_group_props(mode, trans, group)
|
||||||
|
if group_props:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise KeyError('Highlighting groups not found in colorscheme: ' + ', '.join(groups))
|
||||||
|
|
||||||
|
if gradient_level is None:
|
||||||
|
pick_color = self.colors.__getitem__
|
||||||
|
else:
|
||||||
|
pick_color = lambda gradient: self.get_gradient(gradient, gradient_level)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'fg': pick_color(group_props['fg']),
|
||||||
|
'bg': pick_color(group_props['bg']),
|
||||||
|
'attr': get_attr_flag(group_props.get('attr', [])),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# 0 1 2 3 4 5 6 7 8 9
|
||||||
|
cterm_to_hex = (
|
||||||
|
0x000000, 0xc00000, 0x008000, 0x804000, 0x0000c0, 0xc000c0, 0x008080, 0xc0c0c0, 0x808080, 0xff6060, # 0
|
||||||
|
0x00ff00, 0xffff00, 0x8080ff, 0xff40ff, 0x00ffff, 0xffffff, 0x000000, 0x00005f, 0x000087, 0x0000af, # 1
|
||||||
|
0x0000d7, 0x0000ff, 0x005f00, 0x005f5f, 0x005f87, 0x005faf, 0x005fd7, 0x005fff, 0x008700, 0x00875f, # 2
|
||||||
|
0x008787, 0x0087af, 0x0087d7, 0x0087ff, 0x00af00, 0x00af5f, 0x00af87, 0x00afaf, 0x00afd7, 0x00afff, # 3
|
||||||
|
0x00d700, 0x00d75f, 0x00d787, 0x00d7af, 0x00d7d7, 0x00d7ff, 0x00ff00, 0x00ff5f, 0x00ff87, 0x00ffaf, # 4
|
||||||
|
0x00ffd7, 0x00ffff, 0x5f0000, 0x5f005f, 0x5f0087, 0x5f00af, 0x5f00d7, 0x5f00ff, 0x5f5f00, 0x5f5f5f, # 5
|
||||||
|
0x5f5f87, 0x5f5faf, 0x5f5fd7, 0x5f5fff, 0x5f8700, 0x5f875f, 0x5f8787, 0x5f87af, 0x5f87d7, 0x5f87ff, # 6
|
||||||
|
0x5faf00, 0x5faf5f, 0x5faf87, 0x5fafaf, 0x5fafd7, 0x5fafff, 0x5fd700, 0x5fd75f, 0x5fd787, 0x5fd7af, # 7
|
||||||
|
0x5fd7d7, 0x5fd7ff, 0x5fff00, 0x5fff5f, 0x5fff87, 0x5fffaf, 0x5fffd7, 0x5fffff, 0x870000, 0x87005f, # 8
|
||||||
|
0x870087, 0x8700af, 0x8700d7, 0x8700ff, 0x875f00, 0x875f5f, 0x875f87, 0x875faf, 0x875fd7, 0x875fff, # 9
|
||||||
|
0x878700, 0x87875f, 0x878787, 0x8787af, 0x8787d7, 0x8787ff, 0x87af00, 0x87af5f, 0x87af87, 0x87afaf, # 10
|
||||||
|
0x87afd7, 0x87afff, 0x87d700, 0x87d75f, 0x87d787, 0x87d7af, 0x87d7d7, 0x87d7ff, 0x87ff00, 0x87ff5f, # 11
|
||||||
|
0x87ff87, 0x87ffaf, 0x87ffd7, 0x87ffff, 0xaf0000, 0xaf005f, 0xaf0087, 0xaf00af, 0xaf00d7, 0xaf00ff, # 12
|
||||||
|
0xaf5f00, 0xaf5f5f, 0xaf5f87, 0xaf5faf, 0xaf5fd7, 0xaf5fff, 0xaf8700, 0xaf875f, 0xaf8787, 0xaf87af, # 13
|
||||||
|
0xaf87d7, 0xaf87ff, 0xafaf00, 0xafaf5f, 0xafaf87, 0xafafaf, 0xafafd7, 0xafafff, 0xafd700, 0xafd75f, # 14
|
||||||
|
0xafd787, 0xafd7af, 0xafd7d7, 0xafd7ff, 0xafff00, 0xafff5f, 0xafff87, 0xafffaf, 0xafffd7, 0xafffff, # 15
|
||||||
|
0xd70000, 0xd7005f, 0xd70087, 0xd700af, 0xd700d7, 0xd700ff, 0xd75f00, 0xd75f5f, 0xd75f87, 0xd75faf, # 16
|
||||||
|
0xd75fd7, 0xd75fff, 0xd78700, 0xd7875f, 0xd78787, 0xd787af, 0xd787d7, 0xd787ff, 0xd7af00, 0xd7af5f, # 17
|
||||||
|
0xd7af87, 0xd7afaf, 0xd7afd7, 0xd7afff, 0xd7d700, 0xd7d75f, 0xd7d787, 0xd7d7af, 0xd7d7d7, 0xd7d7ff, # 18
|
||||||
|
0xd7ff00, 0xd7ff5f, 0xd7ff87, 0xd7ffaf, 0xd7ffd7, 0xd7ffff, 0xff0000, 0xff005f, 0xff0087, 0xff00af, # 19
|
||||||
|
0xff00d7, 0xff00ff, 0xff5f00, 0xff5f5f, 0xff5f87, 0xff5faf, 0xff5fd7, 0xff5fff, 0xff8700, 0xff875f, # 20
|
||||||
|
0xff8787, 0xff87af, 0xff87d7, 0xff87ff, 0xffaf00, 0xffaf5f, 0xffaf87, 0xffafaf, 0xffafd7, 0xffafff, # 21
|
||||||
|
0xffd700, 0xffd75f, 0xffd787, 0xffd7af, 0xffd7d7, 0xffd7ff, 0xffff00, 0xffff5f, 0xffff87, 0xffffaf, # 22
|
||||||
|
0xffffd7, 0xffffff, 0x080808, 0x121212, 0x1c1c1c, 0x262626, 0x303030, 0x3a3a3a, 0x444444, 0x4e4e4e, # 23
|
||||||
|
0x585858, 0x626262, 0x6c6c6c, 0x767676, 0x808080, 0x8a8a8a, 0x949494, 0x9e9e9e, 0xa8a8a8, 0xb2b2b2, # 24
|
||||||
|
0xbcbcbc, 0xc6c6c6, 0xd0d0d0, 0xdadada, 0xe4e4e4, 0xeeeeee # 25
|
||||||
|
)
|
10
powerline/config.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# vim:fileencoding=utf-8:noet
|
||||||
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
POWERLINE_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
BINDINGS_DIRECTORY = os.path.join(POWERLINE_ROOT, 'powerline', 'bindings')
|
||||||
|
TMUX_CONFIG_DIRECTORY = os.path.join(BINDINGS_DIRECTORY, 'tmux')
|
||||||
|
DEFAULT_SYSTEM_CONFIG_DIR = None
|
117
powerline/config_files/colors.json
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
{
|
||||||
|
"colors": {
|
||||||
|
"black": 16,
|
||||||
|
"white": 231,
|
||||||
|
|
||||||
|
"darkestgreen": 22,
|
||||||
|
"darkgreen": 28,
|
||||||
|
"mediumgreen": 70,
|
||||||
|
"brightgreen": 148,
|
||||||
|
|
||||||
|
"darkestcyan": 23,
|
||||||
|
"darkcyan": 74,
|
||||||
|
"mediumcyan": 117,
|
||||||
|
"brightcyan": 159,
|
||||||
|
|
||||||
|
"darkestblue": 24,
|
||||||
|
"darkblue": 31,
|
||||||
|
|
||||||
|
"red": 1,
|
||||||
|
"darkestred": 52,
|
||||||
|
"darkred": 88,
|
||||||
|
"mediumred": 124,
|
||||||
|
"brightred": 160,
|
||||||
|
"brightestred": 196,
|
||||||
|
|
||||||
|
"darkestpurple": 55,
|
||||||
|
"mediumpurple": 98,
|
||||||
|
"brightpurple": 189,
|
||||||
|
|
||||||
|
"darkorange": 94,
|
||||||
|
"mediumorange": 166,
|
||||||
|
"brightorange": 208,
|
||||||
|
"brightestorange": 214,
|
||||||
|
|
||||||
|
"brightyellow": 220,
|
||||||
|
|
||||||
|
"gray0": 233,
|
||||||
|
"gray1": 235,
|
||||||
|
"gray2": 236,
|
||||||
|
"gray3": 239,
|
||||||
|
"gray4": 240,
|
||||||
|
"gray5": 241,
|
||||||
|
"gray6": 244,
|
||||||
|
"gray7": 245,
|
||||||
|
"gray8": 247,
|
||||||
|
"gray9": 250,
|
||||||
|
"gray10": 252,
|
||||||
|
|
||||||
|
"lightyellowgreen": 106,
|
||||||
|
"gold3": 178,
|
||||||
|
"orangered": 202,
|
||||||
|
|
||||||
|
"steelblue": 67,
|
||||||
|
"darkorange3": 166,
|
||||||
|
"skyblue1": 117,
|
||||||
|
"khaki1": 228,
|
||||||
|
|
||||||
|
"solarized:base03": [8, "002b36"],
|
||||||
|
"solarized:base02": [0, "073642"],
|
||||||
|
"solarized:base01": [10, "586e75"],
|
||||||
|
"solarized:base00": [11, "657b83"],
|
||||||
|
"solarized:base0": [12, "839496"],
|
||||||
|
"solarized:base1": [14, "93a1a1"],
|
||||||
|
"solarized:base2": [7, "eee8d5"],
|
||||||
|
"solarized:base3": [15, "fdf6e3"],
|
||||||
|
"solarized:yellow": [3, "b58900"],
|
||||||
|
"solarized:orange": [9, "cb4b16"],
|
||||||
|
"solarized:red": [1, "dc322f"],
|
||||||
|
"solarized:magenta": [5, "d33682"],
|
||||||
|
"solarized:violet": [13, "6c71c4"],
|
||||||
|
"solarized:blue": [4, "268bd2"],
|
||||||
|
"solarized:cyan": [6, "2aa198"],
|
||||||
|
"solarized:green": [2, "859900"]
|
||||||
|
},
|
||||||
|
"gradients": {
|
||||||
|
"dark_GREEN_Orange_red": [
|
||||||
|
[22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 94, 94, 94, 94, 94, 94, 94, 88, 52],
|
||||||
|
["006000", "006000", "006000", "006000", "006000", "006000", "006000", "006000", "006000", "036000", "076000", "0a6000", "0d6000", "106000", "126000", "146000", "166000", "186000", "1a6000", "1b6000", "1d6000", "1e6000", "206000", "216000", "236000", "246000", "256000", "266000", "286000", "296000", "2a6000", "2b6000", "2c6100", "2d6100", "2f6100", "306100", "316100", "326100", "336100", "346100", "356100", "366100", "376100", "386100", "386100", "396100", "3a6100", "3b6100", "3c6100", "3d6100", "3e6100", "3f6100", "406100", "406100", "416100", "426000", "436000", "446000", "456000", "456000", "466000", "476000", "486000", "496000", "496000", "4a6000", "4b6000", "4c6000", "4d6000", "4d6000", "4e6000", "4f6000", "506000", "506000", "516000", "526000", "536000", "536000", "546000", "556000", "566000", "566000", "576000", "586000", "596000", "596000", "5a6000", "5d6000", "616000", "646000", "686000", "6b6000", "6f6000", "726000", "766000", "796000", "7d6000", "806000", "7e5500", "6f3105", "5d0001"]
|
||||||
|
],
|
||||||
|
"GREEN_Orange_red": [
|
||||||
|
[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1],
|
||||||
|
["005f00", "015f00", "025f00", "035f00", "045f00", "055f00", "065f00", "075f00", "085f00", "095f00", "0b5f00", "0c5f00", "0d5f00", "0e5f00", "0f5f00", "105f00", "115f00", "125f00", "135f00", "145f00", "165f00", "175f00", "185f00", "195f00", "1a5f00", "1b5f00", "1c5f00", "1d5f00", "1e5f00", "1f5f00", "215f00", "225f00", "235f00", "245f00", "255f00", "265f00", "275f00", "285f00", "295f00", "2a5f00", "2c5f00", "2d5f00", "2e5f00", "2f5f00", "305f00", "315f00", "325f00", "335f00", "345f00", "355f00", "375f00", "385f00", "395f00", "3a5f00", "3b5f00", "3c5f00", "3d5f00", "3e5f00", "3f5f00", "415f00", "425f00", "435f00", "445f00", "455f00", "465f00", "475f00", "485f00", "495f00", "4a5f00", "4c5f00", "4d5f00", "4e5f00", "4f5f00", "505f00", "515f00", "525f00", "535f00", "545f00", "555f00", "575f00", "585f00", "595f00", "5a5f00", "5b5f00", "5c5f00", "5d5f00", "5e5f00", "615f00", "655f00", "685f00", "6c5f00", "6f5f00", "735f00", "765f00", "7a5f00", "7d5f00", "815f00", "845f00", "815200", "702900"]
|
||||||
|
],
|
||||||
|
"green_yellow_red": [
|
||||||
|
[190, 184, 178, 172, 166, 160],
|
||||||
|
["8ae71c", "8ce71c", "8fe71c", "92e71c", "95e71d", "98e71d", "9ae71d", "9de71d", "a0e71e", "a3e71e", "a6e71e", "a8e71e", "abe71f", "aee71f", "b1e71f", "b4e71f", "b6e720", "b9e720", "bce720", "bfe720", "c2e821", "c3e721", "c5e621", "c7e521", "c9e522", "cbe422", "cde322", "cfe222", "d1e223", "d3e123", "d5e023", "d7df23", "d9df24", "dbde24", "dddd24", "dfdc24", "e1dc25", "e3db25", "e5da25", "e7d925", "e9d926", "e9d626", "e9d426", "e9d126", "e9cf27", "e9cc27", "e9ca27", "e9c727", "e9c528", "e9c228", "e9c028", "e9bd28", "e9bb29", "e9b829", "e9b629", "e9b329", "e9b12a", "e9ae2a", "e9ac2a", "e9a92a", "eaa72b", "eaa42b", "eaa22b", "ea9f2b", "ea9d2c", "ea9b2c", "ea982c", "ea962c", "ea942d", "ea912d", "ea8f2d", "ea8d2d", "ea8a2e", "ea882e", "ea862e", "ea832e", "ea812f", "ea7f2f", "ea7c2f", "ea7a2f", "eb7830", "eb7530", "eb7330", "eb7130", "eb6f31", "eb6c31", "eb6a31", "eb6831", "eb6632", "eb6332", "eb6132", "eb5f32", "eb5d33", "eb5a33", "eb5833", "eb5633", "eb5434", "eb5134", "eb4f34", "eb4d34", "ec4b35"]
|
||||||
|
],
|
||||||
|
"green_yellow_orange_red": [
|
||||||
|
[2, 3, 9, 1],
|
||||||
|
["719e07", "739d06", "759c06", "779c06", "799b06", "7b9a05", "7d9a05", "7f9905", "819805", "839805", "859704", "879704", "899604", "8b9504", "8d9504", "8f9403", "919303", "949303", "969203", "989102", "9a9102", "9c9002", "9e9002", "a08f02", "a28e01", "a48e01", "a68d01", "a88c01", "aa8c01", "ac8b00", "ae8a00", "b08a00", "b28900", "b58900", "b58700", "b68501", "b78302", "b78102", "b87f03", "b97d04", "b97b04", "ba7905", "bb7806", "bb7606", "bc7407", "bd7208", "bd7008", "be6e09", "bf6c0a", "bf6a0a", "c0690b", "c1670c", "c1650c", "c2630d", "c3610e", "c35f0e", "c45d0f", "c55b10", "c55a10", "c65811", "c75612", "c75412", "c85213", "c95014", "c94e14", "ca4c15", "cb4b16", "cb4a16", "cc4917", "cc4818", "cd4719", "cd4719", "ce461a", "ce451b", "cf441c", "cf441c", "d0431d", "d0421e", "d1411f", "d1411f", "d24020", "d23f21", "d33e22", "d33e22", "d43d23", "d43c24", "d53b25", "d53b25", "d63a26", "d63927", "d73828", "d73828", "d83729", "d8362a", "d9352b", "d9352b", "da342c", "da332d", "db322e", "dc322f"]
|
||||||
|
],
|
||||||
|
"yellow_red": [
|
||||||
|
[220, 178, 172, 166, 160],
|
||||||
|
["ffd700", "fdd500", "fbd300", "fad200", "f8d000", "f7cf00", "f5cd00", "f3cb00", "f2ca00", "f0c800", "efc700", "edc500", "ebc300", "eac200", "e8c000", "e7bf00", "e5bd00", "e3bb00", "e2ba00", "e0b800", "dfb700", "ddb500", "dbb300", "dab200", "d8b000", "d7af00", "d7ad00", "d7ab00", "d7aa00", "d7a800", "d7a700", "d7a500", "d7a300", "d7a200", "d7a000", "d79f00", "d79d00", "d79b00", "d79a00", "d79800", "d79700", "d79500", "d79300", "d79200", "d79000", "d78f00", "d78d00", "d78b00", "d78a00", "d78800", "d78700", "d78500", "d78300", "d78200", "d78000", "d77f00", "d77d00", "d77b00", "d77a00", "d77800", "d77700", "d77500", "d77300", "d77200", "d77000", "d76f00", "d76d00", "d76b00", "d76a00", "d76800", "d76700", "d76500", "d76300", "d76200", "d76000", "d75f00", "d75b00", "d75700", "d75300", "d74f00", "d74c00", "d74800", "d74400", "d74000", "d73c00", "d73900", "d73500", "d73100", "d72d00", "d72900", "d72600", "d72200", "d71e00", "d71a00", "d71600", "d71300", "d70f00", "d70b00", "d70700"]
|
||||||
|
],
|
||||||
|
"yellow_orange_red": [
|
||||||
|
[3, 9, 1],
|
||||||
|
["b58900", "b58700", "b58600", "b68501", "b68401", "b78202", "b78102", "b88003", "b87f03", "b87d03", "b97c04", "b97b04", "ba7a05", "ba7805", "bb7706", "bb7606", "bc7507", "bc7307", "bc7207", "bd7108", "bd7008", "be6e09", "be6d09", "bf6c0a", "bf6b0a", "c06a0b", "c0680b", "c0670b", "c1660c", "c1650c", "c2630d", "c2620d", "c3610e", "c3600e", "c35e0e", "c45d0f", "c45c0f", "c55b10", "c55910", "c65811", "c65711", "c75612", "c75412", "c75312", "c85213", "c85113", "c94f14", "c94e14", "ca4d15", "ca4c15", "cb4b16", "cb4a16", "cb4a17", "cc4917", "cc4918", "cc4818", "cd4819", "cd4719", "cd471a", "ce461a", "ce461b", "ce451b", "cf451c", "cf441c", "cf441d", "d0431d", "d0431e", "d0421e", "d1421f", "d1411f", "d14120", "d24020", "d24021", "d23f21", "d33f22", "d33e22", "d33e23", "d43d23", "d43d24", "d43c24", "d53c25", "d53b25", "d53b26", "d63a26", "d63a27", "d63927", "d73928", "d73828", "d73829", "d83729", "d8372a", "d8362a", "d9362b", "d9352b", "d9352c", "da342c", "da342d", "da332d", "db332e"]
|
||||||
|
],
|
||||||
|
"blue_red": [
|
||||||
|
[39, 74, 68, 67, 103, 97, 96, 132, 131, 167, 203, 197],
|
||||||
|
["19b4fe", "1bb2fc", "1db1fa", "1faff8", "22aef6", "24adf4", "26abf2", "29aaf0", "2ba9ee", "2da7ec", "30a6ea", "32a5e8", "34a3e6", "36a2e4", "39a0e2", "3b9fe1", "3d9edf", "409cdd", "429bdb", "449ad9", "4798d7", "4997d5", "4b96d3", "4d94d1", "5093cf", "5292cd", "5490cb", "578fc9", "598dc7", "5b8cc6", "5e8bc4", "6089c2", "6288c0", "6487be", "6785bc", "6984ba", "6b83b8", "6e81b6", "7080b4", "727eb2", "757db0", "777cae", "797aac", "7b79ab", "7e78a9", "8076a7", "8275a5", "8574a3", "8772a1", "89719f", "8c709d", "8e6e9b", "906d99", "926b97", "956a95", "976993", "996791", "9c668f", "9e658e", "a0638c", "a3628a", "a56188", "a75f86", "a95e84", "ac5c82", "ae5b80", "b05a7e", "b3587c", "b5577a", "b75678", "ba5476", "bc5374", "be5273", "c05071", "c34f6f", "c54e6d", "c74c6b", "ca4b69", "cc4967", "ce4865", "d14763", "d34561", "d5445f", "d7435d", "da415b", "dc4059", "de3f58", "e13d56", "e33c54", "e53a52", "e83950", "ea384e", "ec364c", "ee354a", "f13448", "f33246", "f53144", "f83042", "fa2e40"]
|
||||||
|
],
|
||||||
|
"white_red": [
|
||||||
|
[231, 255, 223, 216, 209, 202, 196],
|
||||||
|
["ffffff", "fefefe", "fdfdfd", "fdfdfd", "fcfcfc", "fbfbfb", "fafafa", "fafafa", "f9f9f9", "f8f8f8", "f7f7f7", "f7f7f7", "f6f6f6", "f5f5f5", "f4f4f4", "f4f3f4", "f3f3f3", "f2f2f2", "f1f1f1", "f0f0f0", "f0f0f0", "efefef", "eeeeee", "efecea", "f1eae4", "f2e8de", "f3e6d8", "f5e4d3", "f6e2cd", "f7e0c7", "f8dec2", "f9dcbc", "fadab6", "fad8b1", "fbd5ac", "fbd2a9", "fbcea5", "fbcaa1", "fbc79e", "fbc39a", "fbc097", "fbbc93", "fbb88f", "fbb58c", "fab188", "faad85", "faaa81", "fba67e", "fba37a", "fb9f76", "fb9c73", "fb986f", "fb946c", "fb9168", "fa8d65", "fa8961", "fa865c", "fa8256", "fb7f4f", "fb7b48", "fb7841", "fb743a", "fb7133", "fb6d2c", "fa6a23", "fa661a", "fa620e", "fa5f03", "fa5d03", "fa5b03", "fa5a03", "fa5803", "fa5703", "fa5503", "fa5303", "fa5103", "fa4f03", "fa4e03", "fa4c03", "fa4a04", "fa4804", "fa4604", "fa4404", "fa4204", "fa3f04", "fa3d04", "fa3b04", "fa3805", "fa3605", "fa3305", "fb3105", "fb2e05", "fb2a05", "fb2705", "fb2306", "fb1f06", "fb1b06", "fb1506", "fb0e06", "fa0506", "fa0007"]
|
||||||
|
],
|
||||||
|
"dark_green_gray": [
|
||||||
|
[70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 107, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247, 247],
|
||||||
|
["51b000", "52b000", "54b000", "55b002", "56b007", "57b00d", "58b011", "59af15", "5aaf18", "5caf1b", "5daf1e", "5eaf21", "5faf23", "60ae25", "61ae27", "62ae2a", "63ae2c", "64ae2e", "65ae30", "66ae31", "67ad33", "68ad35", "69ad37", "69ad38", "6aad3a", "6bad3c", "6cac3d", "6dac3f", "6eac40", "6fac42", "70ac44", "70ac45", "71ab47", "72ab48", "73ab49", "74ab4b", "75ab4c", "75ab4e", "76aa4f", "77aa51", "78aa52", "79aa53", "79aa55", "7aaa56", "7ba957", "7ca959", "7ca95a", "7da95b", "7ea95d", "7fa95e", "7fa85f", "80a861", "81a862", "81a863", "82a865", "83a766", "83a767", "84a768", "85a76a", "85a76b", "86a66c", "87a66d", "87a66f", "88a670", "89a671", "89a672", "8aa574", "8ba575", "8ba576", "8ca577", "8da579", "8da47a", "8ea47b", "8ea47c", "8fa47d", "90a47f", "90a380", "91a381", "91a382", "92a384", "93a385", "93a286", "94a287", "94a288", "95a28a", "95a18b", "96a18c", "97a18d", "97a18e", "98a190", "98a091", "99a092", "99a093", "9aa094", "9aa096", "9b9f97", "9b9f98", "9c9f99", "9c9f9a", "9d9e9c", "9d9e9d"]
|
||||||
|
],
|
||||||
|
"light_green_gray": [
|
||||||
|
[148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 148, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 149, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 187, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250],
|
||||||
|
["a3d900", "a4d800", "a4d800", "a5d805", "a5d80d", "a6d714", "a6d719", "a6d71d", "a7d621", "a7d625", "a8d628", "a8d62b", "a8d52e", "a9d531", "a9d533", "aad536", "aad438", "aad43a", "abd43d", "abd33f", "abd341", "acd343", "acd345", "acd247", "add249", "add24b", "add14d", "aed14f", "aed151", "aed152", "afd054", "afd056", "afd058", "b0d059", "b0cf5b", "b0cf5d", "b1cf5e", "b1ce60", "b1ce62", "b1ce63", "b2ce65", "b2cd67", "b2cd68", "b3cd6a", "b3cc6b", "b3cc6d", "b3cc6e", "b4cc70", "b4cb71", "b4cb73", "b4cb75", "b5ca76", "b5ca78", "b5ca79", "b5ca7a", "b6c97c", "b6c97d", "b6c97f", "b6c880", "b6c882", "b7c883", "b7c885", "b7c786", "b7c788", "b7c789", "b8c68a", "b8c68c", "b8c68d", "b8c68f", "b8c590", "b9c591", "b9c593", "b9c494", "b9c496", "b9c497", "b9c498", "bac39a", "bac39b", "bac39d", "bac29e", "bac29f", "bac2a1", "bac2a2", "bac1a4", "bbc1a5", "bbc1a6", "bbc0a8", "bbc0a9", "bbc0aa", "bbc0ac", "bbbfad", "bbbfae", "bbbfb0", "bbbeb1", "bcbeb3", "bcbeb4", "bcbdb5", "bcbdb7", "bcbdb8", "bcbdb9", "bcbcbb"]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
44
powerline/config_files/colorschemes/default.json
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"name": "Default",
|
||||||
|
"groups": {
|
||||||
|
"background:divider": { "fg": "gray5", "bg": "gray0", "attr": [] },
|
||||||
|
"session": { "fg": "black", "bg": "gray10", "attr": ["bold"] },
|
||||||
|
"date": { "fg": "gray8", "bg": "gray2", "attr": [] },
|
||||||
|
"time": { "fg": "gray10", "bg": "gray2", "attr": ["bold"] },
|
||||||
|
"time:divider": { "fg": "gray5", "bg": "gray2", "attr": [] },
|
||||||
|
"email_alert": { "fg": "white", "bg": "brightred", "attr": ["bold"] },
|
||||||
|
"email_alert_gradient": { "fg": "white", "bg": "yellow_orange_red", "attr": ["bold"] },
|
||||||
|
"hostname": { "fg": "black", "bg": "gray10", "attr": ["bold"] },
|
||||||
|
"weather": { "fg": "gray8", "bg": "gray0", "attr": [] },
|
||||||
|
"weather_temp_gradient": { "fg": "blue_red", "bg": "gray0", "attr": [] },
|
||||||
|
"weather_condition_hot": { "fg": "khaki1", "bg": "gray0", "attr": [] },
|
||||||
|
"weather_condition_snowy": { "fg": "skyblue1", "bg": "gray0", "attr": [] },
|
||||||
|
"weather_condition_rainy": { "fg": "skyblue1", "bg": "gray0", "attr": [] },
|
||||||
|
"uptime": { "fg": "gray8", "bg": "gray0", "attr": [] },
|
||||||
|
"external_ip": { "fg": "gray8", "bg": "gray0", "attr": [] },
|
||||||
|
"internal_ip": { "fg": "gray8", "bg": "gray0", "attr": [] },
|
||||||
|
"network_load": { "fg": "gray8", "bg": "gray0", "attr": [] },
|
||||||
|
"network_load_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0", "attr": [] },
|
||||||
|
"system_load": { "fg": "gray8", "bg": "gray0", "attr": [] },
|
||||||
|
"system_load_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0", "attr": [] },
|
||||||
|
"environment": { "fg": "gray8", "bg": "gray0", "attr": [] },
|
||||||
|
"cpu_load_percent": { "fg": "gray8", "bg": "gray0", "attr": [] },
|
||||||
|
"cpu_load_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0", "attr": [] },
|
||||||
|
"battery": { "fg": "gray8", "bg": "gray0", "attr": [] },
|
||||||
|
"battery_gradient": { "fg": "white_red", "bg": "gray0", "attr": [] },
|
||||||
|
"battery_full": { "fg": "red", "bg": "gray0", "attr": [] },
|
||||||
|
"battery_empty": { "fg": "white", "bg": "gray0", "attr": [] },
|
||||||
|
"now_playing": { "fg": "gray10", "bg": "black", "attr": [] },
|
||||||
|
"user": { "fg": "white", "bg": "darkblue", "attr": ["bold"] },
|
||||||
|
"superuser": { "fg": "white", "bg": "brightred", "attr": ["bold"] },
|
||||||
|
"branch": { "fg": "gray9", "bg": "gray2", "attr": [] },
|
||||||
|
"branch_dirty": { "fg": "brightyellow", "bg": "gray2", "attr": [] },
|
||||||
|
"branch_clean": { "fg": "gray9", "bg": "gray2", "attr": [] },
|
||||||
|
"branch:divider": { "fg": "gray7", "bg": "gray2", "attr": [] },
|
||||||
|
"cwd": { "fg": "gray9", "bg": "gray4", "attr": [] },
|
||||||
|
"cwd:current_folder": { "fg": "gray10", "bg": "gray4", "attr": ["bold"] },
|
||||||
|
"cwd:divider": { "fg": "gray7", "bg": "gray4", "attr": [] },
|
||||||
|
"virtualenv": { "fg": "white", "bg": "darkcyan", "attr": [] },
|
||||||
|
"attached_clients": { "fg": "gray8", "bg": "gray0", "attr": [] }
|
||||||
|
}
|
||||||
|
}
|
7
powerline/config_files/colorschemes/ipython/default.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"name": "Default color scheme for IPython prompt",
|
||||||
|
"groups": {
|
||||||
|
"prompt": { "fg": "gray9", "bg": "gray4", "attr": [] },
|
||||||
|
"prompt_count": { "fg": "white", "bg": "gray4", "attr": [] }
|
||||||
|
}
|
||||||
|
}
|
6
powerline/config_files/colorschemes/shell/__main__.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"groups": {
|
||||||
|
"continuation": "cwd",
|
||||||
|
"continuation:current": "cwd:current_folder"
|
||||||
|
}
|
||||||
|
}
|
19
powerline/config_files/colorschemes/shell/default.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "Default color scheme for shell prompts",
|
||||||
|
"groups": {
|
||||||
|
"hostname": { "fg": "brightyellow", "bg": "mediumorange", "attr": [] },
|
||||||
|
"jobnum": { "fg": "brightyellow", "bg": "mediumorange", "attr": [] },
|
||||||
|
"exit_fail": { "fg": "white", "bg": "darkestred", "attr": [] },
|
||||||
|
"exit_success": { "fg": "white", "bg": "darkestgreen", "attr": [] },
|
||||||
|
"environment": { "fg": "white", "bg": "darkestgreen", "attr": [] },
|
||||||
|
"mode": { "fg": "darkestgreen", "bg": "brightgreen", "attr": ["bold"] },
|
||||||
|
"attached_clients": { "fg": "white", "bg": "darkestgreen", "attr": [] }
|
||||||
|
},
|
||||||
|
"mode_translations": {
|
||||||
|
"vicmd": {
|
||||||
|
"groups": {
|
||||||
|
"mode": {"fg": "darkestcyan", "bg": "white", "attr": ["bold"]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
powerline/config_files/colorschemes/shell/solarized.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"name": "Solarized dark for shell",
|
||||||
|
"groups": {
|
||||||
|
"jobnum": { "fg": "solarized:base3", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"exit_fail": { "fg": "solarized:base3", "bg": "solarized:red", "attr": [] },
|
||||||
|
"exit_success": { "fg": "solarized:base3", "bg": "solarized:green", "attr": [] },
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:green", "attr": ["bold"] }
|
||||||
|
},
|
||||||
|
"mode_translations": {
|
||||||
|
"vicmd": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
powerline/config_files/colorschemes/solarized.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"name": "Solarized dark",
|
||||||
|
"groups": {
|
||||||
|
"background": { "fg": "solarized:base3", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"user": { "fg": "solarized:base3", "bg": "solarized:blue", "attr": ["bold"] },
|
||||||
|
"superuser": { "fg": "solarized:base3", "bg": "solarized:red", "attr": ["bold"] },
|
||||||
|
"virtualenv": { "fg": "solarized:base3", "bg": "solarized:green", "attr": [] },
|
||||||
|
"branch": { "fg": "solarized:base1", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"branch_dirty": { "fg": "solarized:yellow", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"branch_clean": { "fg": "solarized:base1", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"cwd": { "fg": "solarized:base2", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"cwd:current_folder": { "fg": "solarized:base3", "bg": "solarized:base01", "attr": ["bold"] },
|
||||||
|
"cwd:divider": { "fg": "solarized:base1", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"hostname": { "fg": "solarized:base3", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"environment": { "fg": "solarized:base3", "bg": "solarized:green", "attr": [] },
|
||||||
|
"attached_clients": { "fg": "solarized:base3", "bg": "solarized:green", "attr": [] }
|
||||||
|
}
|
||||||
|
}
|
31
powerline/config_files/colorschemes/vim/__main__.json
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"groups": {
|
||||||
|
"branch_clean": "branch",
|
||||||
|
"environment": "information:unimportant",
|
||||||
|
"file_size": "information:unimportant",
|
||||||
|
"file_format": "information:unimportant",
|
||||||
|
"file_encoding": "file_format",
|
||||||
|
"file_type": "file_format",
|
||||||
|
"branch": "information:additional",
|
||||||
|
"file_scheme": "file_name",
|
||||||
|
"file_directory": "information:additional",
|
||||||
|
"file_name_empty": "file_directory",
|
||||||
|
"line_percent": "information:additional",
|
||||||
|
"line_count": "line_current",
|
||||||
|
"position": "information:additional",
|
||||||
|
"single_tab": "line_current",
|
||||||
|
"many_tabs": "line_current",
|
||||||
|
"bufnr": "file_directory",
|
||||||
|
"winnr": "information:unimportant",
|
||||||
|
"tabnr": "file_directory",
|
||||||
|
|
||||||
|
"tab_nc:file_directory": "information:unimportant",
|
||||||
|
"tab_nc:file_name": "tab_nc:file_directory",
|
||||||
|
"tab_nc:tabnr": "tab_nc:file_directory",
|
||||||
|
|
||||||
|
"buf_nc:file_directory": "tab_nc:file_directory",
|
||||||
|
"buf_nc:file_name": "tab_nc:file_name",
|
||||||
|
"buf_nc:bufnr": "tab_nc:tabnr",
|
||||||
|
"buf_nc:modified_indicator": "tab_nc:modified_indicator"
|
||||||
|
}
|
||||||
|
}
|
100
powerline/config_files/colorschemes/vim/default.json
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
{
|
||||||
|
"name": "Default color scheme",
|
||||||
|
"groups": {
|
||||||
|
"information:unimportant": { "fg": "gray8", "bg": "gray2", "attr": [] },
|
||||||
|
"information:additional": { "fg": "gray9", "bg": "gray4", "attr": [] },
|
||||||
|
"background": { "fg": "white", "bg": "gray2", "attr": [] },
|
||||||
|
"background:divider": { "fg": "gray6", "bg": "gray2", "attr": [] },
|
||||||
|
"mode": { "fg": "darkestgreen", "bg": "brightgreen", "attr": ["bold"] },
|
||||||
|
"visual_range": { "fg": "brightestorange", "bg": "darkorange", "attr": ["bold"] },
|
||||||
|
"modified_indicator": { "fg": "brightyellow", "bg": "gray4", "attr": ["bold"] },
|
||||||
|
"paste_indicator": { "fg": "white", "bg": "mediumorange", "attr": ["bold"] },
|
||||||
|
"readonly_indicator": { "fg": "brightestred", "bg": "gray4", "attr": [] },
|
||||||
|
"branch_dirty": { "fg": "brightyellow", "bg": "gray4", "attr": [] },
|
||||||
|
"branch:divider": { "fg": "gray7", "bg": "gray4", "attr": [] },
|
||||||
|
"file_name": { "fg": "white", "bg": "gray4", "attr": ["bold"] },
|
||||||
|
"window_title": { "fg": "white", "bg": "gray4", "attr": [] },
|
||||||
|
"file_name_no_file": { "fg": "gray9", "bg": "gray4", "attr": ["bold"] },
|
||||||
|
"file_vcs_status": { "fg": "brightestred", "bg": "gray4", "attr": [] },
|
||||||
|
"file_vcs_status_M": { "fg": "brightyellow", "bg": "gray4", "attr": [] },
|
||||||
|
"file_vcs_status_A": { "fg": "brightgreen", "bg": "gray4", "attr": [] },
|
||||||
|
"line_percent": { "fg": "gray9", "bg": "gray4", "attr": [] },
|
||||||
|
"line_percent_gradient": { "fg": "dark_green_gray", "bg": "gray4", "attr": [] },
|
||||||
|
"position": { "fg": "gray9", "bg": "gray4", "attr": [] },
|
||||||
|
"position_gradient": { "fg": "green_yellow_red", "bg": "gray4", "attr": [] },
|
||||||
|
"line_current": { "fg": "gray1", "bg": "gray10", "attr": ["bold"] },
|
||||||
|
"line_current_symbol": { "fg": "gray1", "bg": "gray10", "attr": [] },
|
||||||
|
"virtcol_current_gradient": { "fg": "dark_GREEN_Orange_red", "bg": "gray10", "attr": [] },
|
||||||
|
"col_current": { "fg": "gray6", "bg": "gray10", "attr": [] },
|
||||||
|
"modified_buffers": { "fg": "brightyellow", "bg": "gray2", "attr": [] },
|
||||||
|
"attached_clients": { "fg": "gray8", "bg": "gray2", "attr": [] },
|
||||||
|
"error": { "fg": "brightestred", "bg": "darkred", "attr": ["bold"] },
|
||||||
|
"warning": { "fg": "brightyellow", "bg": "darkorange", "attr": ["bold"] },
|
||||||
|
"current_tag": { "fg": "gray9", "bg": "gray2", "attr": [] },
|
||||||
|
|
||||||
|
"tab_nc:modified_indicator": { "fg": "brightyellow", "bg": "gray2", "attr": ["bold"] }
|
||||||
|
},
|
||||||
|
"mode_translations": {
|
||||||
|
"nc": {
|
||||||
|
"colors": {
|
||||||
|
"brightyellow": "darkorange",
|
||||||
|
"brightestred": "darkred",
|
||||||
|
"gray0": "gray0",
|
||||||
|
"gray1": "gray0",
|
||||||
|
"gray2": "gray0",
|
||||||
|
"gray3": "gray1",
|
||||||
|
"gray4": "gray1",
|
||||||
|
"gray5": "gray1",
|
||||||
|
"gray6": "gray1",
|
||||||
|
"gray7": "gray4",
|
||||||
|
"gray8": "gray4",
|
||||||
|
"gray9": "gray4",
|
||||||
|
"gray10": "gray5",
|
||||||
|
"white": "gray6",
|
||||||
|
"dark_green_gray": "gray5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"i": {
|
||||||
|
"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", "attr": ["bold"] },
|
||||||
|
"background:divider": { "fg": "darkcyan", "bg": "darkestblue", "attr": [] },
|
||||||
|
"branch:divider": { "fg": "darkcyan", "bg": "darkblue", "attr": [] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"v": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "darkorange", "bg": "brightestorange", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"V": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "darkorange", "bg": "brightestorange", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"^V": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "darkorange", "bg": "brightestorange", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"R": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "white", "bg": "brightred", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
96
powerline/config_files/colorschemes/vim/solarized.json
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"name": "Solarized dark for vim",
|
||||||
|
"groups": {
|
||||||
|
"information:additional": { "fg": "solarized:base2", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"information:unimportant": { "fg": "solarized:base3", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"background": { "fg": "solarized:base3", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"background:divider": { "fg": "solarized:base00", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:green", "attr": ["bold"] },
|
||||||
|
"visual_range": { "fg": "solarized:green", "bg": "solarized:base3", "attr": ["bold"] },
|
||||||
|
"modified_indicator": { "fg": "solarized:yellow", "bg": "solarized:base01", "attr": ["bold"] },
|
||||||
|
"paste_indicator": { "fg": "solarized:base3", "bg": "solarized:orange", "attr": ["bold"] },
|
||||||
|
"readonly_indicator": { "fg": "solarized:red", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"branch_dirty": { "fg": "solarized:yellow", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"branch:divider": { "fg": "solarized:base1", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"file_name": { "fg": "solarized:base3", "bg": "solarized:base01", "attr": ["bold"] },
|
||||||
|
"window_title": { "fg": "solarized:base3", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"file_name_no_file": { "fg": "solarized:base3", "bg": "solarized:base01", "attr": ["bold"] },
|
||||||
|
"file_format": { "fg": "solarized:base1", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"file_vcs_status": { "fg": "solarized:red", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"file_vcs_status_M": { "fg": "solarized:yellow", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"file_vcs_status_A": { "fg": "solarized:green", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"line_percent": { "fg": "solarized:base3", "bg": "solarized:base00", "attr": [] },
|
||||||
|
"line_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "solarized:base00", "attr": [] },
|
||||||
|
"position": { "fg": "solarized:base3", "bg": "solarized:base00", "attr": [] },
|
||||||
|
"position_gradient": { "fg": "green_yellow_orange_red", "bg": "solarized:base00", "attr": [] },
|
||||||
|
"line_current": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": ["bold"] },
|
||||||
|
"line_current_symbol": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"virtcol_current_gradient": { "fg": "GREEN_Orange_red", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"col_current": { "fg": "solarized:base0", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"environment": { "fg": "solarized:base1", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"attached_clients": { "fg": "solarized:base1", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"error": { "fg": "solarized:base3", "bg": "solarized:red", "attr": ["bold"] },
|
||||||
|
"warning": { "fg": "solarized:base3", "bg": "solarized:orange", "attr": ["bold"] },
|
||||||
|
"current_tag": { "fg": "solarized:base3", "bg": "solarized:base02", "attr": ["bold"] }
|
||||||
|
},
|
||||||
|
"mode_translations": {
|
||||||
|
"nc": {
|
||||||
|
"colors": {
|
||||||
|
"solarized:base01": "solarized:base02",
|
||||||
|
"solarized:base00": "solarized:base02",
|
||||||
|
"solarized:base0": "solarized:base01",
|
||||||
|
"solarized:base1": "solarized:base00",
|
||||||
|
"solarized:base2": "solarized:base0",
|
||||||
|
"solarized:base3": "solarized:base1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"i": {
|
||||||
|
"groups": {
|
||||||
|
"background": { "fg": "solarized:base3", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"background:divider": { "fg": "solarized:base2", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attr": ["bold"] },
|
||||||
|
"modified_indicator": { "fg": "solarized:yellow", "bg": "solarized:base2", "attr": ["bold"] },
|
||||||
|
"paste_indicator": { "fg": "solarized:base3", "bg": "solarized:orange", "attr": ["bold"] },
|
||||||
|
"readonly_indicator": { "fg": "solarized:red", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"branch": { "fg": "solarized:base01", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"branch:divider": { "fg": "solarized:base00", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_directory": { "fg": "solarized:base01", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_name": { "fg": "solarized:base02", "bg": "solarized:base2", "attr": ["bold"] },
|
||||||
|
"file_size": { "fg": "solarized:base02", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_name_no_file": { "fg": "solarized:base02", "bg": "solarized:base2", "attr": ["bold"] },
|
||||||
|
"file_name_empty": { "fg": "solarized:base02", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_format": { "fg": "solarized:base2", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"file_vcs_status": { "fg": "solarized:red", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_vcs_status_M": { "fg": "solarized:yellow", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_vcs_status_A": { "fg": "solarized:green", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"line_percent": { "fg": "solarized:base3", "bg": "solarized:base1", "attr": [] },
|
||||||
|
"line_percent_gradient": { "fg": "solarized:base3", "bg": "solarized:base1", "attr": [] },
|
||||||
|
"position": { "fg": "solarized:base3", "bg": "solarized:base1", "attr": [] },
|
||||||
|
"position_gradient": { "fg": "solarized:base3", "bg": "solarized:base1", "attr": [] },
|
||||||
|
"line_current": { "fg": "solarized:base03", "bg": "solarized:base3", "attr": ["bold"] },
|
||||||
|
"line_current_symbol": { "fg": "solarized:base03", "bg": "solarized:base3", "attr": [] },
|
||||||
|
"col_current": { "fg": "solarized:base0", "bg": "solarized:base3", "attr": [] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"v": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"V": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"^V": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"R": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:red", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
96
powerline/config_files/colorschemes/vim/solarizedlight.json
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"name": "Solarized light for vim",
|
||||||
|
"groups": {
|
||||||
|
"information:additional": { "fg": "solarized:base02", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"information:unimportant": { "fg": "solarized:base1", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"background": { "fg": "solarized:base03", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"background:divider": { "fg": "solarized:base0", "bg": "solarized:base01", "attr": [] },
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:green", "attr": ["bold"] },
|
||||||
|
"visual_range": { "fg": "solarized:green", "bg": "solarized:base3", "attr": ["bold"] },
|
||||||
|
"modified_indicator": { "fg": "solarized:yellow", "bg": "solarized:base2", "attr": ["bold"] },
|
||||||
|
"paste_indicator": { "fg": "solarized:red", "bg": "solarized:base2", "attr": ["bold"] },
|
||||||
|
"readonly_indicator": { "fg": "solarized:red", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"branch_dirty": { "fg": "solarized:yellow", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"branch:divider": { "fg": "solarized:base1", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_name": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": ["bold"] },
|
||||||
|
"window_title": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_size": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_name_no_file": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": ["bold"] },
|
||||||
|
"file_name_empty": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_vcs_status": { "fg": "solarized:red", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_vcs_status_M": { "fg": "solarized:yellow", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_vcs_status_A": { "fg": "solarized:green", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"line_percent": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"line_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"position": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"position_gradient": { "fg": "green_yellow_orange_red", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"line_current": { "fg": "solarized:base3", "bg": "solarized:base02", "attr": ["bold"] },
|
||||||
|
"line_current_symbol": { "fg": "solarized:base3", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"virtcol_current_gradient": { "fg": "yellow_orange_red", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"col_current": { "fg": "solarized:base00", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"error": { "fg": "solarized:base03", "bg": "solarized:red", "attr": ["bold"] },
|
||||||
|
"warning": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": ["bold"] },
|
||||||
|
"current_tag": { "fg": "solarized:base03", "bg": "solarized:base01", "attr": ["bold"] }
|
||||||
|
},
|
||||||
|
"mode_translations": {
|
||||||
|
"nc": {
|
||||||
|
"colors": {
|
||||||
|
"solarized:base2": "solarized:base01",
|
||||||
|
"solarized:base0": "solarized:base01",
|
||||||
|
"solarized:base00": "solarized:base2",
|
||||||
|
"solarized:base1": "solarized:base0",
|
||||||
|
"solarized:base02": "solarized:base00",
|
||||||
|
"solarized:base03": "solarized:base1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"i": {
|
||||||
|
"groups": {
|
||||||
|
"background": { "fg": "solarized:base03", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"background:divider": { "fg": "solarized:base02", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:blue", "attr": ["bold"] },
|
||||||
|
"modified_indicator": { "fg": "solarized:yellow", "bg": "solarized:base02", "attr": ["bold"] },
|
||||||
|
"paste_indicator": { "fg": "solarized:base3", "bg": "solarized:orange", "attr": ["bold"] },
|
||||||
|
"readonly_indicator": { "fg": "solarized:red", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"branch": { "fg": "solarized:base2", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"branch:divider": { "fg": "solarized:base0", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"file_directory": { "fg": "solarized:base2", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"file_name": { "fg": "solarized:base01", "bg": "solarized:base02", "attr": ["bold"] },
|
||||||
|
"file_size": { "fg": "solarized:base01", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"file_name_no_file": { "fg": "solarized:base01", "bg": "solarized:base02", "attr": ["bold"] },
|
||||||
|
"file_name_empty": { "fg": "solarized:base01", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"file_format": { "fg": "solarized:base02", "bg": "solarized:base2", "attr": [] },
|
||||||
|
"file_vcs_status": { "fg": "solarized:red", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"file_vcs_status_M": { "fg": "solarized:yellow", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"file_vcs_status_A": { "fg": "solarized:green", "bg": "solarized:base02", "attr": [] },
|
||||||
|
"line_percent": { "fg": "solarized:base03", "bg": "solarized:base1", "attr": [] },
|
||||||
|
"line_percent_gradient": { "fg": "solarized:base03", "bg": "solarized:base1", "attr": [] },
|
||||||
|
"position": { "fg": "solarized:base03", "bg": "solarized:base1", "attr": [] },
|
||||||
|
"position_gradient": { "fg": "solarized:base03", "bg": "solarized:base1", "attr": [] },
|
||||||
|
"line_current": { "fg": "solarized:base3", "bg": "solarized:base03", "attr": ["bold"] },
|
||||||
|
"line_current_symbol": { "fg": "solarized:base3", "bg": "solarized:base03", "attr": [] },
|
||||||
|
"virtcol_current_gradient": { "fg": "yellow_orange_red", "bg": "solarized:base03", "attr": [] },
|
||||||
|
"col_current": { "fg": "solarized:base00", "bg": "solarized:base03", "attr": [] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"v": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"V": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"^V": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:orange", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"R": {
|
||||||
|
"groups": {
|
||||||
|
"mode": { "fg": "solarized:base3", "bg": "solarized:red", "attr": ["bold"] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
48
powerline/config_files/config.json
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{
|
||||||
|
"common": {
|
||||||
|
"term_truecolor": false
|
||||||
|
},
|
||||||
|
"ext": {
|
||||||
|
"ipython": {
|
||||||
|
"colorscheme": "default",
|
||||||
|
"theme": "in",
|
||||||
|
"local_themes": {
|
||||||
|
"rewrite": "rewrite",
|
||||||
|
"out": "out",
|
||||||
|
"in2": "in2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"shell": {
|
||||||
|
"colorscheme": "default",
|
||||||
|
"theme": "default",
|
||||||
|
"local_themes": {
|
||||||
|
"continuation": "continuation",
|
||||||
|
"select": "select"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tmux": {
|
||||||
|
"colorscheme": "default",
|
||||||
|
"theme": "default"
|
||||||
|
},
|
||||||
|
"vim": {
|
||||||
|
"colorscheme": "default",
|
||||||
|
"theme": "default",
|
||||||
|
"local_themes": {
|
||||||
|
"__tabline__": "tabline",
|
||||||
|
|
||||||
|
"cmdwin": "cmdwin",
|
||||||
|
"help": "help",
|
||||||
|
"quickfix": "quickfix",
|
||||||
|
|
||||||
|
"powerline.matchers.vim.plugin.nerdtree.nerdtree": "plugin_nerdtree",
|
||||||
|
"powerline.matchers.vim.plugin.ctrlp.ctrlp": "plugin_ctrlp",
|
||||||
|
"powerline.matchers.vim.plugin.gundo.gundo": "plugin_gundo",
|
||||||
|
"powerline.matchers.vim.plugin.gundo.gundo_preview": "plugin_gundo-preview"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"wm": {
|
||||||
|
"colorscheme": "default",
|
||||||
|
"theme": "default"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
134
powerline/config_files/themes/ascii.json
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
{
|
||||||
|
"use_non_breaking_spaces": false,
|
||||||
|
"dividers": {
|
||||||
|
"left": {
|
||||||
|
"hard": " ",
|
||||||
|
"soft": "| "
|
||||||
|
},
|
||||||
|
"right": {
|
||||||
|
"hard": " ",
|
||||||
|
"soft": " |"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"spaces": 1,
|
||||||
|
"segment_data": {
|
||||||
|
"branch": {
|
||||||
|
"before": "BR "
|
||||||
|
},
|
||||||
|
"cwd": {
|
||||||
|
"args": {
|
||||||
|
"ellipsis": "..."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"line_current_symbol": {
|
||||||
|
"contents": "LN "
|
||||||
|
},
|
||||||
|
|
||||||
|
"time": {
|
||||||
|
"before": ""
|
||||||
|
},
|
||||||
|
|
||||||
|
"powerline.segments.common.network_load": {
|
||||||
|
"args": {
|
||||||
|
"recv_format": "DL {value:>8}",
|
||||||
|
"sent_format": "UL {value:>8}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"powerline.segments.common.now_playing": {
|
||||||
|
"args": {
|
||||||
|
"state_symbols": {
|
||||||
|
"fallback": "",
|
||||||
|
"play": ">",
|
||||||
|
"pause": "~",
|
||||||
|
"stop": "X"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"powerline.segments.common.battery": {
|
||||||
|
"args": {
|
||||||
|
"full_heart": "O",
|
||||||
|
"empty_heart": "O"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"powerline.segments.common.uptime": {
|
||||||
|
"before": "UP "
|
||||||
|
},
|
||||||
|
"powerline.segments.common.email_imap_alert": {
|
||||||
|
"before": "MAIL "
|
||||||
|
},
|
||||||
|
"powerline.segments.common.virtualenv": {
|
||||||
|
"before": "(e) "
|
||||||
|
},
|
||||||
|
"powerline.segments.common.hostname": {
|
||||||
|
"before": "H "
|
||||||
|
},
|
||||||
|
"powerline.segments.common.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"
|
||||||
|
},
|
||||||
|
"temp_format": "{temp:.0f} C"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"powerline.segments.common.fuzzy_time": {
|
||||||
|
"args": {
|
||||||
|
"unicode_text": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"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",
|
||||||
|
"R": "REPLACE",
|
||||||
|
"Rv": "V-RPLCE",
|
||||||
|
"c": "COMMND",
|
||||||
|
"cv": "VIM EX",
|
||||||
|
"ce": "EX",
|
||||||
|
"r": "PROMPT",
|
||||||
|
"rm": "MORE",
|
||||||
|
"r?": "CONFIRM",
|
||||||
|
"!": "SHELL"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"powerline.segments.vim.visual_range": {
|
||||||
|
"args": {
|
||||||
|
"CTRL_V_text": "{rows} x {vcols}",
|
||||||
|
"v_text_oneline": "C:{vcols}",
|
||||||
|
"v_text_multiline": "L:{rows}",
|
||||||
|
"V_text": "L:{rows}"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"powerline.segments.vim.readonly_indicator": {
|
||||||
|
"args": {
|
||||||
|
"text": "RO"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"powerline.segments.vim.modified_indicator": {
|
||||||
|
"args": {
|
||||||
|
"text": "+"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|