powerline-shell

0.7.0 · active · verified Tue Apr 14

Powerline-shell is a Python-based utility that generates a beautiful and highly customizable prompt for various shells including Bash, ZSH, Fish, and tcsh. It enhances the command-line experience by displaying contextual information such as version control status (Git, SVN, Mercurial), the current Python virtual environment, command exit codes, and a shortened current working directory. It is configured via a JSON file to define segments and themes. The current version is 0.7.0 and it is actively maintained.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install powerline-shell, set up required fonts for proper rendering, and integrate it into a Bash shell environment. It also includes steps for initial configuration file setup for customization.

# 1. Install powerline-shell (if not already done)
pip install powerline-shell

# 2. Install Powerline-compatible fonts (if not already done)
# This is crucial for correct symbol rendering. Restart your terminal after installing.
git clone --depth=1 https://github.com/powerline/fonts.git
cd fonts
./install.sh
cd ..
rm -rf fonts

# 3. Configure your shell (example for Bash - add to ~/.bashrc)
# Find your powerline-shell.py path, e.g., using 'pip show powerline-shell' and looking at 'Location'
# Example path: $HOME/.local/bin/powerline-shell

# Ensure .local/bin is in PATH for pip-installed executables
export PATH="$PATH:$HOME/.local/bin"

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

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

# 4. Apply changes (or open a new terminal)
source ~/.bashrc

# 5. (Optional) Customize by copying the default config to your home directory
# and editing ~/.config/powerline-shell/config.json
mkdir -p ~/.config/powerline-shell
cp $(pip show powerline-shell | grep Location | cut -d ' ' -f 2)/powerline_shell/config.json.dist ~/.config/powerline-shell/config.json

view raw JSON →