Powerline for Zsh (This is a fork from https://github.com/milkbikis/powerline-bash)
This is a fork from https://github.com/milkbikis/powerline-bash
A Powerline like prompt for Zsh:
This script uses ANSI color codes to display colors in a terminal. These are notoriously non-portable, so may not work for you out of the box, but try setting your $TERM to xterm-256color, because that works for me. i.e. edit your
.zshrcfile to add:
export TERM='xterm-256color'
If you still face problems seeing colors then read this: https://gist.github.com/3749830#filepowerlinezsh_instructions.md
Patch the font you use for your terminal. Download the font from: https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts Follow the instructions: https://github.com/Lokaltog/vim-powerline/tree/develop/fontpatcher#font-patching-guide
Clone this repository somewhere:
git clone https://github.com/carlcarl/powerline-zsh
Create a symlink to the python script in your home:
ln -s ~/powerline-zsh.py
If you don't want the symlink, just modify the path in the
.zshrccommand below
.zshrc:
function _update_ps1() { export PROMPT="$(~/powerline-zsh.py $?)" } precmd() { _update_ps1 }
-h, --help show this help message and exit --cwd-only Hide parent directory --hostname Show hostname at the begin -m Choose icon font: default, compatible, patched or konsole. Default is "default"
Most of the distros use
Python2as default, however, Some distros like
Archlinuxuse
Python3. The earlier version of
powerline-zshis not compatible with
Python3. With such condition, you have two ways to solve this issue.
powerline-zsh. Just download from the
masterbranch.
.zshrccontent, use
python2to execute it.
function _update_ps1() { export PROMPT="$(python2 ~/powerline-zsh.py $?)" } precmd() { _update_ps1 }
You can use
pypyto speed up your script execution, in your
.zshrc:
function _update_ps1() { error=$? if [[ -s "/usr/local/bin/pypy" ]]; then export PROMPT="$(pypy ~/powerline-zsh.py $error)" else export PROMPT="$(~/powerline-zsh.py $error)" fi } precmd() { _update_ps1 }
You may not see the icons when using konsole. To solve this problem, you can use
-moption:
function _update_ps1() { export PROMPT="$(~/powerline-zsh.py -m konsole $?)" } precmd() { _update_ps1 }
The
powerline-zshpackage is written by Chien-Wei Huang, Shrey Banga and contributors. It’s MIT licensed and freely available.
Feel free to improve this package and send a pull request to GitHub.