{"id":33014324,"url":"https://github.com/lzambarda/hbt","last_synced_at":"2026-02-19T18:12:58.913Z","repository":{"id":43028312,"uuid":"355662373","full_name":"lzambarda/hbt","owner":"lzambarda","description":"Experimental command suggestion system based on historical usage of commands in certain locations.","archived":false,"fork":false,"pushed_at":"2022-11-02T09:31:21.000Z","size":1712,"stargazers_count":9,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-15T14:47:45.470Z","etag":null,"topics":["go","suggestions","terminal","zsh"],"latest_commit_sha":null,"homepage":"","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/lzambarda.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}},"created_at":"2021-04-07T19:37:39.000Z","updated_at":"2024-07-27T16:12:55.000Z","dependencies_parsed_at":"2022-09-10T02:53:16.482Z","dependency_job_id":null,"html_url":"https://github.com/lzambarda/hbt","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/lzambarda/hbt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzambarda%2Fhbt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzambarda%2Fhbt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzambarda%2Fhbt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzambarda%2Fhbt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lzambarda","download_url":"https://codeload.github.com/lzambarda/hbt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lzambarda%2Fhbt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29627090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T18:02:07.722Z","status":"ssl_error","status_checked_at":"2026-02-19T18:01:46.144Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["go","suggestions","terminal","zsh"],"created_at":"2025-11-13T18:00:20.526Z","updated_at":"2026-02-19T18:12:58.908Z","avatar_url":"https://github.com/lzambarda.png","language":"Go","readme":"# hbt\n\nA heuristic command suggestion system for zsh.\nTAB anywhere and you can cycle through the commands you previously ran in the same location.\n\n## Rationale\n\nStoring each command into a directed graph where each node is a directory, and the edges are commands connecting nodes.\n\nEach new shell session creates a \"walker\" which keeps track of the \"path\" of directories and commands.\n\nThe built graph can then be used to suggest possible commands to execute.\n\n## Installation\n\n1. Download or build `hbt`\n2. Amend the environment variables in `zsh/hbt.zsh` to match where you store hbt (fancy the PATH?)\n3. Make sure that `zsh/hbt.zsh` is loaded by your shell.\n\n## Development\n\nThere is a `--debug` flag (or `HBT_DEBUG` env var) which can be used to print extra information.\nBy default the TCP server runs in the foreground. If you want to work on the same terminal you can use something like `nohup`.\nCheck out [`zsh/hbt.zsh`](./zsh/hbt.zsh) for an implementation of it.\n\nYou can change `HBT_BIN_PATH` to point to the binary in this repo.\nIt is usually better to run the built binary otherwise `hbt_stop` won't be able to find the running process and terminate it.\n\n## Usage\n\nThe zsh bit of hbt talks to a locally spawned TCP server handled by a go binary.\nHbt will track every command that you type and store it into a graph.\nUpon pressing TAB with an empty prompty buffer, it will try to hint at a good command, according to your typing history. Shrugs otherwise (seriously).\n\nIt internally uses some functions from [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions).\n\nSince a ~~picture~~ GIF is worth a thousand words:\n\n![demo](./docs/demo.gif)\n\n### Manual interaction with hbt\n\n```bash\nhbtsrv --help\n```\n\n[`zsh/hbt.zsh`](./zsh/hbt.zsh) provides some functions you can use to interact with a running hbt server.\n\nOtherwise you can use the `cli` command to manually execute certain commands without interacting with a server (cache and graph will be the same as the server's).\n\nExample:\n\n```bash\nhbtsrv --debug cli hint $$ $(pwd)\n```\n\nSee [server/server.go](server/server.go) for the list of supported commands.\n\n## Why the mix of go and shell functions?\n\nAt first I wanted to developed the whole thing in go, but for tracking and hinting I couldn't find an implementation faster than pure shell commands.\nGiven that the functions use zsh hooks which are executed at every command, I didn't want this to have a too significant impact on the terminal experience.\n\n## Todo\n\n- [x] Naive graph implementation\n- [x] Create custom marshaller which supports cycles and correctly restores pointers\n\n  This hasn't really been done the proper way, but it works.\n\n- [x] Tests\n- [x] Migrate what can be migrated from zsh to go\n- [ ] Benchmarking\n- [ ] R/B tree / ngram tree implementation???\n- [x] Partial path search\n- [ ] Better error catching\n- [ ] More dynamic graph parameters (env variables or flags)\n- [ ] Do not store sensistive information (is it even possible to detect it?)\n- [ ] Identify \"workflows\" by using the walker model (for the naive implementation)\n","funding_links":[],"categories":["Plugins"],"sub_categories":["ZSH on Windows"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzambarda%2Fhbt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flzambarda%2Fhbt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flzambarda%2Fhbt/lists"}