Skip to content

Instantly share code, notes, and snippets.

@so0k
Last active September 18, 2020 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save so0k/2b2ad209c6eb396359efefc33cb8e752 to your computer and use it in GitHub Desktop.
Save so0k/2b2ad209c6eb396359efefc33cb8e752 to your computer and use it in GitHub Desktop.

Powerline

http://powerline.readthedocs.io

 mkdir powerlineFonts
 cd powerlineFonts/
 git init
 git remote add origin https://github.com/powerline/fonts.git
 git remote -v
   origin  https://github.com/powerline/fonts.git (fetch)
   origin  https://github.com/powerline/fonts.git (push)
 git config core.sparsecheckout true
 touch .git/info/sparse-checkout
 vim .git/info/sparse-checkout
 cat .git/info/sparse-checkout
   SourceCodePro
 git pull origin master
   remote: Counting objects: 602, done.
   remote: Total 602 (delta 0), reused 0 (delta 0), pack-reused 602
   Receiving objects: 100% (602/602), 12.21 MiB | 1.33 MiB/s, done.
   Resolving deltas: 100% (203/203), done.
   From https://github.com/powerline/fonts
    * branch            master     -> FETCH_HEAD
    * [new branch]      master     -> origin/master
 ls -l
   total 0
  drwxr-xr-x  13 vincentdesmet  staff  442 19 May 18:14 SourceCodePro

Copy all Downloaded fonts to OSX Font Library (effectively installing them)

find powerlineFonts/ -type f -name '*.otf' -print0 | xargs -0 -I % cp "%" /Users/vincentdesmet/Library/Fonts/

Update iTerm configuration to use the powerline font (Sauce Code Powerline is the one downloaded & installed if following instructions earlier)

Install powerline:

pip install --user powerline-status

pip installed powerline binaries to python 2.7 folder, add to path in bash_profile, use function to ensure it is not added multiple times:

 pathadd() {
     if [ -d "$1" ] && ! echo $PATH | grep -E -q "(^|:)$1($|:)" ; then
         if [ "$2" = "after" ] ; then
             PATH="$PATH:${1%/}"
         else
             PATH="${1%/}:$PATH"
         fi
     fi
 }

 pathrm() {
     PATH="$(echo $PATH | sed -e "s;\(^\|:\)${1%/}\(:\|\$\);\1\2;g" -e 's;^:\|:$;;g' -e 's;::;:;g')"
 }

 pathadd ~/Library/Python/2.7/bin/

Ensure the power line daemon runs, add to .bash_profile as well (after pathadd)

powerline-daemon -q

Use pip list installed packages (pip list) and show info about powerline-status package:

pip show powerline-status 

you will find all binding scripts in that directory, adding bash & vim bindings: Bash

POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1

export POWERLINE_HOME=$HOME/Library/Python/2.7/lib/python/site-packages/powerline
if [ -f $POWERLINE_HOME/bindings/bash/powerline.sh ]; then
    . $POWERLINE_HOME/bindings/bash/powerline.sh
fi

Add Git status segment: https://github.com/jaspernbrouwer/powerline-gitstatus

pip install powerline-gitstatus
mkdir -p .config/powerline/colorschemes/
cp $POWERLINE_HOME/config_files/colorschemes/{default.json,solarized.json} ~/.config/powerline/colorschemes/

You will need to add the gitstatus colour definitions in both default an solarized colorschemes, you can run powerline-lint to verify config and refresh with: powerline-daemon -q --replace

Finally, define all your powerline segments as you wish, Bash does not support left segment on a single line, but if you create an above segment you can have left segments (see ~/.config/....)

Guideline:

  • ★: most recent tag (if enabled)
  • ↓: n commits behind
  • ↑: n commits ahead
  • ●: n staged files
  • ✖: n unmerged files (conflicts)
  • ✚: n changed files
  • …: n untracked files
  • ⚑: n stashed files

good reference of rc files also: https://github.com/yongjhih/rc

Add Kubernetes segment:

powerline-kubernetes

TMUX

brew install tmux

now you need to add the powerline config:

vim ~/.tmux.conf

source /Users/vincentdesmet/Library/Python/2.7/lib/python/site-packages/powerline/bindings/tmux/powerline.conf
set -g default-terminal "screen-256-color"

VIM

only started working after installing newer vim version through brew (sets up vim with python support):

brew install vim --with-python --with-ruby --with-perl

restart terminal, and add this to .vimrc:

set term=xterm-256color

" this should enable powerline in vimrc
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
@so0k
Copy link
Author

so0k commented Oct 29, 2016

Created a new segment for Kubernetes: https://github.com/so0k/powerline-kubernetes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment