Skip to main content

Crate pxh

Crate pxh 

Source

Modules§

helpers
recall
secrets_patterns

Structs§

Invocation

Constants§

CURRENT_SCHEMA_VERSION
Current schema version – bump when adding new migrations below.

Functions§

atomically_remove_lines_from_file
atomically_remove_matching_lines_from_file
Rewrite a file removing lines that exactly match any of the contraband items. Unlike atomically_remove_lines_from_file, this matches complete lines (after trimming).
default_db_path
Return the default database path (pxh_data_dir()/pxh.db).
effective_host_set
Build the set of hostnames that count as “this host” for recall filtering. Returns {current_hostname} ∪ {aliases}, deduped.
get_hostname
get_setting
import_bash_history
import_json_history
import_zsh_history
initialize_base_schema
Initialize base schema (persistent tables and indexes only). Safe to call on foreign databases (scan/scrub –dir) – all DDL is idempotent.
initialize_full_schema
Set up the in-memory memdb tables and register the REGEXP function. Only needed by commands that use memdb.show_results or REGEXP (show, scrub).
join_continuation_lines
Join backslash-continuation lines in zsh EXTENDED_HISTORY format. Lines ending with \ are joined with their successor using \n as separator.
json_export
migrate_host_settings
Migrate host settings from DB legacy storage to config file. Called from install and config commands, not on every connection.
present_results_human_readable
pxh_config_dir
Return the pxh config directory. Prefers XDG, falls back to ~/.pxh if it exists. New installs default to $XDG_CONFIG_HOME/pxh (~/.config/pxh).
pxh_data_dir
Return the pxh data directory. Prefers XDG, falls back to ~/.pxh if it exists. New installs default to $XDG_DATA_HOME/pxh (~/.local/share/pxh).
read_local_machine_id
Read this database’s local_machine_id setting, parsed as u64. Accepts either TEXT or BLOB storage so we tolerate values written by non-pxh tooling. Returns None if the setting is absent or unparseable – callers should fall back to non-watermarked behavior in that case.
resolve_hostname
Resolve hostname: config > DB setting (legacy “original_hostname”) > live hostname.
run_schema_migrations
Run versioned schema migrations tracked via PRAGMA user_version.
set_setting
sqlite_connection
Open a lightweight connection (persistent schema only, no memdb/regexp). Use for hot-path commands like insert and seal.
sqlite_connection_full
Open a full connection with memdb tables and REGEXP function. Use for commands that need memdb.show_results or REGEXP (show, scrub, scan).
with_write_retry
Run f against a write transaction, retrying on SQLITE_BUSY/SQLITE_LOCKED with exponential backoff and jitter. Each attempt uses BEGIN IMMEDIATE so contention is detected up front rather than mid-transaction. Gives up once max_total elapses and returns the final busy error.