markov-cli

command module
v0.0.0-...-b989bb3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

README ΒΆ

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.

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL