Compare commits

..

46 commits

Author SHA1 Message Date
Buck Ryan 4b19aa47f1
Merge pull request #521 from pmbauer/master
add nord theme
2022-09-22 14:12:11 -04:00
Buck Ryan f091bdc61c Switch CYGWIN job counting code from map to list comprehension
Closes #516
2022-09-22 14:08:37 -04:00
Buck Ryan 0c9ccee860
Merge pull request #536 from conr2d/readme-zsh
Update README.md (zsh example)
2022-09-22 14:03:24 -04:00
Buck Ryan 0055f7c2b7 MINGW condition in job count
Closes #330
2022-09-22 14:01:08 -04:00
Buck Ryan 5763a35cc0 add note about testing on zsh 2022-09-22 13:55:46 -04:00
Buck Ryan db35d233d1 Fix jobs segment for bash 5, fish 3 2022-09-22 13:52:42 -04:00
Buck Ryan 70edbd062d Merge commit '33d1ae1ae9a147ecfbd4f33d3b346e4f4767a027' into fix-jobs 2022-09-22 13:29:02 -04:00
Jeeyong Um 7adadf1e04 Update README.md 2022-07-28 20:17:28 +09:00
Buck Ryan 4b681d8318
Merge pull request #531 from blcsntb/patch-1
Update README.md
2022-03-16 14:10:09 -04:00
Binh Nguyen 3433b92e86
Update README.md 2022-03-09 14:50:46 +07:00
Paul Bauer 56f78ca049 add nord theme 2021-05-17 12:44:49 -04:00
Thomas Cherry 33d1ae1ae9 removing need to explicity call out fish from the command line 2019-07-03 23:23:08 -04:00
Thomas Cherry fd0b3a8ec4 removing need to explicity call out fish from the command line 2019-07-03 23:21:33 -04:00
Thomas Cherry 256888344a fixing names as suggested 2019-07-03 23:03:52 -04:00
Buck Ryan a9b8c9bb39 update metadata homepage 2018-09-15 20:24:03 -04:00
Buck Ryan 7332357af6 prepare 0.7.0 2018-09-15 19:17:33 -04:00
Buck Ryan 09fd45d6fc doc formatting 2018-09-15 19:13:48 -04:00
Buck Ryan feb9c8550e fix bug in svn segment 2018-07-01 21:13:15 -04:00
Buck Ryan 067202f71a prepare 0.7.0-rc1 2018-06-21 21:29:37 -04:00
Buck Ryan e8a86cf8ff Merge branch 'master' into develop 2018-06-21 21:28:39 -04:00
Buck Ryan 9d15bf7040
Merge pull request #365 from b-ryan/stdout-segment
Generic stdout and environment variable segments
2018-06-21 21:28:15 -04:00
Buck Ryan d095a2f3d5 fix tests and new test dockerfile 2018-06-21 21:26:40 -04:00
Buck Ryan 54f7b90052 Merge branch 'develop' into stdout-segment 2018-06-21 18:17:52 -04:00
Buck Ryan 0ea47cc115 date the 0.6.0 release 2018-06-20 10:29:30 -04:00
Buck Ryan 3d46c135dc
Merge pull request #416 from b-ryan/develop
Develop
2018-06-20 10:28:59 -04:00
Buck Ryan 7935d7ad11 readme updates for custom segments 2018-06-20 10:26:22 -04:00
Buck Ryan 3cf55e7b60 get ready for 0.6.0 2018-06-20 10:18:58 -04:00
Buck Ryan af919e1772 Custom segment support
Closes #407

The changes in 407 were on the right track, but didn't take it all the
way. Some issues it had:

- Did not call `expanduser` to handle paths like `~/segment.py`
- Did not appear to work on both Python 2 and Python 3
- Did not show a meaningful message when a segment cannot be found

This commit repurposes the code written to import custom themes for
segments.
2018-06-20 10:18:06 -04:00
Buck Ryan 3b95178400 fix issues with config file path
fixes #409
2018-06-04 14:45:30 -04:00
Buck Ryan ee5776f10c
Merge pull request #386 from jamessimas/master
Fix filename for macOS
2018-05-07 10:54:50 -04:00
Buck Ryan 36486483eb changelog for #383 2018-05-07 10:53:02 -04:00
Buck Ryan c2932e7e8f
Merge pull request #383 from dundalek/feature/time-format
Add format option for time segment
2018-05-07 10:51:49 -04:00
Buck Ryan b53337c215 Merge branch 'develop' into stdout-segment 2018-04-25 09:55:50 -04:00
Buck Ryan 73b01d6597 Revert "implement fix for #249"
This reverts commit 86fd04c7a8.

Closes #389
2018-04-22 12:13:10 -04:00
James Simas c64da3dde4 Update macOS section 2018-04-21 19:33:56 -07:00
Buck Ryan 08c07fa1f1 prepare 0.5.3 2018-04-21 17:50:42 -04:00
Buck Ryan bbb7354068
Merge pull request #388 from monicaycli/master
add gruvbox theme
2018-04-21 17:14:21 -04:00
Monica Li 4e74b9a12a add gruvbox theme 2018-04-21 13:55:56 -04:00
James Simas 8b9c0f2b80 Fix filename for macOS 2018-04-19 22:22:48 -07:00
Jakub Dundalek 7f72c1b031 Add format option for time segment 2018-03-29 16:28:37 +02:00
Buck Ryan 47ca2df524 nevermind on extra theme variables 2018-02-18 22:04:43 -05:00
Buck Ryan 84a6b215c1 docs for stdout and env 2018-02-18 22:02:44 -05:00
Buck Ryan f0caebd26f segment that gets an environment variable 2018-02-18 21:52:51 -05:00
Buck Ryan 9703379d58 create an stdout segment that just plops in outputs of commands 2018-02-18 21:42:02 -05:00
Thomas Cherry eb0f462717 adding a way to force fish mode for testing and to be more explicit 2017-11-05 12:05:39 -05:00
Thomas Cherry 006be7777f got this to work with fish 2017-11-05 12:05:39 -05:00
23 changed files with 443 additions and 104 deletions

View file

@ -1,5 +1,26 @@
# Changes
2018-09-15 (version 0.7.0)
* New generic `stdout` and `env` segments
2018-06-20 (version 0.6.0)
* Support for custom themes
* New option for the `time` segment to specify format of the displayed time
([@dundalek](https://github.com/b-ryan/powerline-shell/pull/383))
2018-04-22 (version 0.5.4)
* Reverted fix for
([#249](https://github.com/b-ryan/powerline-shell/issues/249)) because it
caused issues on Mac.
2018-04-21 (version 0.5.3)
* New theme! (gruvbox)
([@monicaycli](https://github.com/b-ryan/powerline-shell/pull/388))
2018-04-21 (version 0.5.2)
* Fix hostname colorize bug

View file

@ -1,6 +1,6 @@
FROM aa8y/core:python2
FROM python:2-alpine
MAINTAINER github.com/banga/powerline-shell
MAINTAINER github.com/b-ryan/powerline-shell
USER root
RUN apk add --no-cache --update \
@ -9,25 +9,23 @@ RUN apk add --no-cache --update \
git \
mercurial \
php5 \
subversion && \
subversion \
&& \
rm -rf /var/cache/apk/*
# Cache the dev requirements. Directory is set in the base image.
WORKDIR $APP_DIR
RUN mkdir /code
WORKDIR /code
COPY requirements-dev.txt .
RUN pip install -r requirements-dev.txt && \
rm -rf requirements-dev.txt
rm requirements-dev.txt
# 'USER' is set in the base image. It points to a non-root user called 'docker'.
USER $USER
RUN bzr whoami "$USERNAME <$USER@example.com>" && \
git config --global user.email "$USER@example.com" && \
git config --global user.name "$USERNAME"
RUN bzr whoami "root <root@example.com>" && \
git config --global user.email "root@example.com" && \
git config --global user.name "root"
COPY . ./
USER root
RUN ./setup.py install && \
chown -R $USER:$USER .
# COPY . ./
# RUN ./setup.py install
USER $USER
ENTRYPOINT ["/bin/bash"]
ENV USER root
CMD ["nosetests"]

111
README.md
View file

@ -23,9 +23,11 @@ has no relation to powerline.
- [Bash](#bash)
- [ZSH](#zsh)
- [Fish](#fish)
- [tcsh](#tcsh)
- [Customization](#customization)
- [Config File](#config-file)
- [Adding, Removing and Re-arranging segments](#adding-removing-and-re-arranging-segments)
- [Generic Segments](#generic-segments)
- [Segment Separator](#segment-separator)
- [Themes](#themes)
- [Segment Configuration](#segment-configuration)
@ -98,7 +100,7 @@ python setup.py install
### Bash
Add the following to your `.bashrc` (or `.profile` on Mac):
Add the following to your `.bashrc` file:
```
function _update_ps1() {
@ -110,6 +112,11 @@ if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then
fi
```
**Note:** On macOS, you must add this to one of `.bash_profile`, `.bash_login`,
or `.profile`. macOS will execute the files in the aforementioned order and
will stop execution at the first file it finds. For more information on the
order of precedence, see the section **INVOCATION** in `man bash`.
### ZSH
Add the following to your `.zshrc`:
@ -128,7 +135,7 @@ function install_powerline_precmd() {
precmd_functions+=(powerline_precmd)
}
if [ "$TERM" != "linux" ]; then
if [ "$TERM" != "linux" -a -x "$(command -v powerline-shell)" ]; then
install_powerline_precmd
fi
```
@ -160,50 +167,70 @@ expected to be located at `~/.config/powerline-shell/config.json`. You can
generate the default config at this location using:
```
powerline-shell --generate-config > ~/.powerline-shell.json
mkdir -p ~/.config/powerline-shell && \
powerline-shell --generate-config > ~/.config/powerline-shell/config.json
```
(As an example, my config file is located here:
[here](https://github.com/b-ryan/dotfiles/blob/master/home/powerline-shell.json))
[here](https://github.com/b-ryan/dotfiles/blob/master/home/config/powerline-shell/config.json))
### Adding, Removing and Re-arranging segments
Once you have generated your config file, you can now start adding or removing
"segments" - the building blocks of your shell. The list of segments available
are:
can be seen
[here](https://github.com/b-ryan/powerline-shell/tree/master/powerline_shell/segments).
- `aws_profile` - Show which AWS profile is in use. See the
[AWS](http://docs.aws.amazon.com/cli/latest/userguide/cli-multiple-profiles.html)
documentation.
- `battery` - See percentage of battery charged and an icon when the battery is
charging.
- `bzr` - Details about the current Bazaar repo.
- `cwd` - Shows your current working directory. See [Segment
Configuration](#segment-configuration) for some options.
- `exit_code` - When the previous command ends in a non-zero status, shows the
value of the exit status in red.
- `fossil` - Details about the current Fossil repo.
- `git` - Details about the current Git repo.
- `git_stash` - Number of stashes in the current Git repo.
- `hg` - Details about the current Mercurial repo.
- `hostname` - Current machine's hostname.
- `jobs` - Number of background jobs currently running.
- `newline` - Inserts a newline into the prompt.
- `node_version` - `node --version`
- `npm_version` - `npm --version`
- `php_version` - Version of php on the machine.
- `rbenv` - `rbenv local`
- `read_only` - Shows a lock icon if the current directory is read-only.
- `root` - Shows a `#` if logged in as root, `$` otherwise.
- `ruby_version` - `ruby --version`
- `set_term_title` - If able, sets the title of your terminal to include some
useful info.
- `ssh` - If logged into over SSH, shows a network icon.
- `svn` - Details about the current SVN repo.
- `time` - Shows the current time.
- `uptime` - Uptime of the current machine.
- `username` - Name of the logged-in user.
- `virtual_env` - Shows the name of the current virtual env or conda env.
You can also create custom segments. Start by copying an existing segment like
[this](https://github.com/b-ryan/powerline-shell/blob/master/powerline_shell/segments/aws_profile.py).
Make sure to change any relative imports to absolute imports. Ie. change things
like:
```python
from ..utils import BasicSegment
```
to
```python
from powerline_shell.utils import BasicSegment
```
Then change the `add_to_powerline` function to do what you want. You can then
use this segment in your configuration by putting the path to your segment in
the segments section, like:
```json
"segments": [
"~/path/to/segment.py"
]
```
### Generic Segments
There are two special segments available. `stdout` accepts an arbitrary command
and the output of the command will be put into your prompt. `env` takes an
environment variable and the value of the variable will be set in your prompt.
For example, your config could look like this:
```
{
"segments": [
"cwd",
"git",
{
"type": "stdout",
"command": ["echo", "hi"],
"fg_color": 22,
"bg_color": 161
},
{
"type": "env",
"var": "DOCKER_MACHINE_NAME"
},
]
}
```
### Segment Separator
@ -227,8 +254,8 @@ they miss colors for any segments.
If you want to create a custom theme, start by copying one of the existing
themes, like the
[basic](https://github.com/b-ryan/powerline-shell/blob/master/powerline_shell/themes/basic.py).
and update your `~/.powerline-shell.json`, setting the `"theme"` to the path of
the file. For example your configuration might have:
and update your `~/.config/powerline-shell/config.json`, setting the `"theme"`
to the path of the file. For example your configuration might have:
```
"theme": "~/mythemes/my-great-theme.py"
@ -246,7 +273,7 @@ settings.
Some segments support additional configuration. The options for the segment are
nested under the name of the segment itself. For example, all of the options
for the `cwd` segment are set in `~/.powerline-shell.json` like:
for the `cwd` segment are set in `~/.config/powerline-shell/config.json` like:
```
{
@ -288,6 +315,10 @@ The options for the `battery` segment are:
- `always_show_percentage`: If true, show percentage when fully charged on AC.
- `low_threshold`: Threshold percentage for low-battery indicator color.
The options for the `time` segment are:
- `format`: Format string as used by strftime function, e.g. `%H:%M`.
### Contributing new types of segments
The `powerline_shell/segments` directory contains python scripts which are

View file

@ -90,7 +90,7 @@ class Powerline(object):
self.cwd = get_valid_cwd()
mode = config.get("mode", "patched")
self.color_template = self.color_templates[args.shell]
self.reset = self.color_template % '[0m\]\[\e[0K'
self.reset = self.color_template % '[0m'
self.lock = Powerline.symbols[mode]['lock']
self.network = Powerline.symbols[mode]['network']
self.separator = Powerline.symbols[mode]['separator']
@ -167,21 +167,26 @@ DEFAULT_CONFIG = {
}
class ThemeNotFoundException(Exception):
class ModuleNotFoundException(Exception):
pass
def read_theme(config):
theme_name = config.get("theme", "default")
try:
mod = importlib.import_module("powerline_shell.themes." + theme_name)
except ImportError:
class CustomImporter(object):
def __init__(self):
self.file_import_count = 0
def import_(self, module_prefix, module_or_file, description):
try:
mod = import_file("custom_theme", os.path.expanduser(theme_name))
mod = importlib.import_module(module_prefix + module_or_file)
except ImportError:
raise ThemeNotFoundException(
"Theme " + theme_name + " cannot be found")
return getattr(mod, "Color")
try:
module_name = "_custom_mod_{0}".format(self.file_import_count)
mod = import_file(module_name, os.path.expanduser(module_or_file))
self.file_import_count += 1
except (ImportError, IOError):
msg = "{0} {1} cannot be found".format(description, module_or_file)
raise ModuleNotFoundException( msg)
return mod
def main():
@ -211,13 +216,24 @@ def main():
else:
config = DEFAULT_CONFIG
theme = read_theme(config)
custom_importer = CustomImporter()
theme_mod = custom_importer.import_(
"powerline_shell.themes.",
config.get("theme", "default"),
"Theme")
theme = getattr(theme_mod, "Color")
powerline = Powerline(args, config, theme)
segments = []
for seg_name in config["segments"]:
mod = importlib.import_module("powerline_shell.segments." + seg_name)
segment = getattr(mod, "Segment")(powerline)
for seg_conf in config["segments"]:
if not isinstance(seg_conf, dict):
seg_conf = {"type": seg_conf}
seg_name = seg_conf["type"]
seg_mod = custom_importer.import_(
"powerline_shell.segments.",
seg_name,
"Segment")
segment = getattr(seg_mod, "Segment")(powerline, seg_conf)
segment.start()
segments.append(segment)
for segment in segments:

View file

@ -0,0 +1,10 @@
import os
from ..utils import BasicSegment
class Segment(BasicSegment):
def add_to_powerline(self):
self.powerline.append(
" %s " % os.getenv(self.segment_def["var"]),
self.segment_def.get("fg_color", self.powerline.theme.PATH_FG),
self.segment_def.get("bg_color", self.powerline.theme.PATH_BG))

View file

@ -6,26 +6,30 @@ from ..utils import ThreadedSegment
class Segment(ThreadedSegment):
def run(self):
self.num_jobs = 0
if platform.system().startswith('CYGWIN'):
system = platform.system()
if system.startswith("CYGWIN") or system.startswith("MINGW"):
# cygwin ps is a special snowflake...
output_proc = subprocess.Popen(['ps', '-af'], stdout=subprocess.PIPE)
output = map(lambda l: int(l.split()[2].strip()),
output_proc.communicate()[0].decode("utf-8").splitlines()[1:])
output_proc = subprocess.Popen(["ps", "-af"], stdout=subprocess.PIPE)
output = [int(l.split()[2].strip()) for l in output_proc.communicate()[0].decode("utf-8").splitlines()[1:]]
self.num_jobs = output.count(os.getppid()) - 1
else:
pppid_proc = subprocess.Popen(['ps', '-p', str(os.getppid()), '-oppid='],
stdout=subprocess.PIPE)
pppid = pppid_proc.communicate()[0].decode("utf-8").strip()
output_proc = subprocess.Popen(['ps', '-a', '-o', 'ppid'],
stdout=subprocess.PIPE)
# The following logic was tested on:
# - fish, version 3.3.1
# - GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
# - zsh 5.8.1 (x86_64-ubuntu-linux-gnu)
# If you change the behavior to account for another shell's
# behavior, please provide details of the shell version you tested
# on in this comment.
output_proc = subprocess.Popen(["ps", "-a", "-o", "ppid"], stdout=subprocess.PIPE)
output = output_proc.communicate()[0].decode("utf-8")
self.num_jobs = len(re.findall(str(pppid), output)) - 1
self.num_jobs = len(re.findall(str(os.getppid()), output)) - 1
def add_to_powerline(self):
self.join()
if self.num_jobs > 0:
self.powerline.append(' %d ' % self.num_jobs,
self.powerline.append(" %d " % self.num_jobs,
self.powerline.theme.JOBS_FG,
self.powerline.theme.JOBS_BG)

View file

@ -0,0 +1,17 @@
import subprocess
from ..utils import ThreadedSegment
class Segment(ThreadedSegment):
def run(self):
cmd = self.segment_def["command"]
self.output = subprocess.check_output(cmd).decode("utf-8").strip()
# TODO handle OSError
# TODO handle no command defined or malformed
def add_to_powerline(self):
self.join()
self.powerline.append(
" %s " % self.output,
self.segment_def.get("fg_color", self.powerline.theme.PATH_FG),
self.segment_def.get("bg_color", self.powerline.theme.PATH_BG))

View file

@ -39,7 +39,7 @@ def build_stats():
env=get_subprocess_env())
except OSError:
# Popen will throw an OSError if svn is not found
return None
return None, None
pdata = p.communicate()
if p.returncode != 0 or pdata[1][:22] == b'svn: warning: W155007:':
return None, None
@ -50,11 +50,6 @@ def build_stats():
class Segment(ThreadedSegment):
def __init__(self, powerline):
super(Segment, self).__init__(powerline)
self.stats = None
self.revision = ""
def run(self):
self.stats, self.revision = build_stats()

View file

@ -6,7 +6,10 @@ import time
class Segment(BasicSegment):
def add_to_powerline(self):
powerline = self.powerline
if powerline.args.shell == 'bash':
format = powerline.segment_conf('time', 'format')
if format:
time_ = ' %s ' % time.strftime(format)
elif powerline.args.shell == 'bash':
time_ = ' \\t '
elif powerline.args.shell == 'zsh':
time_ = ' %* '

View file

@ -75,6 +75,7 @@ class DefaultColor(object):
TIME_FG = 250
TIME_BG = 238
class Color(DefaultColor):
"""
This subclass is required when the user chooses to use 'default' theme.

View file

@ -0,0 +1,111 @@
from powerline_shell.themes.default import DefaultColor
"""
absolute colors based on
https://github.com/morhetz/gruvbox/blob/master/colors/gruvbox.vim
"""
dark0 = 235
dark1 = 237
dark2 = 239
dark3 = 241
dark4 = 243
light0 = 229
light1 = 223
light2 = 250
light3 = 248
light4 = 246
dark_gray = 245
light_gray = 244
neutral_red = 124
neutral_green = 106
neutral_yellow = 172
neutral_blue = 66
neutral_purple = 132
neutral_aqua = 72
neutral_orange = 166
bright_red = 167
bright_green = 142
bright_yellow = 214
bright_blue = 109
bright_purple = 175
bright_aqua = 108
bright_orange = 208
faded_red = 88
faded_green = 100
faded_yellow = 136
faded_blue = 24
faded_purple = 96
faded_aqua = 66
faded_orange = 130
class Color(DefaultColor):
USERNAME_ROOT_BG = faded_red
USERNAME_BG = dark2
USERNAME_FG = bright_purple
HOSTNAME_BG = dark1
HOSTNAME_FG = bright_purple
HOME_SPECIAL_DISPLAY = True
HOME_BG = neutral_blue
HOME_FG = light2
PATH_BG = dark3
PATH_FG = light3
CWD_FG = light2
SEPARATOR_FG = dark_gray
READONLY_BG = bright_red
READONLY_FG = light0
SSH_BG = faded_purple
SSH_FG = light0
REPO_CLEAN_BG = faded_green
REPO_CLEAN_FG = dark1
REPO_DIRTY_BG = faded_orange
REPO_DIRTY_FG = light0
JOBS_FG = neutral_aqua
JOBS_BG = dark1
CMD_PASSED_FG = light4
CMD_PASSED_BG = dark1
CMD_FAILED_FG = light0
CMD_FAILED_BG = neutral_red
SVN_CHANGES_FG = REPO_DIRTY_FG
SVN_CHANGES_BG = REPO_DIRTY_BG
GIT_AHEAD_BG = dark2
GIT_AHEAD_FG = light3
GIT_BEHIND_BG = dark2
GIT_BEHIND_FG = light3
GIT_STAGED_BG = neutral_green
GIT_STAGED_FG = light0
GIT_NOTSTAGED_BG = neutral_orange
GIT_NOTSTAGED_FG = light0
GIT_UNTRACKED_BG = faded_red
GIT_UNTRACKED_FG = light0
GIT_CONFLICTED_BG = neutral_red
GIT_CONFLICTED_FG = light0
GIT_STASH_BG = neutral_yellow
GIT_STASH_FG = dark0
VIRTUAL_ENV_BG = faded_green
VIRTUAL_ENV_FG = light0
BATTERY_NORMAL_BG = neutral_green
BATTERY_NORMAL_FG = dark2
BATTERY_LOW_BG = neutral_red
BATTERY_LOW_FG = light1
AWS_PROFILE_FG = neutral_aqua
AWS_PROFILE_BG = dark1
TIME_FG = light2
TIME_BG = dark4

View file

@ -0,0 +1,89 @@
from powerline_shell.themes.default import DefaultColor
"""
colors from https://www.nordtheme.com/docs/colors-and-palettes
"""
night0 = 236 # nord0
night1 = 237 # nord1
night2 = 238 # nord2
night3 = 239 # nord3
snow0 = 253 # nord4
snow1 = 254 # nord5
snow2 = 255 # nord6
frost0 = 109 # nord7
frost1 = 111 # nord8
frost2 = 110 # nord9
frost3 = 68 # nord10
red = 167 # nord11
orange = 173 # nord12
yellow = 179 # nord13
green = 150 # nord14
purple = 139 # nord15
class Color(DefaultColor):
USERNAME_BG = night3
USERNAME_FG = snow0
HOSTNAME_FG = snow0
HOSTNAME_BG = night0
HOME_BG = frost2
HOME_FG = snow2
PATH_BG = night0
PATH_FG = snow0
CWD_FG = snow0
SEPARATOR_FG = night3
READONLY_BG = red
READONLY_FG = snow2
SSH_BG = orange
SSH_FG = snow2
REPO_CLEAN_BG = green
REPO_CLEAN_FG = night1
REPO_DIRTY_BG = red
REPO_DIRTY_FG = snow2
JOBS_FG = frost3
JOBS_BG = night0
CMD_PASSED_BG = night0
CMD_PASSED_FG = snow2
CMD_FAILED_BG = yellow
CMD_FAILED_FG = snow2
SVN_CHANGES_BG = REPO_DIRTY_FG
SVN_CHANGES_FG = REPO_DIRTY_BG
GIT_AHEAD_BG = night3
GIT_AHEAD_FG = snow0
GIT_BEHIND_BG = night3
GIT_BEHIND_FG = snow0
GIT_STAGED_BG = frost0
GIT_STAGED_FG = night1
GIT_NOTSTAGED_BG = orange
GIT_NOTSTAGED_FG = snow2
GIT_UNTRACKED_BG = purple
GIT_UNTRACKED_FG = snow2
GIT_CONFLICTED_BG = red
GIT_CONFLICTED_FG = snow2
GIT_STASH_BG = yellow
GIT_STASH_FG = night1
VIRTUAL_ENV_BG = green
VIRTUAL_ENV_FG = night1
BATTERY_NORMAL_BG = green
BATTERY_NORMAL_FG = night1
BATTERY_LOW_BG = red
BATTERY_LOW_FG = snow2
AWS_PROFILE_FG = frost3
AWS_PROFILE_BG = night0
TIME_BG = night3
TIME_FG = snow0

View file

@ -94,17 +94,19 @@ def warn(msg):
class BasicSegment(object):
def __init__(self, powerline):
def __init__(self, powerline, segment_def):
self.powerline = powerline
self.segment_def = segment_def # type: dict
def start(self):
pass
class ThreadedSegment(threading.Thread):
def __init__(self, powerline):
def __init__(self, powerline, segment_def):
super(ThreadedSegment, self).__init__()
self.powerline = powerline
self.segment_def = segment_def # type: dict
def import_file(module_name, path):

View file

@ -3,13 +3,20 @@ from setuptools import setup, find_packages
setup(
name="powerline-shell",
version="0.5.2",
version="0.7.0",
description="A pretty prompt for your shell",
author="Buck Ryan",
author_email="buck@buckryan.com",
license="MIT",
url="https://github.com/banga/powerline-shell",
classifiers=[],
url="https://github.com/b-ryan/powerline-shell",
classifiers=[
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
],
packages=[
"powerline_shell",
"powerline_shell.segments",

View file

@ -1,4 +1,6 @@
#!/bin/sh
set -eu
docker build -t powerline-shell .
docker run --rm -it powerline-shell -c nosetests
docker run --rm --interactive --tty \
--volume $PWD:/code \
powerline-shell "$@"

View file

@ -34,7 +34,7 @@ class BzrTest(unittest.TestCase):
sh.cd("trunk")
sh.bzr("init")
self.segment = bzr.Segment(self.powerline)
self.segment = bzr.Segment(self.powerline, {})
def tearDown(self):
shutil.rmtree(self.dirname)

View file

@ -28,7 +28,7 @@ class FossilTest(unittest.TestCase):
sh.fossil("init", "test.fossil")
sh.fossil("open", "test.fossil")
self.segment = fossil.Segment(self.powerline)
self.segment = fossil.Segment(self.powerline, {})
def tearDown(self):
shutil.rmtree(self.dirname)

View file

@ -15,7 +15,7 @@ class GitStashTest(unittest.TestCase):
sh.cd(self.dirname)
sh.git("init", ".")
self.segment = git_stash.Segment(self.powerline)
self.segment = git_stash.Segment(self.powerline, {})
def tearDown(self):
shutil.rmtree(self.dirname)

View file

@ -19,7 +19,7 @@ class GitTest(unittest.TestCase):
sh.cd(self.dirname)
sh.git("init", ".")
self.segment = git.Segment(self.powerline)
self.segment = git.Segment(self.powerline, {})
def tearDown(self):
shutil.rmtree(self.dirname)

View file

@ -29,7 +29,7 @@ class HgTest(unittest.TestCase):
sh.cd(self.dirname)
sh.hg("init", ".")
self.segment = hg.Segment(self.powerline)
self.segment = hg.Segment(self.powerline, {})
def tearDown(self):
shutil.rmtree(self.dirname)

View file

@ -9,7 +9,7 @@ class HostnameTest(unittest.TestCase):
def setUp(self):
self.powerline = mock.MagicMock()
self.powerline.theme = Color
self.segment = hostname.Segment(self.powerline)
self.segment = hostname.Segment(self.powerline, {})
def test_colorize(self):
self.powerline.segment_conf.return_value = True

View file

@ -0,0 +1,32 @@
import tempfile
import unittest
import shutil
import mock
import sh
import powerline_shell.segments.svn as svn
from ..testing_utils import dict_side_effect_fn
class SvnTest(unittest.TestCase):
def setUp(self):
self.powerline = mock.MagicMock()
self.powerline.segment_conf.side_effect = dict_side_effect_fn({
("vcs", "show_symbol"): False,
})
self.dirname = tempfile.mkdtemp()
sh.cd(self.dirname)
# sh.svn("init", ".")
self.segment = svn.Segment(self.powerline, {})
def tearDown(self):
shutil.rmtree(self.dirname)
@mock.patch("powerline_shell.utils.get_PATH")
def test_svn_not_installed(self, get_PATH):
get_PATH.return_value = "" # so svn can't be found
self.segment.start()
self.segment.add_to_powerline()
self.assertEqual(self.powerline.append.call_count, 0)

View file

@ -19,7 +19,7 @@ class UptimeTest(unittest.TestCase):
def setUp(self):
self.powerline = mock.MagicMock()
self.segment = uptime.Segment(self.powerline)
self.segment = uptime.Segment(self.powerline, {})
@mock.patch('subprocess.check_output')
def test_all(self, check_output):