Code Monkey home page Code Monkey logo

powerline-zsh's Introduction

Powerline style prompt for Zsh

This is a fork from https://github.com/milkbikis/powerline-bash

A Powerline like prompt for Zsh:

Powerline-Zsh Screenshot Powerline-Zsh Screenshot2

  • Shows some important details about the git branch:
    • Displays the current git branch which changes background color when the branch is dirty
    • A '+' appears when untracked files are present
    • When the local branch differs from the remote, the difference in number of commits is shown along with '⇡' or '⇣' indicating whether a git push or pull is pending
  • Changes color if the last command exited with a failure code
  • If you're too deep into a directory tree, shortens the displayed path with an ellipsis
  • Shows the current Python virtualenv environment
  • It's all done in a Python script, so you could go nuts with it

Setup

  • 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 .zshrc file to add:

    export TERM='xterm-256color'

If you still face problems seeing colors then read this: https://gist.github.com/3749830#file_powerline_zsh_instructions.md

If you don't want the symlink, just modify the path in the .zshrc command below

  • Now add the following to your .zshrc:
function _update_ps1()
{
    export PROMPT="$(~/powerline-zsh.py $?)"
}
precmd()
{
    _update_ps1
}
  • powerline-zsh.py usage:
-h, --help  show this help message and exit
--cwd-only  Hide parent directory
--hostname  Show hostname at the begin
-m <mode>   Choose icon font: default, compatible, patched or konsole.
            Default is "default"

Python version note

Most of the distros use Python2 as default, however, Some distros like Archlinux use Python3. The earlier version of powerline-zsh is not compatible with Python3. With such condition, you have two ways to solve this issue.

  1. Use the newest version of powerline-zsh. Just download from the master branch.
  2. Modify the .zshrc content, use python2 to execute it.
function _update_ps1()
{
    export PROMPT="$(python2 ~/powerline-zsh.py $?)"
}
precmd()
{
    _update_ps1
}

Pypy note

You can use pypy to 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
}

konsole user note

You may not see the icons when using konsole. To solve this problem, you can use -m option:

function _update_ps1()
{
    export PROMPT="$(~/powerline-zsh.py -m konsole $?)"
}
precmd()
{
    _update_ps1
}

Authors and License

The powerline-zsh package 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.

powerline-zsh's People

Contributors

a9entropy avatar borkweb avatar carl-h-20230331 avatar carlcarl avatar jwlogemann avatar toroidal-code avatar wshearn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

powerline-zsh's Issues

Encoding issue

Hey !

I've bumped on a bug in a french debian in the folder /home/user/Téléchargement.

you bet that the "é" isn't python2 friendly and I got an encoding error (and no powerline).

Here's my hack :
116 cwd = os.getenv('PWD')
->117 cwd = cwd.decode('utf-8', 'ignore')

encoding returns ascii since default system encoding for python is ascii and shouldn't be changed

Also just in case I did this :
->303 cwd = cwd.decode('utf-8', 'ignore')
304 return cwd

have a nice day,

Tumulte

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.