| Crates.io | zsh-history-cleaner |
| lib.rs | zsh-history-cleaner |
| version | 0.5.0 |
| created_at | 2025-09-28 20:19:46.865137+00 |
| updated_at | 2026-01-01 15:37:10.031554+00 |
| description | Clean your commands history by removing duplicate commands, commands between dates, etc... |
| homepage | |
| repository | https://github.com/haidaraM/zsh-history-cleaner |
| max_upload_size | |
| id | 1858609 |
| size | 403,011 |
A command line tool to clean your .zsh history by:

[!WARNING]
Disclaimer: I'm primarily using this project as an opportunity to learn the Rust programming language (it's my first project in Rust). As such, do not expect the project to be a full-featured solution for cleaning your history file. A backup of your history file is created by default before any modification. Use the--no-backupflag with caution.
Contributions are welcome! Some ideas for future improvements:
HISTFILE.zsh_history file format is supported.cargo install zsh-history-cleaner
zhc --help
$ zhc --analyze # or zhc -a
~/.zsh_history):
$ zhc
$ zhc --remove-between 2023-01-01 2023-06-30 --keep-duplicates
Clean your commands history by removing duplicate commands, commands between dates, etc...
By default, all the duplicate commands are removed.
Usage: zhc [OPTIONS]
Options:
-d, --dry-run
Dry run mode. The history file is not modified when this flag is used
-H, --history-file <HISTORY_FILE>
The history file to use
[default: ~/.zsh_history]
--no-backup
[USE WITH CAUTION!!] Disable the history file backup. By default, a backup is written to '{history_file_path}.zhc_backup_{timestamp}'
-k, --keep-duplicates
Should we keep duplicate commands in the history file?
-r, --remove-between <START_DATE> <END_DATE>
Remove commands between the provided two dates (included): YYYY-MM-DD YYYY-MM-DD. The first date must be before or equal to the second date. Example: --remove-between 2023-01-01 2023-06-30
-a, --analyze
Analyze the history file and provide statistics about the commands over time. No changes are made to the history file when this flag is used
--top-n <TOP_N>
Number of top commands/executables to display in analysis. Only used with --analyze
[default: 10]
-h, --help
Print help (see a summary with '-h')
-V, --version
Print version
cargo build
cargo test
The code is set up to use cargo-release and git-cliff to automate releases and CHANGELOG generation. The workflow
automatically pushes to crates.io when a new tag is pushed with the
Trusted Publishing feature enabled and enforced.