App-PS1

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

        Adding eval to protect against errors (Ivan Wills)
        Adding generic environment reporter (Ivan Wills)
        Added perl 5.24 to travis build (Ivan Wills)

0.03   2016-09-11
        Updating for release of version 0.03
        Fixed spelling (Ivan Wills)
        Added documentation about status (Ivan Wills)
        Changed status to be shorter if nothing to report (Ivan Wills)
        Fixed missing 11 (Ivan Wills)
        Adding git status details to prompt (Ivan Wills)
        Added some description to A::P::P::Face (Ivan Wills)
        Added vtide files (Ivan Wills)

0.02   2016-01-01
        Updating for release of version 0.02
        Updating license (Ivan Wills)
        Made directory length configurable (and set to 30) (Ivan Wills)

0.01   2015-08-16
        Updating for release of version 0.01

Changes  view on Meta::CPAN

        Updated generated files (Ivan Wills)
        Stopped Perl::Critic complaining about stuff (Ivan Wills)
        Updated stopwords (Ivan Wills)
        Corrected copyright (Ivan Wills)
        Updated license text (Ivan Wills)
        Fixed copyright (Ivan Wills)
        Added ignoring generated files (Ivan Wills)
        Added ignoring generated files (Ivan Wills)
        Fixed copyright (Ivan Wills)
        Added missing dependencies (Ivan Wills)
        Started working out how to write a deamon for the prompt (Ivan Wills)
        Updated MANIFEST files (Ivan Wills)
        Automated update (Ivan Wills)
        Added place name words to be ignored by spelling (Ivan Wills)
        Fixed incorrect mobule name (Ivan Wills)
        initial commit (Ivan Wills)

README.pod  view on Meta::CPAN


=begin html

<a href="https://travis-ci.org/ivanwills/App-PS1"><img src="https://travis-ci.org/ivanwills/App-PS1.png" alt="App-PS1"></a>
<a href="https://coveralls.io/r/ivanwills/App-PS1?branch=master"><img src="https://coveralls.io/repos/ivanwills/App-PS1/badge.svg?branch=master" alt="Coverage Status" /></a>

=end html

=head1 App-PS1

Sick of the boring BASH shell command prompt, want more information displayedi
L<App-PS1> does this.

It provides a nice way of addind a line sepperator for your prompt which you
can fill with various peices of information like the directory, status of the
last command and more.

The C<app-ps1> command displays the elements put into either C<$APP_PS1>
environment variable or passed with C<--ps1> parameter. The elements are
all calculated and if one more more has no content (eg branch, perl, node
or ruby) it is removed and all the rest are show. If there is too much to
display on the line (requires L<Term::Size::Any> or C<$PS1_COLS> environment
variable to be set) the elements from the right are dropped until the line
would fit.

README.pod  view on Meta::CPAN


To install this module, run the following commands:

    perl Build.PL
    ./Build
    ./Build test
    ./Build install

=head1 CONFIGURATION AND ENVIRONMENT

Lots of environment variables are used to configure the command prompt

=over 4

=item C<$APP_PS1>

Sets the elements to be displayed (overridden by C<--ps1>)

Default 'face;branch;date;directory;uptime',

=item C<$APP_PS1_THEME>

Sets the colour theme for the prompt

=over 4

=item *

default

=item *

green

README.pod  view on Meta::CPAN

=item C<$PS1_COLS>

If L<Term::Size::Any> is not installed you can configure the width of your
screen by setting this parameter.

Default 90,

=item C<$UNICODE_UNSAFE>

If set to a true value this will allow UTF8 characters to be used displaying
the prompt

Default not set

=item C<$APP_PS1_BACKGROUND>

Set the line's background colour

Default 52

=back

bin/app-ps1  view on Meta::CPAN

        my $ps1 = App::PS1->new({
            ps1     => $option{ps1},
            low     => $option{16},
            bw      => $option{bw},
            theme   => $option{theme},
            exit    => $option{exit},
            cols    => $chars[0],
            verbose => $option{verbose},
        });

        print $ps1->cmd_prompt;
    };

    return;
}

sub quick_start {
    print <<'QS';
export PS1='\[\033[0m\]\[`ps1 -e $?`\]\n\[\033[1;32m\]\u\[\033[0m\]\[\033[0;33m\]\[\033[01;22m\]@\[\033[0m\]\[\033[1;35m\]\h \[\033[0m\]\$ '; export PATH=~/bin:$PATH; export TM_OUT=0; alias l='ls --ignore=.*.sw? -lAF -h'; alias gfind='find . | /bin/g...
alias ghistory='history | /bin/grep -r -P --color'; alias gps='ps aux | head -1; ps aux | grep -v " /bin/grep " | grep -r -P --color'; alias grep='/bin/grep -r -P --color'; alias less='less -R'; shopt -s checkwinsize; shopt -s cdspell
QS

bin/app-ps1  view on Meta::CPAN


sub pod2usage {
    require Pod::Usage;
    Pod::Usage::pod2usage(@_);
}

__DATA__

=head1 NAME

app-ps1 - Command prompt generator

=head1 VERSION

This documentation refers to app-ps1 version 0.08.

=head1 SYNOPSIS

   app-ps1 --quick-start
   app-ps1 -e $? [--256|--16|--2] [(--ps1|-p) 'semicolon-separaged-list']

 OPTIONS:
  -p --ps1[=]str    The prompt string (Default $ENV{APP_PS1} || 'face;branch;date;directory;uptime')
                    Values:
                        branch - Show the Git, SVN or CVS branch of the current directory (if any)
                        date - the date and time of when the prompt is displayed
                        directory - Info about the current directory (name, subdirs, files disk usage)
                            abreviate - Abreviate parent directories to one character if true
                            dir - If set to false turns off directory count
                            file - If set to false turns off file count
                            size - If set to false turns off directory size
                        face - Happy face if last command exited with 0 sad otherwise
                        node - Current nodejs version if using nvm or nave
                        perl - Current perl version if using perlbrew
                        processes - Info about the current processes
                        ruby - Current ruby version if using rvm

bin/app-ps1  view on Meta::CPAN

   export PS1="\[\`app-ps1 -e\$?\`\]\n\u@\h \\\$ "

=head1 DESCRIPTION

=head1 SUBROUTINES/METHODS

=head1 DIAGNOSTICS

=head1 CONFIGURATION AND ENVIRONMENT

Lots of environment variables are used to configure the command prompt

=over 4

=item C<$APP_PS1>

Sets the elements to be displayed (overridden by C<--ps1>)

Default 'face;branch;date;directory;uptime',

=item C<$APP_PS1_THEME>

Sets the colour theme for the prompt

=over 4

=item *

default

=item *

green

bin/app-ps1  view on Meta::CPAN

=item C<$PS1_COLS>

If L<Term::Size::Any> is not installed you can configure the width of your
screen by setting this parameter.

Default 90,

=item C<$UNICODE_UNSAFE>

If set to a true value this will allow UTF8 characters to be used displaying
the prompt

Default not set

=item C<$APP_PS1_BACKGROUND>

Set the line's background colour

Default 52

=back

lib/App/PS1.pm  view on Meta::CPAN


    return $self;
}

sub sum(@) { ## no critic
    my $i = 0;
    $i += $_ || 0 for (@_);
    return $i;
}

sub cmd_prompt {
    my ($self) = @_;
    my $out = '';
    $self->parts([]);

    for my $param ( split /;/, $self->ps1 ) {
        my ( $plugin, $options ) = split /(?=[{])/, $param;
        next if $plugin !~ /^[a-z]+$/;
        next if !$self->load($plugin);

        $options = $self->parse_options($options, $plugin);

lib/App/PS1.pm  view on Meta::CPAN

   export PS1="\[\`app-ps1 -e\$?\`\]\n\u@\h \\\$ "

=head1 DESCRIPTION

This is the engine for the C<app-ps1> command.

=head1 SUBROUTINES/METHODS

=head3 C<new ( $param_hash )>

Param: C<ps1>   Str  What plugins to show on the prompt
Param: C<low>   Bool Use low (16 bit colour)
Param: C<bw>    Bool Don't use any colour (black and white)
Param: C<theme> Str  Use colour theme
Param: C<exit>  Int  The last program's exit code
Param: C<cols>  Int  The number of columns wide to assume the terminal is

Return: App::PS1 - A new object

Description:

=head3 C<sum ( @list )>

Adds the values in list and returns the result.

=head3 C<cmd_prompt ()>

Display the command prompt

=head3 C<parts_size ()>

calculate the size of the prompt parts

=head3 C<load ()>

Load plugins

=head3 C<surround ()>

Surround the text with brackets

=head3 C<colour ($name)>

lib/App/PS1.pm  view on Meta::CPAN

Get the theme colour for C<$name>

=head3 C<parse_options ($options)>

Parses the JSON $options txt.

=head1 DIAGNOSTICS

=head1 CONFIGURATION AND ENVIRONMENT

Lots of environment variables are used to configure the command prompt

=over 4

=item C<$APP_PS1>

Sets the elements to be displayed (overridden by C<--ps1>)

Default 'face;branch;date;directory;uptime',

=item C<$APP_PS1_THEME>

Sets the colour theme for the prompt

=over 4

=item *

default

=item *

green

lib/App/PS1.pm  view on Meta::CPAN

=item C<$PS1_COLS>

If L<Term::Size::Any> is not installed you can configure the width of your
screen by setting this parameter.

Default 90,

=item C<$UNICODE_UNSAFE>

If set to a true value this will allow UTF8 characters to be used displaying
the prompt

Default not set

=item C<$APP_PS1_BACKGROUND>

Set the line's background colour

Default 52

=back

lib/App/PS1/Plugin/Branch.pm  view on Meta::CPAN

    }
    return 'cvs';
}

1;

__END__

=head1 NAME

App::PS1::Plugin::Branch - Adds the current branch to prompt

=head1 VERSION

This documentation refers to App::PS1::Plugin::Branch version 0.08.

=head1 SYNOPSIS

   use App::PS1::Plugin::Branch;

   # Brief but working code example(s) here showing the most common usage(s)

lib/App/PS1/Plugin/Date.pm  view on Meta::CPAN


    return $self->surround( length $date, $self->colour('date') . $date );
}

1;

__END__

=head1 NAME

App::PS1::Plugin::Date - Adds the current date to prompt

=head1 VERSION

This documentation refers to App::PS1::Plugin::Date version 0.08.

=head1 SYNOPSIS

   use App::PS1::Plugin::Date;

   # Brief but working code example(s) here showing the most common usage(s)

lib/App/PS1/Plugin/Env.pm  view on Meta::CPAN

        $out,
    );
}

1;

__END__

=head1 NAME

App::PS1::Plugin::Env - Shows the value/state of requested environment variables for displaying on the prompt

=head1 VERSION

This documentation refers to App::PS1::Plugin::Env version 0.08.

=head1 SYNOPSIS

   use App::PS1::Plugin::Env;

   # Brief but working code example(s) here showing the most common usage(s)
   # This section will be as far as many users bother reading, so make it as
   # educational and exemplary as possible.


=head1 DESCRIPTION

Allows the addition of environment variables on the prompt

=head1 SUBROUTINES/METHODS

=head3 C<env ()>

Returns requested environment variables for the prompt

=head1 DIAGNOSTICS

=head1 CONFIGURATION AND ENVIRONMENT

=head1 DEPENDENCIES

=head1 INCOMPATIBILITIES

=head1 BUGS AND LIMITATIONS

lib/App/PS1/Plugin/Face.pm  view on Meta::CPAN


    return ( 3, !$exit_code ? $self->colour('face_happy') . $happy : $exit_code ? $self->colour('face_sad') . $sad : $self->colour('red', 'red') . $sad );
}

1;

__END__

=head1 NAME

App::PS1::Plugin::Face - Adds an indicator of last programs success or failure to prompt

=head1 VERSION

This documentation refers to App::PS1::Plugin::Face version 0.08.

=head1 SYNOPSIS

   use App::PS1::Plugin::Face;

   # Brief but working code example(s) here showing the most common usage(s)

lib/App/PS1/Plugin/Processes.pm  view on Meta::CPAN

use English qw/ -no_match_vars /;

our $VERSION = 0.08;

1;

__END__

=head1 NAME

App::PS1::Plugin::Processes - Running processes to prompt

=head1 VERSION

This documentation refers to App::PS1::Plugin::Processes version 0.08.

=head1 SYNOPSIS

   use App::PS1::Plugin::Processes;

   # Brief but working code example(s) here showing the most common usage(s)

lib/App/PS1/Plugin/Uptime.pm  view on Meta::CPAN


    return $self->surround( 4 + $length, $self->colour('up_label') . "up: $up" );
}

1;

__END__

=head1 NAME

App::PS1::Plugin::Uptime - Adds system uptime to prompt

=head1 VERSION

This documentation refers to App::PS1::Plugin::Uptime version 0.08.

=head1 SYNOPSIS

   use App::PS1::Plugin::Uptime;

   # Brief but working code example(s) here showing the most common usage(s)



( run in 1.299 second using v1.01-cache-2.11-cpan-6aa56a78535 )