class documentation

class Base(object):

Known subclasses: ps1api.Parrot, ps1api.ParrotGit

View In Hierarchy

Base PS1 Building object.

Class Variable USER PS1 user expansion value.
Class Variable HOST PS1 host expansion value.
Class Variable HOST_LONG PS1 host expansion value.
Class Variable WORKING_DIR PS1 working directory expansion value.
Class Variable PROMPT PS1 prompt for regular user / root user.
Class Variable TERM_BASE The basename of the shell's terminal device name.
Class Variable JOBS The number of jobs currently managed by the shell.
Class Variable HIST_NUM History count.
Class Variable CMD_NUM Number of commands this terminal has run.
Class Variable DATE_WEEK_MONTH_DAY Date week month day.
Class Variable SHELL_NAME The name of the shell, the basename of $0 (the portion following the final slash).
Class Variable TIME_24 The time, in 24-hour HH:MM:SS format.
Class Variable TIME_12HR_W_SECOND The time, in 12-hour HH:MM:SS format.
Class Variable TIME_12HR_AM_PM The time, in 12-hour am/pm format.
Class Variable BASH_VER The version of Bash (e.g., 2.00).
Class Variable BASH_VER_RELEASE The release of Bash, version + patchlevel (e.g., 2.00.0).
Class Variable WORKING_DIR_BASENAME The basename of $PWD.
Method __init__ Initialize class.
Instance Variable delim_color Delimiter color.
Instance Variable ps1_escape Escape non-printable sequences to prevent prompt breakage.
Instance Variable title_color Title color.
Instance Variable fancy_lines Turn on Fancy lines.
Instance Variable sections Sections list.
Method set_no_ps1_escape For prompt debugging, set an option to not escape the unicode and non-printable chars.
Method set_title_color Set title color.
Method set_no_color Set terminal to no color.
Instance Variable no_color Disable color from PS1 prompt.
Method set_fancy_lines No summary
Method set_delim_color Set Delimiter color.
Method set_section_delim No summary
Instance Variable delim Section delimiter.
Method set_section_color Set default section color.
Instance Variable section_color Delim and prefix/suffix color.
Method set_prompt_color Set prompt color. :: i.e. $ or # depending on user
Instance Variable prompt_color PS1 Prompt $/# color.
Method color Abstracted color class.
Method build_template Build template (if defined in subclass).
Method set_ends No summary
Instance Variable section_prefix Section prefix.
Instance Variable section_suffix Section suffix.
Method add_custom Add custom section value/color.
Method add_newline Insert newline.
Method add_user_host No summary
Method add_working_directory No summary
Method add_git_branch Add git branch to prompt.
Method add_exit_code Add Exit code indicator to prompt.
Method add_user Add PS1 user expansion value.
Method add_host Add PS1 host expansion value.
Method add_host_long Add PS1 host expansion value.
Method add_term_base Add The basename of the shell's terminal device name.
Method add_jobs Add The number of jobs currently managed by the shell.
Method add_hist_num Add History count.
Method add_cmd_num Add Number of commands this terminal has run.
Method add_date_week_month_day Add Date week month day. :: Mon Sep 13
Method add_date_time_24hr Add the date/time, in 24-hour HH:MM:SS format. :: Mon Sep 13 10:28:40
Method add_shell_name Add The name of the shell, the basename of $0 (the portion following the final slash).
Method add_time_24 Add The time, in 24-hour HH:MM:SS format. :: 10:28:40
Method add_time_12hr_with_second Add The time, in 12-hour HH:MM:SS format. :: 10:28:40
Method add_time_12hr_am_pm Add The time, in 12-hour am/pm format. :: 10:28 AM
Method add_bash_ver Add The version of Bash (e.g., 2.00).
Method add_bash_ver_release Add The release of Bash, version + patchlevel (e.g., 2.00.0).
Method add_working_dir_basename Add The basename of $PWD.
Method output Output / export PS1 value.
Method _strip_color Strip color from output.
Method _sammy Sandwhich section between separators.
USER =

PS1 user expansion value.

(type: str)
HOST =

PS1 host expansion value.

(type: str)
HOST_LONG =

PS1 host expansion value.

(type: str)
WORKING_DIR =

PS1 working directory expansion value.

(type: str)
PROMPT =

PS1 prompt for regular user / root user.

(type: str)
TERM_BASE =

The basename of the shell's terminal device name.

(type: str)
JOBS =

The number of jobs currently managed by the shell.

(type: str)
HIST_NUM =

History count.

(type: str)
CMD_NUM =

Number of commands this terminal has run.

(type: str)
DATE_WEEK_MONTH_DAY =

Date week month day.

(type: str)
SHELL_NAME =

The name of the shell, the basename of $0 (the portion following the final slash).

(type: str)
TIME_24 =

The time, in 24-hour HH:MM:SS format.

(type: str)
TIME_12HR_W_SECOND =

The time, in 12-hour HH:MM:SS format.

(type: str)
TIME_12HR_AM_PM =

The time, in 12-hour am/pm format.

(type: str)
BASH_VER =

The version of Bash (e.g., 2.00).

(type: str)
BASH_VER_RELEASE =

The release of Bash, version + patchlevel (e.g., 2.00.0).

(type: str)
WORKING_DIR_BASENAME =

The basename of $PWD.

(type: str)
def __init__(self):

Initialize class.

delim_color =

Delimiter color.

ps1_escape =

Escape non-printable sequences to prevent prompt breakage.

(type: bool)
title_color =

Title color.

fancy_lines =

Turn on Fancy lines.

(type: bool)
sections =

Sections list.

(type: list)
def _strip_color(self, value):

Strip color from output.

def set_no_ps1_escape(self):

For prompt debugging, set an option to not escape the unicode and non-printable chars.

def set_title_color(self, value):

Set title color.

ParametersvalueUndocumented (type: str)
def set_no_color(self, value=True):

Set terminal to no color.

no_color =

Disable color from PS1 prompt.

def set_fancy_lines(self):

Set fancy line breaks like the following :

    ┌───
    ├───
    └──╼
def set_delim_color(self, value):

Set Delimiter color.

def set_section_delim(self, delim='-'):

Set section separator. :

    i.e. [section1]-[section2]
                   ^ separator
delim =

Section delimiter.

def set_section_color(self, color='red_1'):

Set default section color.

section_color =

Delim and prefix/suffix color.

def set_prompt_color(self, color='light_yellow'):

Set prompt color. :

    i.e. $ or # depending on user
prompt_color =

PS1 Prompt $/# color.

def color(self, cval, txt, escape=True):

Abstracted color class.

ParameterscvalUndocumented (type: str)
txtUndocumented
escapeUndocumented
def build_template(self):

Build template (if defined in subclass).

def _sammy(self, value):

Sandwhich section between separators.

def set_ends(self, start='[', end=']'):

Set Section start / end values. :

    {}
    {section1}-{section2}

    []
    [section1]-[section2]

    ❰❱
    ❰section1❱-❰section2❱
section_prefix =

Section prefix.

section_suffix =

Section suffix.

def add_custom(self, value, color, title=None):

Add custom section value/color.

ParametersvalueUndocumented (type: str)
colorUndocumented (type: str)
titleUndocumented (type: str)
def add_newline(self):

Insert newline.

def add_user_host(self, user_color='grey_62', at_sym_color='light_yellow', host_color='light_blue'):

Add User/Host to prompt. :

    [user@hostname]-[section2]
          ^ add this
Parametersuser_colorUndocumented (type: str)
at_sym_colorUndocumented (type: str)
host_colorUndocumented (type: str)
def add_working_directory(self, color='light_green', title=''):

Add Working directory to prompt. :

    [user@hostame]─[~/path/i/am/in]
                     ^ add this
ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_git_branch(self, color='light_yellow', title=''):

Add git branch to prompt.

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_exit_code(self, ok_txt='✔', err_txt='✘', ok_color='light_green', err_color='red_1', title=''):

Add Exit code indicator to prompt.

Parametersok_txtUndocumented (type: str)
err_txtUndocumented (type: str)
ok_colorUndocumented (type: str)
err_colorUndocumented (type: str)
titleUndocumented (type: str)
def add_user(self, color='', title=''):

Add PS1 user expansion value.

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_host(self, color='', title=''):

Add PS1 host expansion value.

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_host_long(self, color='', title=''):

Add PS1 host expansion value.

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_term_base(self, color='', title=''):

Add The basename of the shell's terminal device name.

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_jobs(self, color='', title=''):

Add The number of jobs currently managed by the shell.

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_hist_num(self, color='', title=''):

Add History count.

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_cmd_num(self, color='', title=''):

Add Number of commands this terminal has run.

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_date_week_month_day(self, color='', title=''):

Add Date week month day. :

    Mon Sep 13
ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_date_time_24hr(self, color='', title=''):

Add the date/time, in 24-hour HH:MM:SS format. :

    Mon Sep 13 10:28:40
ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_shell_name(self, color='', title=''):

Add The name of the shell, the basename of $0 (the portion following the final slash).

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_time_24(self, color='', title=''):

Add The time, in 24-hour HH:MM:SS format. :

    10:28:40
ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_time_12hr_with_second(self, color='', title=''):

Add The time, in 12-hour HH:MM:SS format. :

    10:28:40
ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_time_12hr_am_pm(self, color='', title=''):

Add The time, in 12-hour am/pm format. :

    10:28 AM
ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_bash_ver(self, color='', title=''):

Add The version of Bash (e.g., 2.00).

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_bash_ver_release(self, color='', title=''):

Add The release of Bash, version + patchlevel (e.g., 2.00.0).

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def add_working_dir_basename(self, color='', title=''):

Add The basename of $PWD.

ParameterscolorUndocumented (type: str)
titleUndocumented (type: str)
def output(self):

Output / export PS1 value.

API Documentation for ps1api, generated by pydoctor 21.2.2 at 1996-06-17 15:00:00.