{"id":14982903,"url":"https://github.com/alexanderthaller/hstdb","last_synced_at":"2025-10-29T18:31:40.657Z","repository":{"id":38330296,"uuid":"303369333","full_name":"AlexanderThaller/hstdb","owner":"AlexanderThaller","description":"Better history management for zsh. Based on ideas from https://github.com/larkery/zsh-histdb.","archived":false,"fork":false,"pushed_at":"2023-04-03T22:54:39.000Z","size":188,"stargazers_count":47,"open_issues_count":19,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-09T11:07:01.298Z","etag":null,"topics":["cli","history","rust","sync","zsh"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexanderThaller.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-12T11:25:14.000Z","updated_at":"2024-11-20T11:28:39.000Z","dependencies_parsed_at":"2024-09-28T08:20:48.842Z","dependency_job_id":null,"html_url":"https://github.com/AlexanderThaller/hstdb","commit_stats":{"total_commits":148,"total_committers":4,"mean_commits":37.0,"dds":0.08783783783783783,"last_synced_commit":"df68cdb2056acefe0eea57a80dd645e84309bac6"},"previous_names":["alexanderthaller/histdb-rs"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderThaller%2Fhstdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderThaller%2Fhstdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderThaller%2Fhstdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderThaller%2Fhstdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexanderThaller","download_url":"https://codeload.github.com/AlexanderThaller/hstdb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238874283,"owners_count":19545151,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","history","rust","sync","zsh"],"created_at":"2024-09-24T14:06:23.073Z","updated_at":"2025-10-29T18:31:40.650Z","avatar_url":"https://github.com/AlexanderThaller.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hstdb\n\n[![Rust](https://github.com/AlexanderThaller/hstdb/actions/workflows/rust.yml/badge.svg)](https://github.com/AlexanderThaller/hstdb/actions/workflows/rust.yml)\n[![crates.io](https://img.shields.io/crates/v/hstdb.svg)](https://crates.io/crates/hstdb)\n\nBetter history management for zsh. Based on ideas from\n[https://github.com/larkery/zsh-histdb](https://github.com/larkery/zsh-histdb).\n\nLicensed under MIT.\n\nIt was mainly written because the sqlite merging broke a few to many times for\nme and using a sqlite database seemed overkill.\n\nThe tool is just writing CSV files for each host which makes syncing them via\ngit pretty painless.\n\nHas pretty much the same feature set as zsh-histdb:\n\n* Start and stop time of the command\n* Working directory in which the command was run\n* Hostname of the machine the command was run in\n* Unique session ids based on UUIDs\n* Exit status of the command\n* Import from zsh histfile and zsh-histdb sqlite database\n\n## Installation\n\nYou can either install the right binary from the releases page or run:\n\n```\ncargo install hstdb\n```\n\n## Archlinux\n\nInstall from AUR:\n* https://aur.archlinux.org/packages/hstdb/\n* https://aur.archlinux.org/packages/hstdb-git/\n\n## First Start\n\nAfter you installed hstdb you need to start the server:\n\n```\nhstdb server\n```\n\nBy default the server will run in the foreground.\n\nTo stop the server you can run the following:\n\n```\nhstdb stop\n```\n\nOr send SIGTERM/SIGINT (Ctrl+C) to stop the server.\n\nYou can also use the systemd unit file in\n[`hstdb.service`](resources/hstdb.service) which you can copy to\n`\"$XDG_CONFIG_HOME/systemd` (usually `$HOME/.config/systemd`) and\nenable/start with the following:\n\n```\nsystemctl --user daemon-reload\nsystemctl --user enable hstdb.service\nsystemctl --user start hstdb.service\n```\n\nAfter that you can add the following to your `.zshrc` to enable hstdb for\nyou shell.\n\n```\neval \"$(hstdb init)\"\n```\n\nYou can run that in your current shell to enable hstdb or restart your\nshell.\n\n## Usage\n\nHelp output of default command:\n\n```\nhstdb 2.1.0\nBetter history management for zsh. Based on ideas from\n[https://github.com/larkery/zsh-histdb](https://github.com/larkery/zsh-histdb).\n\nUSAGE:\n    hstdb [OPTIONS] [SUBCOMMAND]\n\nOPTIONS:\n        --all-hosts\n            Print all hosts\n\n    -c, --command \u003cCOMMAND\u003e\n            Only print entries beginning with the given command\n\n        --config-path \u003cCONFIG_PATH\u003e\n            Path to the socket for communication with the server [env: HISTDBRS_CONFIG_PATH=]\n            [default: $XDG_CONFIG_HOME/hstdb/config.toml]\n\n    -d, --data-dir \u003cDATA_DIR\u003e\n            Path to folder in which to store the history files [default:\n            $XDG_DATA_HOME/hstdb]\n\n        --disable-formatting\n            Disable fancy formatting\n\n    -e, --entries-count \u003cENTRIES_COUNT\u003e\n            How many entries to print [default: 25]\n\n    -f, --folder \u003cFOLDER\u003e\n            Only print entries that have been executed in the given directory\n\n        --filter-failed\n            Filter out failed commands (return code not 0)\n\n        --find-status \u003cFIND_STATUS\u003e\n            Find commands with the given return code\n\n    -h, --help\n            Print help information\n\n        --hide-header\n            Disable printing of header\n\n        --hostname \u003cHOSTNAME\u003e\n            Filter by given hostname\n\n    -i, --in\n            Only print entries that have been executed in the current directory\n\n        --no-subdirs\n            Exclude subdirectories when filtering by folder\n\n        --session \u003cSESSION\u003e\n            Filter by given session\n\n        --show-duration\n            Show how long the command ran\n\n        --show-host\n            Print host column\n\n        --show-pwd\n            Show directory in which the command was run\n\n        --show-session\n            Show session id for command\n\n        --show-status\n            Print returncode of command\n\n    -t, --text \u003cCOMMAND_TEXT\u003e\n            Only print entries containing the given regex\n\n    -T, --text_excluded \u003cCOMMAND_TEXT_EXCLUDED\u003e\n            Only print entries not containing the given regex\n\n    -V, --version\n            Print version information\n\nSUBCOMMANDS:\n    bench\n            Run benchmark against server\n    completion\n            Generate autocomplete files for shells\n    disable\n            Disable history recording for current session\n    enable\n            Enable history recording for current session\n    help\n            Print this message or the help of the given subcommand(s)\n    import\n            Import entries from existing histdb sqlite or zsh histfile\n    init\n            Print out shell functions needed by histdb and set current session id\n    precmd\n            Finish command for current session\n    server\n            Start the server\n    session_id\n            Get new session id\n    stop\n            Stop the server\n    zshaddhistory\n            Add new command for current session\n```\n\nThe most basic command ist just running `hstdb` without any arguments:\n\n```\n» hstdb\n tmn    cmd\n 14:28  cargo +nightly install --path .\n```\n\nThat will print the history for the current machine. By default only the last\n25 entries will be printed.\n\n## Git\n\nhstdb was written to easily sync the history between multiple machines. For\nthat hstdb will write separate history files for each machine.\n\nIf you want to sync between machines go to the datadir (default is\n`$XDG_DATA_HOME/hstdb`) and run the following commands:\n\n```\ngit init\ngit add :/\ngit commit -m \"Initial commit\"\n```\n\nAfter that you can configure origins and start syncing the files between\nmachines. There is no autocommit/autosync implemented as we don't want to have\ncommits for each command run. This could be changed in the future.\n\n## Configuration\n\nThere is also a way to configure `hstdb`. By default the configuration\nis stored under `$XDG_CONFIG_HOME/hstdb/config.toml` (usually\n`$HOME/.config/hstdb/config.toml`). A different path can be specified\nusing the `--config-path` option.\n\nThe default configuration looks like this:\n\n```toml\n# When true will not save commands that start with a space.\n# Default: true\nignore_space = true\n\n# The log level to run under.\n# Default: Warn\nlog_level = \"Warn\"\n```\n\nAn example with all configuration options can be found in\n[config.toml](config.toml).\n\n## Import\n\n### zsh-histdb\n\n```\n» histdb import histdb -h\nhstdb-import-histdb 0.1.0\nImport entries from existing histdb sqlite file\n\nUSAGE:\n    hstdb import histdb [OPTIONS]\n\nFLAGS:\n    -h, --help\n            Prints help information\n\n\nOPTIONS:\n    -d, --data-dir \u003cdata-dir\u003e\n            Path to folder in which to store the history files [default: $XDG_DATA_HOME/hstdb]\n\n    -i, --import-file \u003cimport-file\u003e\n            Path to the existing histdb sqlite file [default: $HOME/.histdb/zsh-history.db]\n```\n\nIf the defaults for the `data-dir` and the `import-file` are fine you can just\nrun the following command:\n\n```\nhistdb import histdb\n```\n\nThis will create CSV files for each `hostname` found in the sqlite database. It\nwill create a UUID for each unique session found in sqlite so command run in the\nsame session should still be grouped together.\n\n### zsh histfile\n\n```\n» histdb import histfile -h\nhstdb-import-histfile 0.1.0\nImport entries from existing zsh histfile\n\nUSAGE:\n    hstdb import histfile [OPTIONS]\n\nFLAGS:\n    -h, --help\n            Prints help information\n\n\nOPTIONS:\n    -d, --data-dir \u003cdata-dir\u003e\n            Path to folder in which to store the history files [default: $XDG_DATA_HOME/hstdb]\n\n    -i, --import-file \u003cimport-file\u003e\n            Path to the existing zsh histfile file [default: $HOME/.histfile]\n```\n\nIf the defaults for the `data-dir` and the `import-file` are fine you can just\nrun the following command:\n\n```\nhistdb import histfile\n```\n\nAs the information stored in the histfile is pretty limited the following\ninformation will be stored:\n\n* `time_finished` will be parsed from the histfile\n* `result` (exit code) will be parsed from the histfile\n* `command` will be parsed from the histfile\n* `time_start` will be copied over from `time_finished`\n* `hostname` will use the current machines hostname\n* `pwd` will be set to the current users home directory\n* `session_id` will be generated and used for all commands imported from the\nhistfile\n* `user` will use the current user thats running the import\n\n## Completion\nCurrentyl only zsh generation is enabled as other shells don't make\nsense at the moment.\n\nCompletion generation is provided through a subcommand:\n\n```\n» hstdb completion -h\nhstdb-completion 2.1.0\nGenerate autocomplete files for shells\n\nUSAGE:\n    hstdb completion \u003cSHELL\u003e\n\nARGS:\n    \u003cSHELL\u003e\n            For which shell to generate the autocomplete [default: zsh] [possible values: zsh]\n\nOPTIONS:\n    -h, --help\n            Print help information\n\n    -V, --version\n            Print version information\n```\n\n### Zsh\nFor zsh make sure your `$fpath` contains a folder you can write to:\n```\n# add .zsh_completion to load additional zsh stuff\nexport fpath=(~/.zsh_completion $fpath)\n```\n\nThen write the autocomplete file to that folder:\n```\nhstdb completion zsh \u003e ~/.zsh_completion/_hstdb\n```\n\nAfter that restart your shell which should now have working\nautocompletion.\n\n## Contribution\n\nI'm happy with how the tool works for me so I won't expand it further but\ncontributions for features and fixes are always welcome!\n\n## Notes\n* This tool follows the [XDG Base Directory\n  Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)\n  where possible.\n\n\n## Alternatives\n\n* https://github.com/ellie/atuin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexanderthaller%2Fhstdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexanderthaller%2Fhstdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexanderthaller%2Fhstdb/lists"}