Skip to main content

persists all shell history in `$HOME/.logs`

If you like the idea click ⭐ on the repo and tweet.

xontrib log-all-history

To install use pip:

xpip install xontrib-log-all-history
# or: xpip install -U git+https://github.com/drmikecrowe/xontrib-log-all-history

Usage

xontrib load log_all_history
# TODO: what's next?

⚠️ If you using SqliteHistory backend, you must include $XONSH_HISTORY_BACKEND = 'sqlite' before loading. For example:

$XONSH_HISTORY_BACKEND = 'sqlite'
xontrib load 'log-all-history'

Architecture

This plugin intercepts history before sending to the JsonHistory or SqliteHistory backend. In short:

  • Take the current command line and append to a history named: $HOME/.logs/$PWD/xonsh-history-{DateTime}.log
  • For example:
 ~/P/P/x/xontrib-log-all-history  cat README.md > /dev/null
 ~/P/P/x/xontrib-log-all-history  tail $LOG_ALL_HISTORY_FILE
2022-03-11.21.17.01 cat README.md > /dev/null
 ~/P/P/x/xontrib-log-all-history 

I've been using this method since October in 2019 (both in bash and now xonsh). Here's stats on my logs directory:

 ~/P/P/x/xontrib-log-all-history  du -sh ~/.logs
16M     /home/mcrowe/.logs
 ~/P/P/x/xontrib-log-all-history  egrep '^201' ~/.logs -Rh | cut -b -7 | sort | uniq | head -n 1
2019-10
 ~/P/P/x/xontrib-log-all-history  find ~/.logs | wc -l
3645
 ~/P/P/x/xontrib-log-all-history 

Searching History

Two helper aliases are enabled to assist in searching your accumulated history:


hgrep -- "H"istory "Grep"

This command is simply grep -ERh {SEARCH_STRING} $HOME/.logs -- it searches all folders.


hgrep -- "H"istory in this "D"irectory "Grep"

This command is simply grep -ERh {SEARCH_STRING} $HOME/.logs/$PWD -- it searches all logs you've done in this specific directory. The use-case for this is:

  • You use the python command frequently
  • You remember using a python command in the past for the current project with a lot of parameters you figured out, but you didn't save it.
    • If you did hgrep python, you'd find many entries.
    • By using hdgrep python, you find the specific command.

Example:

 ~/P/P/x/xontrib-log-all-history  hgrep cat | wc -l
1427
 ~/P/P/x/xontrib-log-all-history  hdgrep cat | wc -l
10
 ~/P/P/x/xontrib-log-all-history 

(yes, I did several cats testing for the readme...)

Optional Configuration

If you want to place to the logs in a different folder, set:

$LOG_ALL_HISTORY_DIR = f"{$HOME}/.all-logs"
xontrib load 'log-all-history'

Credits

This package was created with xontrib cookiecutter template.

Metadata

Release files for xontrib-log-all-history 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xontrib-log-all-history 1.1.0
File Size Uploaded
xontrib-log-all-history-1.1.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xontrib-log-all-history 1.1.0
File Interpreter ABI Platform
xontrib_log_all_history-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.4 kB

Release files / xontrib-log-all-history-1.1.0.tar.gz

Download URL xontrib-log-all-history-1.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9e2078effce66c674c8227b2d5218c71648ba76e998dfe5ce5dad02c8a0bb801
BLAKE2b-256 checksum
How to use checksums
ebfa6124ef836b41814548d8b2b51de8c7ce14bd1c9699905ae9e75b239a8aa1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / xontrib_log_all_history-1.1.0-py3-none-any.whl

Download URL xontrib_log_all_history-1.1.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddac54383bfce4ec69f0d4238dbebddc3fa1755f375653e106c0dcf384a9f54f
BLAKE2b-256 checksum
How to use checksums
29bc005d2a3524930bad882f7a8d902b52061de59a2190995477526f924874c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page