Need help with powerline-shell?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

5.7K Stars 733 Forks MIT License 572 Commits 122 Opened issues


A beautiful and useful prompt for your shell

Services available


Need anything else?

Contributors list

A Powerline style prompt for your shell

A beautiful and useful prompt generator for Bash, ZSH, Fish, and tcsh:


  • Shows some important details about the git/svn/hg/fossil branch (see below)
  • 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 easy to customize and extend. See below for details.

The generated prompts are designed to resemble powerline, but otherwise this project has no relation to powerline.

Table of Contents generated with DocToc

Version Control

All of the version control systems supported by powerline shell give you a quick look into the state of your repo:

  • The current branch is displayed and changes background color when the branch is dirty.
  • When the local branch differs from the remote, the difference in number of commits is shown along with
    indicating whether a git push or pull is pending.

If files are modified or in conflict, the situation is summarized with the following symbols:

  • -- a file has been modified (but not staged for commit, in git)
  • -- a file is staged for commit (git) or added for tracking
  • -- a file has conflicts
  • ?
    -- a file is untracked

Each of these will have a number next to it if more than one file matches.

The segment can start with a symbol representing the version control system in use. To show that symbol, the configuration file must have a variable

with an option
set to
(see Segment Configuration).


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

  • Patch the font you use for your terminal: see powerline-fonts

    • If you struggle too much to get working fonts in your terminal, you can use "compatible" mode.
    • If you're using old patched fonts, you have to use the older symbols. Basically reverse this commit in your copy.
  • Install using pip:

pip install powerline-shell

(You can use the

option to install for just your user, if you'd like. But you may need to fiddle with your
to get this working properly.

  • Or, install from the git repository:
git clone
cd powerline-shell
python install
  • Setup your shell prompt using the instructions for your shell below.


Add the following to your

function _update_ps1() {
    PS1=$(powerline-shell $?)

if [[ $TERM != linux && ! $PROMPT_COMMAND =~ _update_ps1 ]]; then PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND" fi

Note: On macOS, you must add this to one of

, or
. macOS will execute the files in the aforementioned order and will stop execution at the first file it finds. For more information on the order of precedence, see the section INVOCATION in
man bash


Add the following to your

function powerline_precmd() {
    PS1="$(powerline-shell --shell zsh $?)"

function install_powerline_precmd() { for s in "${precmd_functions[@]}"; do if [ "$s" = "powerline_precmd" ]; then return fi done precmd_functions+=(powerline_precmd) }

if [ "$TERM" != "linux" ]; then install_powerline_precmd fi



in ~/.config/fish/
function fish_prompt
    powerline-shell --shell bare $status


Add the following to your

alias precmd 'set prompt="`powerline-shell --shell tcsh $?`"'


Config File

Powerline-shell is customizable through the use of a config file. This file is expected to be located at

. You can generate the default config at this location using:
mkdir -p ~/.config/powerline-shell && \
powerline-shell --generate-config > ~/.config/powerline-shell/config.json

(As an example, my config file is located here: here)

Adding, Removing and Re-arranging segments

Once you have generated your config file, you can now start adding or removing "segments" - the building blocks of your shell. The list of segments available can be seen here.

You can also create custom segments. Start by copying an existing segment like this. Make sure to change any relative imports to absolute imports. Ie. change things like:

from ..utils import BasicSegment


from powerline_shell.utils import BasicSegment

Then change the

function to do what you want. You can then use this segment in your configuration by putting the path to your segment in the segments section, like:
"segments": [

Generic Segments

There are two special segments available.

accepts an arbitrary command and the output of the command will be put into your prompt.
takes an environment variable and the value of the variable will be set in your prompt. For example, your config could look like this:
  "segments": [
      "type": "stdout",
      "command": ["echo", "hi"],
      "fg_color": 22,
      "bg_color": 161
      "type": "env",
      "var": "DOCKER_MACHINE_NAME",

Segment Separator

By default, a unicode character (resembling the > symbol) is used to separate each segment. This can be changed by changing the "mode" option in the config file. The available modes are:

  • patched
    - The default.
  • compatible
    - Attempts to use characters that may already be available using your chosen font.
  • flat
    - No separator is used between segments, giving each segment a rectangular appearance (and also saves space).



directory stores themes for your prompt, which are basically color values used by segments. The
defines a default theme which can be used standalone, and every other theme falls back to it if they miss colors for any segments.

If you want to create a custom theme, start by copying one of the existing themes, like the basic. and update your

, setting the
to the path of the file. For example your configuration might have:
  "theme": "~/mythemes/"

You can then modify the color codes to your liking. Theme colors are specified using Xterm-256 color codes.

A script for testing color combinations is provided at
. Note that the colors you see may vary depending on your terminal. When designing a theme, please test your theme on multiple terminals, especially with default settings.

Segment Configuration

Some segments support additional configuration. The options for the segment are nested under the name of the segment itself. For example, all of the options for the

segment are set in
    "segments": [...],
    "cwd": {
        options go here
    "theme": "theme-name",
    "vcs": {
        options go here

The options for the

segment are:
  • mode
    : If
    , then simple text will be used to show the cwd. If
    , only the current directory will be shown. Otherwise expands the cwd into individual directories.
  • max_depth
    : Maximum number of directories to show in path.
  • max_dir_size
    : Maximum number of characters displayed for each directory in the path.
  • full_cwd
    : If true, the last directory will not be shortened when
    is used.


segment provides one option:
  • colorize
    : If true, the hostname will be colorized based on a hash of itself.


segment provides one option:
  • show_symbol
    : If
    , the version control system segment will start with a symbol representing the specific version control system in use in the current directory.

The options for the

segment are:
  • always_show_percentage
    : If true, show percentage when fully charged on AC.
  • low_threshold
    : Threshold percentage for low-battery indicator color.

The options for the

segment are:
  • format
    : Format string as used by strftime function, e.g.

Contributing new types of segments


directory contains python scripts which are injected as is into a single file
. Each segment script defines a function that inserts one or more segments into the prompt. If you want to add a new segment, simply create a new file in the segments directory.

Make sure that your script does not introduce new globals which might conflict with other scripts. Your script should fail silently and run quickly in any scenario.

Make sure you introduce new default colors in

for every new segment you create. Test your segment with this theme first.

You should add tests for your segment as best you are able. Unit and integration tests are both welcome. Run your tests by running the
script. It uses
to manage dependencies and the environment. Alternatively, you can run the
command after installing the requirements in


See the FAQ. If you continue to have issues, please open an issue.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.