markov-cli
markov-cli is a terminal-based command suggestion tool powered by a Markov chain model.
It learns your shell history and helps you autocomplete commands in an interactive TUI using the Bubbletea framework.
π§ Status: Under Development
This project is still in an early development phase.
Functionality may be unstable or incomplete. Use at your own risk.
Your feedback and contributions are welcome!
β¨ Features
- π§ Learns from your
.zsh_history or .bash_history
- β‘ Token-based Markov model for smarter suggestions (e.g.,
npm β run, install, etc.)
- π― Real-time suggestions as you type
- β¨οΈ Interactive CLI with up/down navigation and selection
- π§Ό Clears the screen and outputs the final command on exit
πΈ Demo
$ markov-cli
Command: npm
Suggestions:
install
> run
test
# After pressing Enter:
npm run
π Installation
git clone https://github.com/trknhr/markov-cli.git
cd markov-cli
go build -o markov-cli
./markov-cli
π Directory Structure
.
βββ history/ # History parsers for bash and zsh
βββ marcov/ # Token-level Markov model implementation
βββ ui/ # Bubbletea-based TUI
βββ main.go # Entry point
βββ go.mod
βββ README.md
π How It Works
- History is loaded from
~/.zsh_history by default
- Each line is tokenized (e.g.,
git commit -m β ["git", "commit", "-m"])
- Transitions between tokens are counted and stored as a Markov chain
- As you type, the last token is used to predict the most likely next token(s)
- Suggestions are updated dynamically
β¨οΈ Keyboard Shortcuts
- β / β : Navigate suggestions
Enter : Add selected token to input and quit
q or Ctrl+C : Quit without output
π§ͺ Optional Enhancements (Planned)
- Multi-step interaction (keep suggesting until the user confirms)
- Support for persistent model across sessions
- Improved UI and fuzzy matching
- Better integration with shells (
zle, eval, etc.)
π License
Apache-2.0
See LICENSE for full terms.