{"id":16343342,"url":"https://github.com/n8henrie/fixbashhistory","last_synced_at":"2026-05-04T07:31:16.085Z","repository":{"id":57572980,"uuid":"98128353","full_name":"n8henrie/fixbashhistory","owner":"n8henrie","description":"Remove duplicates in bash history file","archived":false,"fork":false,"pushed_at":"2017-07-23T22:13:25.000Z","size":5,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-21T10:27:09.715Z","etag":null,"topics":["bash","go","golang"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/n8henrie.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}},"created_at":"2017-07-23T22:08:41.000Z","updated_at":"2024-11-26T13:44:00.000Z","dependencies_parsed_at":"2022-09-19T03:01:20.371Z","dependency_job_id":null,"html_url":"https://github.com/n8henrie/fixbashhistory","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/n8henrie/fixbashhistory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n8henrie%2Ffixbashhistory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n8henrie%2Ffixbashhistory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n8henrie%2Ffixbashhistory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n8henrie%2Ffixbashhistory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/n8henrie","download_url":"https://codeload.github.com/n8henrie/fixbashhistory/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/n8henrie%2Ffixbashhistory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32598901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bash","go","golang"],"created_at":"2024-10-11T00:24:14.635Z","updated_at":"2026-05-04T07:31:16.060Z","avatar_url":"https://github.com/n8henrie.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- [![Build Status](https://travis-ci.org/n8henrie/fixbashhistory.svg?branch=master)](https://travis-ci.org/n8henrie/fixbashhistory) --\u003e\n# fixbashhistory\n\nRemove duplicates in bash history file\n\n- Free software: MIT\n\u003c!-- - Documentation: https://fixbashhistory.readthedocs.org --\u003e\n\n## Features\n\n- Deduplicates the `.bash_history` file.\n- Preserves the timestamp for the *most recent* invocation of a command.\n- Preserves the order of (unique) commands with duplicate timestamps.\n\n## Introduction\n\nEven with `HISTCONTROL=ignoreboth:erasedups` set, duplicate commands that are\n**not** sequential are preserved. `tail -f ~/.bash_history` in one window, and\nwatch it while you run in another:\n\n```shell_session\n$ echo foo \u0026\u0026 history -a\nfoo\n$ echo foo \u0026\u0026 history -a\nfoo\n$ echo bar \u0026\u0026 history -a\nbar\n$ echo foo \u0026\u0026 history -a\nfoo\n```\n\n`awk` is one way to get an idea of how many duplicate commands are in your\n`~/.bash_history`.\n\n```shell_session\n$ awk '!/^#[[:digit:]]+$/ \u0026\u0026 seen[$0]++ \\\n    { count++ } END { print count }' ~/.bash_history/bash_history\n83118\n```\n\nI obviously have a lot of duplicates, in part from having too many tmux\nsessions open and goofing around with `PROMPT_COMMAND` and `history -a`.\n\nMy idea in writing this little script was twofold:\n\n1. Learn a little more Go. Which is why you probably shouldn't use this -- I\n   don't know what I'm doing.\n1. Deduplicate my large `.bash_history` file.\n\nBefore you use this tool, I highly recommend that you back up your\n`~/.bash_history` file, and keep that backup around for a while in case\nsomething got messed up that isn't immediately obvious.\n\n## Dependencies\n\n- Go \u003e= 1.8\n\n## Quickstart\n\n```shell_session\n$ # Consider `history -a` first\n$ go get -u https://github.com/n8henrie/fixbashhistory\n$ fixbashhistory -history-file ~/.bash_history -outfile bash_history.new\n$ wc -l ~/.bash_history bash_history.new\n$ ls -lh ~/.bash_history bash_history.new\n```\n\nCheck out `bash_history.new`, and if you like what you see:\n\n```shell_session\n$ cp ~/.bash_history{,.bak}\n$ mv bash_history.new ~/.bash_history\n$ history -c  # Clear current session's history\n$ history -n  # Read history from history file\n```\n\n### Development Setup\n\n1. Clone the repo: `git clone https://github.com/n8henrie/fixbashhistory \u0026\u0026 cd\n   fixbashhistory`\n\n## Troubleshooting / FAQ\n\n- What are some cool history settings for bash \u003e= 4?\n    - `man bash` and search for `shopt`\n    - Google: `histappend cmdhist lithist histreedit histverify`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn8henrie%2Ffixbashhistory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fn8henrie%2Ffixbashhistory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fn8henrie%2Ffixbashhistory/lists"}