buddy-rs is a Rust-based cli tools that helps you through your Linux/macOS terminal journey. It provides a set of tools to enhance your command-line experience, including command explanations, feedback on command execution, and more.
- Installation: When you run
buddy install, it configures your shell to callbuddyshafter each command execution. - Hooking: Every time a command is executed in your shell, the hook (
buddysh) captures the command data, - Communication:
buddyshsends this data to thebuddyddaemon via a Unix domain socket. - Reaction: The daemon processes the event and can provide feedback or perform actions based on the command result.
- Explanation: ask buddy to explain a command for you.
- Rust (latest stable)
- A Unix-like environment (Linux/macOS)
To install the buddy hooks into your shell:
cargo install buddy-rsFour commands will be installed after the installation:
buddy- to manage buddy (install, uninstall, explain)buddyd- the buddy daemon that processes eventsbuddysh- the shell hook that captures command execution detailsbuddy-rs- buddy greeting and initialiser
Then initialise buddy reaction:
buddy initTo use buddy explain feature, you need to configure the API first with:
buddy config init
buddy config set BUDDY_PROVIDER <groq|openai|anthropic>
buddy config set BUDDY_API_KEY <your-api-key>Note: You can get your API key from groq or openai or anthropic.
The base url and model is set by default from the BUDDY_PROVIDER environment variable. You can change them with:
buddy config set BUDDY_BASE_URL <your-base-url>buddy config set BUDDY_MODEL <your-model>Then you can use the buddy explain command to get a brief explanation of a command:
buddy explain "ls -la"You can also specify an assistant to give you the explanation:
buddy explain "rm -rf /" --assistant gremlinAvailable assistants:
buddy(default): A bro, a buddy, a friend who gives casual, laid-back explanations with a good dose of sarcasm and humour.boss: A strict, straightforward boss who gives concise, no-nonsense explanations.mochi: A helpful, gentle close friend who provides clear explanations with a touch of humour.mrbruno: A math teacher who is known for his ability to explain complex concepts in a clear and funny way.gremlin: A mischievous gremlin who loves to cause chaos and confusion.spock: A logical and precise Vulcan who provides clear, concise explanations.
Buddy will give you its feedback on some commands:
build: build commandsdev: some popular development tools commandsfile-operation: touch, mkdir, rm, mv, cp, ln, rmdirgit: git commandspackage-manager: your system package manager commandssearch: find, lookup, grep, rg, fd, locate.fail: any command that fails with a non-zero exit code.
To uninstall the buddy hooks from your shell:
buddy uninstallP.S: This will remove the hooks from your shell but does not remove the buddy cargo installations.
Buddy daemon is handled by buddyd and hooks are handled by buddysh.
You can manage buddy service with buddy.service.
systemctl --user <start|stop|restart|status> buddy.serviceThe buddy service will be started automatically after installation.
To manage buddy shell hook, you can modify the preexec and postexec functions in:
~/.config/buddy/buddy.bashforbashwhich is sourced by~/.bashrc~/.config/buddy/buddy.zshforzshwhich is sourced by~/.zshrc~/.config/fish/functions/buddy.fishfor `fish
For fish, you can remove the preexec and postexec functions to uninstall the hooks with:
functions -e buddy_preexec
functions -e buddy_postexecMIT