NAME
App::BashHistoryUtils - CLI utilities related to bash history file
VERSION
This document describes version 0.071 of App::BashHistoryUtils (from
Perl distribution App-BashHistoryUtils), released on 2025-08-20.
DESCRIPTION
This distribution includes the following CLI utilities:
* delete-bash-history-entries
* each-bash-history-entry
* grep-bash-history-entries
* grephist
FUNCTIONS
delete_bash_history_entries
Usage:
delete_bash_history_entries(%args) -> [$status_code, $reason, $payload, \%result_meta]
Delete matching entries from bash history file.
This function is not exported.
This function supports dry-run operation.
Arguments ('*' denotes required arguments):
* histfile => *str* (default: "/home/u1/.bash_history")
(No description)
* ignore_case => *bool*
(No description)
* inplace => *bool*
Replace original bash history file.
* invert_match => *bool*
(No description)
* max_age => *duration*
Match entries older than a certain age.
* min_age => *duration*
Match entries younger than a certain age.
* pattern => *re*
Match entries using a regex pattern.
* strip_timestamp => *bool*
Strip timestamps.
Special arguments:
* -dry_run => *bool*
Pass -dry_run=>1 to enable simulation mode.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
each_bash_history_entry
Usage:
each_bash_history_entry(%args) -> [$status_code, $reason, $payload, \%result_meta]
Run Perl code for each bash history entry.
This function is not exported.
Arguments ('*' denotes required arguments):
* code* => *str*
Perl code to run for each entry.
Inside the code, you can set $PRINT to 0 to suppress the output of
the entry. You can modify $_ to modify the entry. $TS (timestamp) is
also available.
* histfile => *str* (default: "/home/u1/.bash_history")
(No description)
* ignore_case => *bool*
(No description)
* invert_match => *bool*
(No description)
* max_age => *duration*
Match entries older than a certain age.
* min_age => *duration*
Match entries younger than a certain age.
* strip_timestamp => *bool*
Strip timestamps.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
grep_bash_history_entries
Usage:
grep_bash_history_entries(%args) -> [$status_code, $reason, $payload, \%result_meta]
Show matching entries from bash history file.
This function is not exported.
Arguments ('*' denotes required arguments):
* histfile => *str* (default: "/home/u1/.bash_history")
(No description)
* ignore_case => *bool*
(No description)
* invert_match => *bool*
(No description)
* max_age => *duration*
Match entries older than a certain age.
* min_age => *duration*
Match entries younger than a certain age.
* pattern => *re*
Match entries using a regex pattern.
* strip_timestamp => *bool*
Strip timestamps.
Returns an enveloped result (an array).
First element ($status_code) is an integer containing HTTP-like status
code (200 means OK, 4xx caller error, 5xx function error). Second
element ($reason) is a string containing error message, or something
like "OK" if status is 200. Third element ($payload) is the actual
result, but usually not present when enveloped result is an error
response ($status_code is not 2xx). Fourth element (%result_meta) is
called result metadata and is optional, a hash that contains extra
information, much like how HTTP response headers provide additional
metadata.
Return value: (any)
HOMEPAGE
Please visit the project's homepage at
<https://metacpan.org/release/App-BashHistoryUtils>.
SOURCE
Source repository is at
<https://github.com/perlancar/perl-App-BashHistoryUtils>.
SEE ALSO
Bash::History::Read
AUTHOR
perlancar <perlancar@cpan.org>
CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull
requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You
can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally
on your system), you can install Dist::Zilla,
Dist::Zilla::PluginBundle::Author::PERLANCAR,
Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two
other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps
required beyond that are considered a bug and can be reported to me.
COPYRIGHT AND LICENSE
This software is copyright (c) 2025 by perlancar <perlancar@cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
BUGS
Please report any bugs or feature requests on the bugtracker website
<https://rt.cpan.org/Public/Dist/Display.html?Name=App-BashHistoryUtils>
When submitting a bug or request, please include a test-file or a patch
to an existing test-file that illustrates the bug or desired feature.