Powerline On Mac

March 18, 2017 by Jon Whitcraft

For the longest time, I've been trying to get powerline running on my mac. The documentation is not 100% clear on what to do, so today I sat down and figure it out, and I have to say I've very pleased with the results so far.

Powerline

Here are the steps I took to get it running

# install python from brew
brew install python

# install powerline from pip
pip install --user powerline-status

#setup my .bash_profile script
echo <<- EOF
export PATH="$HOME/Library/Python/2.7/bin:$PATH"
export XDG_CONFIG_DIRS="$HOME/.config"

powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
source $HOME/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh
EOF >> ~/.bash_profile

Once that as done, I just restarted the terminal and was off and running. I added a few more plugins

# for better git status 
pip install --user  powerline-gitstatus

# to show what kubernetes context i'm currently in
pip install --user  powerline-kubernetes

My final config ended up like this

In $HOME/.config/powerline/themes/shell/config.json

{
   "segments":{
      "above":[
         {
            "left":[
               {
                  "function":"powerline.segments.shell.mode"
               },
               {
                  "function":"powerline.segments.common.net.hostname",
                  "priority":10
               },
               {
                  "function":"powerline.segments.common.env.user",
                  "priority":30
               },
               {
                  "function":"powerline.segments.shell.cwd",
                  "priority":10,
                  "args":{
                     "use_path_separator":true
                  }
               },
               {
                  "function":"powerline.segments.shell.jobnum",
                  "priority":20
               },
               {
                  "function":"powerline.segments.shell.continuation",
                  "draw_hard_divider":false
               }
            ],
            "right":[
               {
                  "function":"powerline_kubernetes.kubernetes",
                  "priority":30
               }
            ]
         }
      ],
      "left":[
         {
            "function":"powerline.segments.shell.mode"
         },
         {
            "function":"powerline_gitstatus.gitstatus",
            "priority":40
         },
         {
            "function":"powerline.segments.shell.last_status",
            "priority":10
         },
         {
            "type":"string",
            "highlight_groups":[
               "information:regular"
            ],
            "contents":"↪"
         }
      ]
   }
}

And my colorscheme is

In $HOME/.config/powerline/colorscheme/default.json

{
    "name": "Default",
    "groups": {
    "kubernetes":                { "fg": "white", "bg": "darkblue", "attrs": [] },
    "kubernetes:divider":        { "fg": "white", "bg": "darkblue", "attrs": [] },
    "information:additional":    { "fg": "gray9", "bg": "gray4", "attrs": [] },
    "information:regular":       { "fg": "gray10", "bg": "gray4", "attrs": ["bold"] },
    "information:highlighted":   { "fg": "white", "bg": "gray4", "attrs": [] },
    "information:priority":      { "fg": "brightyellow", "bg": "mediumorange", "attrs": [] },
    "warning:regular":           { "fg": "white", "bg": "brightred", "attrs": ["bold"] },
    "critical:failure":          { "fg": "white", "bg": "darkestred", "attrs": [] },
    "critical:success":          { "fg": "white", "bg": "darkestgreen", "attrs": [] },
    "background":                { "fg": "white", "bg": "gray0", "attrs": [] },
    "background:divider":        { "fg": "gray5", "bg": "gray0", "attrs": [] },
    "session":                   { "fg": "black", "bg": "gray10", "attrs": ["bold"] },
    "date":                      { "fg": "gray8", "bg": "gray2", "attrs": [] },
    "time":                      { "fg": "gray10", "bg": "gray2", "attrs": ["bold"] },
    "time:divider":              { "fg": "gray5", "bg": "gray2", "attrs": [] },
    "email_alert":               "warning:regular",
    "email_alert_gradient":      { "fg": "white", "bg": "yellow_orange_red", "attrs": ["bold"] },
    "hostname":                  { "fg": "black", "bg": "gray10", "attrs": ["bold"] },
    "weather":                   { "fg": "gray8", "bg": "gray0", "attrs": [] },
    "weather_temp_gradient":     { "fg": "blue_red", "bg": "gray0", "attrs": [] },
    "weather_condition_hot":     { "fg": "khaki1", "bg": "gray0", "attrs": [] },
    "weather_condition_snowy":   { "fg": "skyblue1", "bg": "gray0", "attrs": [] },
    "weather_condition_rainy":   { "fg": "skyblue1", "bg": "gray0", "attrs": [] },
    "uptime":                    { "fg": "gray8", "bg": "gray0", "attrs": [] },
    "external_ip":               { "fg": "gray8", "bg": "gray0", "attrs": [] },
    "internal_ip":               { "fg": "gray8", "bg": "gray0", "attrs": [] },
    "network_load":              { "fg": "gray8", "bg": "gray0", "attrs": [] },
    "network_load_gradient":     { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
    "network_load:divider":      "background:divider",
    "system_load":               { "fg": "gray8", "bg": "gray0", "attrs": [] },
    "system_load_gradient":      { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
    "environment":               { "fg": "gray8", "bg": "gray0", "attrs": [] },
    "cpu_load_percent":          { "fg": "gray8", "bg": "gray0", "attrs": [] },
    "cpu_load_percent_gradient": { "fg": "green_yellow_orange_red", "bg": "gray0", "attrs": [] },
    "battery":                   { "fg": "gray8", "bg": "gray0", "attrs": [] },
    "battery_gradient":          { "fg": "white_red", "bg": "gray0", "attrs": [] },
    "battery_full":              { "fg": "red", "bg": "gray0", "attrs": [] },
    "battery_empty":             { "fg": "white", "bg": "gray0", "attrs": [] },
    "player":                    { "fg": "gray10", "bg": "black", "attrs": [] },
    "user":                      { "fg": "white", "bg": "darkblue", "attrs": ["bold"] },
    "branch":                    { "fg": "gray9", "bg": "gray2", "attrs": [] },
    "branch_dirty":              { "fg": "brightyellow", "bg": "gray2", "attrs": [] },
    "branch_clean":              { "fg": "gray9", "bg": "gray2", "attrs": [] },
    "branch:divider":            { "fg": "gray7", "bg": "gray2", "attrs": [] },
    "cwd":                       "information:additional",
    "cwd:current_folder":        "information:regular",
    "cwd:divider":               { "fg": "gray7", "bg": "gray4", "attrs": [] },
    "virtualenv":                { "fg": "white", "bg": "darkcyan", "attrs": [] },
    "attached_clients":          { "fg": "gray8", "bg": "gray0", "attrs": [] },
    "gitstatus":                 { "fg": "gray8", "bg": "gray2", "attrs": [] },
    "gitstatus_branch":          { "fg": "gray8", "bg": "gray2", "attrs": [] },
    "gitstatus_branch_clean":    { "fg": "green", "bg": "gray2", "attrs": [] },
    "gitstatus_branch_dirty":    { "fg": "gray8", "bg": "gray2", "attrs": [] },
    "gitstatus_branch_detached": { "fg": "mediumpurple", "bg": "gray2", "attrs": [] },
    "gitstatus_behind":          { "fg": "gray10", "bg": "gray2", "attrs": [] },
    "gitstatus_ahead":           { "fg": "gray10", "bg": "gray2", "attrs": [] },
    "gitstatus_staged":          { "fg": "green", "bg": "gray2", "attrs": [] },
    "gitstatus_unmerged":        { "fg": "brightred", "bg": "gray2", "attrs": [] },
    "gitstatus_changed":         { "fg": "mediumorange", "bg": "gray2", "attrs": [] },
    "gitstatus_untracked":       { "fg": "brightestorange", "bg": "gray2", "attrs": [] },
    "gitstatus_stashed":         { "fg": "darkblue", "bg": "gray2", "attrs": [] },
    "gitstatus:divider":         { "fg": "gray8", "bg": "gray2", "attrs": [] }
    }
}

© 2017-2019 h2ik | Build With Hugo