Home

Awesome

PureLine - A Pure Bash Powerline PS1 Command Prompt

Pureline is currently in development and subject to frequent changes. Updates are likely to change the format of the configuration file and therefore break configuration files from previous versions. Please be aware when updating, it is highly likely you will need to change your config file!

A simple but powerful Powerline style prompt for the Bash shell written in Bash script.

Pureline was inspired by Bash-Powerline-Shell and is designed to make configuration easy, using either full 256 color or just the basic terminal colors - allowing colors to be set by the terminal (eg Xresources or profiles).

Default Install

Battery and Git Segments

Time and Python Virtual Segments

Jobs and Prompt Segments

SSH Segment

Main Features

Segments for the PS1 prompt include (with some environment varibale options);

All the segments are optional and can be enabled or disabled in a config file.

Unicode symbols used

Setup

Prerequisites

Mac OS X Prerequisites

Install

Git Clone

$ git clone https://github.com/chris-marsh/pureline.git
$ cp pureline/configs/powerline_full_256col.conf ~/.pureline.conf

The powerline fonts need more effort to work on tty screens, so a useful tip is to only source PureLine if you are on a gui;

if [ "$TERM" != "linux" ]; then
    source ~/pureline/pureline ~/.pureline.conf
fi

Note on some terminals, when scrolling at the bottom of the screen, long line wrapped prompts, can cause background color to bleed between lines. If you experience this please set PL_ERASE_TO_EOL=true.

Customization

Some example configuration files are provided. The config file contains lines which are sourced by PureLine. The segments to be used are listed in the PL_segmentS environment variablee;

    PL_SEGMENTS=(
        # Segment                Background  Foreground
        'user_segment            Yellow      Black'
        'path_segment            Blue        Black'
        'read_only_segment       Red         White'
    )

To remove a segment, comment or delete the relevant line. You can rearrange the segments in any order you prefer. The first two parameters are background and foreground colors which can be customized. Some segments may have additional options.

Default Colors

The colors default colors available are:

Using these colors, your command prompt will use the color theme of your terminal.

Custom 256 Colors

You can also define your own custom colors in the config file;

PL_COLORS[Orange]='\[\e[38;5;208m\]'           # 256 Col Orange Foreground
PL_COLORS[On_Orange]='\[\e[48;5;208m\]'        # 256 Col Orange Background
PL_COLORS[LightGrey]='\[\e[38;5;250m\]'        # 256 Col Light Grey Foreground
PL_COLORS[On_LightGrey]='\[\e[48;5;250m\]'     # 256 Col Light Grey Background
PL_COLORS[DarkGrey]='\[\e[38;5;240m\]'         # 256 Col Dark Grey Foreground
PL_COLORS[On_DarkGrey]='\[\e[48;5;240m\]'      # 256 Col Dark Grey Background

The colors must be defined in pairs of background and foreground colors.

Developing New Segments

New segments can be easily created by following a template from existing functions. For example:

function time_segment {
    local bg_color=$1                  # Set the background color
    local fg_color=$2                  # Set the foregropund color
    local content="\t"                 # Set the content to be displayed
    PS1+=$(segment_end $bg_color)
    PS1+=$(segment_content $fg_color $bg_color " $content ")
    __last_color=$bg_color
}

The $content variable can be modified to show any output wanted on the prompt.

You can place segment code anywhere it will be sourced:

Additional resources