{"id":13994755,"url":"https://github.com/digitalist/bash_database_history","last_synced_at":"2025-07-22T20:30:56.192Z","repository":{"id":68239572,"uuid":"161833791","full_name":"digitalist/bash_database_history","owner":"digitalist","description":"save your bash/zsh history to mysql or sqlite","archived":false,"fork":false,"pushed_at":"2019-03-27T09:48:13.000Z","size":18,"stargazers_count":33,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-29T16:39:27.404Z","etag":null,"topics":["bash","bashrc","dotfiles","history","mysql","sqlite","zsh","zshrc"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitalist.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2018-12-14T19:52:29.000Z","updated_at":"2023-05-12T16:53:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"a29cd390-d52f-46e5-8469-92aa3edcd4b6","html_url":"https://github.com/digitalist/bash_database_history","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/digitalist/bash_database_history","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalist%2Fbash_database_history","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalist%2Fbash_database_history/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalist%2Fbash_database_history/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalist%2Fbash_database_history/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalist","download_url":"https://codeload.github.com/digitalist/bash_database_history/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalist%2Fbash_database_history/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266567153,"owners_count":23949297,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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","bashrc","dotfiles","history","mysql","sqlite","zsh","zshrc"],"created_at":"2024-08-09T14:03:05.313Z","updated_at":"2025-07-22T20:30:55.951Z","avatar_url":"https://github.com/digitalist.png","language":"Shell","readme":"# shell_database_history\nsave your bash/zsh history to mysql or sqlite\n\nsee `bashrc_trap.sh` or `zsh_trap.sh`\n\n1) create databases you like (see `bashrc_trap.sh` for templates)\n2) comment/uncomment what you need to use (mysql/sqlite3)\n3) source `bashrc_trap.sh` or `zsh_trap.sh` at the bottom of your `~/.bashrc` / `~/.zshrc`\n4) enjoy your upgraded history using some aliases\n\n```\nmysql\u003e select count(command), cwd from bash.history group by cwd order by 1 desc limit 10\n+----------------+--------------------------------------+\n| count(command) | cwd                                  |\n+----------------+--------------------------------------+\n|            715 | /home/user                           |\n|            393 | /home/user/b/chtest                  |\n|            325 | /home/user/b/hubble                  |\n|            319 | /home/user/b/dump-clickhouse         |\n|            311 | /home/user/b/chtest/scripts          |\n|            297 | /home/user/d/afd                     |\n|            171 | /home/user/b/afonline                |\n|            112 | /home/user/d/afd/src/rules/asn/build |\n|             83 | /home/user/d                         |\n|             81 | /home/user/temp                      |\n+----------------+--------------------------------------+\n10 rows in set (0.06 sec)\n\n\nmysql\u003e select count(command), date(created)  from bash.history group by command, date(created) order by 1 desc limit 20;\n+----------------+---------------+\n| count(command) | date(created) |\n+----------------+---------------+\n|             57 | 2018-11-14    |\n|             51 | 2018-11-20    |\n|             50 | 2018-12-04    |\n|             47 | 2018-11-29    |\n|             41 | 2018-11-26    |\n|             35 | 2018-12-06    |\n|             33 | 2018-11-11    |\n|             33 | 2018-11-25    |\n\n```\nSome example aliases\n\n```\n@his(){\n\tlimit=\"\"\n\tcommand=\"select oid, created, command, cwd, tag from bash.history where command like '%$1%' \"\n\tif [[ -z \"$2\" ]]\n\tthen\n\t\t1=1\n\telse\n\t\tlimit=\"order by created desc limit $2\"\n\tfi;\n\t\n\tmysql -e \"$command$limit\"\n\techo \"run @ NUMBER to repeat command\"\n}\n\nfunction hitag(){\n\texport HISTORY_TAG=$1\n}\n\nfunction hiuntag(){\n\texport HISTORY_TAG=''\n}\n\n# alias historyMysqlDel=\"mysql -e \"use bash; truncate history\"\"\n```\n","funding_links":[],"categories":["Shell"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalist%2Fbash_database_history","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalist%2Fbash_database_history","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalist%2Fbash_database_history/lists"}