Skip to main content

log bash history to an sqlite database

Project description

Recent is a more structured way to log your bash history.

The standard ~/.bash_history file in inadequate in many ways, its worst fault is to by default log only 500 history entries, with no timestamp. You can alter your bash HISTFILESIZE and HISTTIMEFORMAT but it is still a unstructured format with limited querying ability.

Recent does the following:

  1. Logs current localtime, command text, current pid, command return value, working directory to an sqlite database in ~/.recent.db.

  2. Logs history immediately, rather than at the close of the session.

  3. Provides a command called recent for searching logs.

installation instructions

Install the recent pip package:

pip install recent

Add the following to your .bashrc or .bash_profile:

export PROMPT_COMMAND='log-recent -r $? -c "$(history 1)" -p $$'

And start a new shell.

usage

Look at your current history using recent:

recent

Search for a pattern as follows:

recent git

For more information see the help:

recent -h

Not currently recent doesn’t integrate with bash commands such as Ctrl-R, but this is in the pipeline.

You can directly query your history using the following:

sqlite3 ~/.recent.db "select * from commands limit 10"

dev installation instructions

git clone https://github.com/trengrj/recent && cd recent

pip install -e .

security

Please note, recent does not take into account enforcing logging for security purposes. For this functionality on linux, have a look at auditd http://people.redhat.com/sgrubb/audit/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

recent-0.0.3.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

recent-0.0.3-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file recent-0.0.3.tar.gz.

File metadata

  • Download URL: recent-0.0.3.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for recent-0.0.3.tar.gz
Algorithm Hash digest
SHA256 69448ff0a507f9f90c08cab2cb92b37e2e4a52b6e71f1f5d685cbeb27e3efc00
MD5 e612b8a9222324a16bbe666bbf8ff9b0
BLAKE2b-256 9d928169a7072475773ceb0caca57475f0b140ab4a4b68f264868a7030348144

See more details on using hashes here.

Provenance

File details

Details for the file recent-0.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for recent-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d6f8f56070b7800d5c0623261572bf96058788203ee5e22eb0698b182e1cfd2d
MD5 0743ef25932e45d56f9d3c7d501ab5b9
BLAKE2b-256 6d7ec38d81909f88acc6081dae6e3bee3cca4b59b5b86f8b243cc74016f76b6c

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page