powerline-shell icon indicating copy to clipboard operation
powerline-shell copied to clipboard

modified to read symbols from theme

Open kajigga opened this issue 5 years ago • 1 comments

I found that I wanted to be able to customize the separators used by powerline. In order to make this modular, I modified powerline_shell/__init__.py to detect and load this information from the theme.

The default symbols are used if the theme does not provide a SYMBOLS dictionary itself. Interestingly, this also makes it possible to use different modes as defined in the Color.SYMBOLS object

For example, a config like this

{
  "segments": [
    "virtual_env",
    "username",
    "hostname",
    "ssh",
    "cwd",
    "git",
    "hg",
    "jobs",
    "root"
  ],
  "cwd": {
    "max_depth": 2,
    "full_cwd": true
  },
  "theme": "~/.config/powerline-shell/themes/solarized-flames.py",
  "mode": "flames"
}

points to this theme

from powerline_shell.themes.default import DefaultColor


class Color(DefaultColor):
    USERNAME_FG = 15
    USERNAME_BG = 4
    USERNAME_ROOT_BG = 1

    HOSTNAME_FG = 15
    HOSTNAME_BG = 10

    HOME_SPECIAL_DISPLAY = False
    PATH_FG = 7
    PATH_BG = 10
    CWD_FG = 15
    SEPARATOR_FG = 14

    READONLY_BG = 1
    READONLY_FG = 7

    REPO_CLEAN_FG = 14
    REPO_CLEAN_BG = 0
    REPO_DIRTY_FG = 3
    REPO_DIRTY_BG = 0

    JOBS_FG = 4
    JOBS_BG = 8

    CMD_PASSED_FG = 15
    CMD_PASSED_BG = 2
    CMD_FAILED_FG = 15
    CMD_FAILED_BG = 1

    SVN_CHANGES_FG = REPO_DIRTY_FG
    SVN_CHANGES_BG = REPO_DIRTY_BG

    VIRTUAL_ENV_BG = 15
    VIRTUAL_ENV_FG = 2

    AWS_PROFILE_FG = 7
    AWS_PROFILE_BG = 2

    TIME_FG = 15
    TIME_BG = 10
    # https://github.com/ryanoasis/powerline-extra-symbols
    SYMBOLS = {
        "flames": {
            "lock": u"\uE0A2",
            "network": u"\uE0A1",
            "separator": u"\uE0C0 ",
            "separator_thin": u"\uE0b1"
        },
        'patched-blocks': {
            'lock': u'\uE0A2',
            'network': u'\uE0A2',
            'separator': u'\uE0cd',
            'separator_thin': u'\uE0cc'
        }

    }

This give me a powerline theme that uses powerline extra symbols.

flames_powerline

kajigga avatar Mar 15 '19 19:03 kajigga

That's awesome. Your image at bottom is what I came looking for.
@kajigga Can you share the final version solarized-flames.py theme with us? The one in the text seems gives some thing like the below

Screenshot from 2020-12-19 04-37-16

mrprajesh avatar Dec 18 '20 23:12 mrprajesh