mirror of
https://github.com/b-ryan/powerline-shell.git
synced 2026-09-10 07:26:28 -04:00
Compare commits
No commits in common. "master" and "v0.5.2" have entirely different histories.
21
CHANGELOG.md
21
CHANGELOG.md
|
|
@ -1,26 +1,5 @@
|
|||
# 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
|
||||
|
|
|
|||
32
Dockerfile
32
Dockerfile
|
|
@ -1,6 +1,6 @@
|
|||
FROM python:2-alpine
|
||||
FROM aa8y/core:python2
|
||||
|
||||
MAINTAINER github.com/b-ryan/powerline-shell
|
||||
MAINTAINER github.com/banga/powerline-shell
|
||||
|
||||
USER root
|
||||
RUN apk add --no-cache --update \
|
||||
|
|
@ -9,23 +9,25 @@ RUN apk add --no-cache --update \
|
|||
git \
|
||||
mercurial \
|
||||
php5 \
|
||||
subversion \
|
||||
&& \
|
||||
subversion && \
|
||||
rm -rf /var/cache/apk/*
|
||||
|
||||
RUN mkdir /code
|
||||
WORKDIR /code
|
||||
# Cache the dev requirements. Directory is set in the base image.
|
||||
WORKDIR $APP_DIR
|
||||
COPY requirements-dev.txt .
|
||||
RUN pip install -r requirements-dev.txt && \
|
||||
rm requirements-dev.txt
|
||||
rm -rf requirements-dev.txt
|
||||
|
||||
RUN bzr whoami "root <root@example.com>" && \
|
||||
git config --global user.email "root@example.com" && \
|
||||
git config --global user.name "root"
|
||||
# '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"
|
||||
|
||||
# COPY . ./
|
||||
# RUN ./setup.py install
|
||||
COPY . ./
|
||||
USER root
|
||||
RUN ./setup.py install && \
|
||||
chown -R $USER:$USER .
|
||||
|
||||
ENV USER root
|
||||
|
||||
CMD ["nosetests"]
|
||||
USER $USER
|
||||
ENTRYPOINT ["/bin/bash"]
|
||||
|
|
|
|||
111
README.md
111
README.md
|
|
@ -23,11 +23,9 @@ 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)
|
||||
|
|
@ -100,7 +98,7 @@ python setup.py install
|
|||
|
||||
### Bash
|
||||
|
||||
Add the following to your `.bashrc` file:
|
||||
Add the following to your `.bashrc` (or `.profile` on Mac):
|
||||
|
||||
```
|
||||
function _update_ps1() {
|
||||
|
|
@ -112,11 +110,6 @@ 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`:
|
||||
|
|
@ -135,7 +128,7 @@ function install_powerline_precmd() {
|
|||
precmd_functions+=(powerline_precmd)
|
||||
}
|
||||
|
||||
if [ "$TERM" != "linux" -a -x "$(command -v powerline-shell)" ]; then
|
||||
if [ "$TERM" != "linux" ]; then
|
||||
install_powerline_precmd
|
||||
fi
|
||||
```
|
||||
|
|
@ -167,70 +160,50 @@ expected to be located at `~/.config/powerline-shell/config.json`. You can
|
|||
generate the default config at this location using:
|
||||
|
||||
```
|
||||
mkdir -p ~/.config/powerline-shell && \
|
||||
powerline-shell --generate-config > ~/.config/powerline-shell/config.json
|
||||
powerline-shell --generate-config > ~/.powerline-shell.json
|
||||
```
|
||||
|
||||
(As an example, my config file is located here:
|
||||
[here](https://github.com/b-ryan/dotfiles/blob/master/home/config/powerline-shell/config.json))
|
||||
[here](https://github.com/b-ryan/dotfiles/blob/master/home/powerline-shell.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
|
||||
can be seen
|
||||
[here](https://github.com/b-ryan/powerline-shell/tree/master/powerline_shell/segments).
|
||||
are:
|
||||
|
||||
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"
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
- `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.
|
||||
|
||||
### Segment Separator
|
||||
|
||||
|
|
@ -254,8 +227,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 `~/.config/powerline-shell/config.json`, setting the `"theme"`
|
||||
to the path of the file. For example your configuration might have:
|
||||
and update your `~/.powerline-shell.json`, setting the `"theme"` to the path of
|
||||
the file. For example your configuration might have:
|
||||
|
||||
```
|
||||
"theme": "~/mythemes/my-great-theme.py"
|
||||
|
|
@ -273,7 +246,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 `~/.config/powerline-shell/config.json` like:
|
||||
for the `cwd` segment are set in `~/.powerline-shell.json` like:
|
||||
|
||||
```
|
||||
{
|
||||
|
|
@ -315,10 +288,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
self.reset = self.color_template % '[0m\]\[\e[0K'
|
||||
self.lock = Powerline.symbols[mode]['lock']
|
||||
self.network = Powerline.symbols[mode]['network']
|
||||
self.separator = Powerline.symbols[mode]['separator']
|
||||
|
|
@ -167,26 +167,21 @@ DEFAULT_CONFIG = {
|
|||
}
|
||||
|
||||
|
||||
class ModuleNotFoundException(Exception):
|
||||
class ThemeNotFoundException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class CustomImporter(object):
|
||||
def __init__(self):
|
||||
self.file_import_count = 0
|
||||
|
||||
def import_(self, module_prefix, module_or_file, description):
|
||||
def read_theme(config):
|
||||
theme_name = config.get("theme", "default")
|
||||
try:
|
||||
mod = importlib.import_module("powerline_shell.themes." + theme_name)
|
||||
except ImportError:
|
||||
try:
|
||||
mod = importlib.import_module(module_prefix + module_or_file)
|
||||
mod = import_file("custom_theme", os.path.expanduser(theme_name))
|
||||
except ImportError:
|
||||
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
|
||||
raise ThemeNotFoundException(
|
||||
"Theme " + theme_name + " cannot be found")
|
||||
return getattr(mod, "Color")
|
||||
|
||||
|
||||
def main():
|
||||
|
|
@ -216,24 +211,13 @@ def main():
|
|||
else:
|
||||
config = DEFAULT_CONFIG
|
||||
|
||||
custom_importer = CustomImporter()
|
||||
theme_mod = custom_importer.import_(
|
||||
"powerline_shell.themes.",
|
||||
config.get("theme", "default"),
|
||||
"Theme")
|
||||
theme = getattr(theme_mod, "Color")
|
||||
theme = read_theme(config)
|
||||
|
||||
powerline = Powerline(args, config, theme)
|
||||
segments = []
|
||||
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)
|
||||
for seg_name in config["segments"]:
|
||||
mod = importlib.import_module("powerline_shell.segments." + seg_name)
|
||||
segment = getattr(mod, "Segment")(powerline)
|
||||
segment.start()
|
||||
segments.append(segment)
|
||||
for segment in segments:
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
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))
|
||||
|
|
@ -6,30 +6,26 @@ from ..utils import ThreadedSegment
|
|||
|
||||
|
||||
class Segment(ThreadedSegment):
|
||||
|
||||
def run(self):
|
||||
self.num_jobs = 0
|
||||
system = platform.system()
|
||||
if system.startswith("CYGWIN") or system.startswith("MINGW"):
|
||||
if platform.system().startswith('CYGWIN'):
|
||||
# cygwin ps is a special snowflake...
|
||||
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:]]
|
||||
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:])
|
||||
self.num_jobs = output.count(os.getppid()) - 1
|
||||
else:
|
||||
# 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)
|
||||
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)
|
||||
output = output_proc.communicate()[0].decode("utf-8")
|
||||
self.num_jobs = len(re.findall(str(os.getppid()), output)) - 1
|
||||
self.num_jobs = len(re.findall(str(pppid), 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)
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
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))
|
||||
|
|
@ -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, None
|
||||
return None
|
||||
pdata = p.communicate()
|
||||
if p.returncode != 0 or pdata[1][:22] == b'svn: warning: W155007:':
|
||||
return None, None
|
||||
|
|
@ -50,6 +50,11 @@ 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()
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,7 @@ import time
|
|||
class Segment(BasicSegment):
|
||||
def add_to_powerline(self):
|
||||
powerline = self.powerline
|
||||
format = powerline.segment_conf('time', 'format')
|
||||
if format:
|
||||
time_ = ' %s ' % time.strftime(format)
|
||||
elif powerline.args.shell == 'bash':
|
||||
if powerline.args.shell == 'bash':
|
||||
time_ = ' \\t '
|
||||
elif powerline.args.shell == 'zsh':
|
||||
time_ = ' %* '
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@ class DefaultColor(object):
|
|||
TIME_FG = 250
|
||||
TIME_BG = 238
|
||||
|
||||
|
||||
class Color(DefaultColor):
|
||||
"""
|
||||
This subclass is required when the user chooses to use 'default' theme.
|
||||
|
|
|
|||
|
|
@ -1,111 +0,0 @@
|
|||
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
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
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
|
||||
|
|
@ -94,19 +94,17 @@ def warn(msg):
|
|||
|
||||
|
||||
class BasicSegment(object):
|
||||
def __init__(self, powerline, segment_def):
|
||||
def __init__(self, powerline):
|
||||
self.powerline = powerline
|
||||
self.segment_def = segment_def # type: dict
|
||||
|
||||
def start(self):
|
||||
pass
|
||||
|
||||
|
||||
class ThreadedSegment(threading.Thread):
|
||||
def __init__(self, powerline, segment_def):
|
||||
def __init__(self, powerline):
|
||||
super(ThreadedSegment, self).__init__()
|
||||
self.powerline = powerline
|
||||
self.segment_def = segment_def # type: dict
|
||||
|
||||
|
||||
def import_file(module_name, path):
|
||||
|
|
|
|||
13
setup.py
13
setup.py
|
|
@ -3,20 +3,13 @@ from setuptools import setup, find_packages
|
|||
|
||||
setup(
|
||||
name="powerline-shell",
|
||||
version="0.7.0",
|
||||
version="0.5.2",
|
||||
description="A pretty prompt for your shell",
|
||||
author="Buck Ryan",
|
||||
author_email="buck@buckryan.com",
|
||||
license="MIT",
|
||||
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",
|
||||
],
|
||||
url="https://github.com/banga/powerline-shell",
|
||||
classifiers=[],
|
||||
packages=[
|
||||
"powerline_shell",
|
||||
"powerline_shell.segments",
|
||||
|
|
|
|||
6
test.sh
6
test.sh
|
|
@ -1,6 +1,4 @@
|
|||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
docker build -t powerline-shell .
|
||||
docker run --rm --interactive --tty \
|
||||
--volume $PWD:/code \
|
||||
powerline-shell "$@"
|
||||
docker run --rm -it powerline-shell -c nosetests
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
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)
|
||||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue