Skip to content
tabris17Public

About

Natural Language to Shell Command via LLM

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

79 Commits

Folders and files

Repository files navigation

Lazycli

[简体中文]

A cross-platform command-line tool that converts natural language into shell commands using LLMs, bridging user intent and the shell environment with explicit user confirmation before execution for safety.

Features

  • Cross-platform support (Windows, Linux, macOS, BSD)
  • Works seamlessly across popular shells (bash, fish, nushell, zsh, PowerShell)
  • Flexible LLM backend support via OpenAI-compatible APIs
  • Configurable prompt templates
  • Interactive command confirmation before execution
  • Lightweight and token-efficient for low-cost usage

Installation

From Source

git clone https://github.com/tabris17/lazycli
cd lazycli
nimble setup
nimble release

Download

Get the latest release from:

https://github.com/tabris17/lazycli/releases

Integration

Configure your shell to initialize lazycli. Select yours from the list below:

Bash

Add the following to the end of ~/.bashrc:

eval "$(lazycli init bash)"

If you are running Bash on Windows (e.g., Git Bash, MSYS2), add the --posix-path flag to ensure correct path handling:

eval "$(lazycli init --posix-path bash)"

Fish

Add the following to the end of ~/.config/fish/config.fish:

lazycli init fish | source

Nushell

Run the following code in nushell:

mkdir ($nu.data-dir | path join "vendor/autoload")
lazycli init nushell | save -f ($nu.data-dir | path join "vendor/autoload/lazycli.nu")

PowerShell

Add the following to the end of your PowerShell profile, which you can open by running notepad $PROFILE:

Invoke-Expression (& { lazycli init powershell | Out-String })

Zsh

Add the following to the end of ~/.zshrc:

eval "$(lazycli init zsh)"

Advanced

lazycli init supports the following options:

  • --config: Specifies the configuration file to use
  • --posix-path: Forces the init shell script to use POSIX path separators. Useful for portable versions of Bash running on Windows
  • -p, --proxy: Specifies the proxy URL (overrides config and environment variables)

lazycli query also supports the --verbose/-v flag for debugging, which outputs the full API request and response to stderr:

lazycli query --verbose "list all files"

Usage

First, initialize the configuration file using the following command:

lazycli config init

Follow the prompts to complete the setup step by step. To overwrite an existing configuration, use the --force option.

Make sure your shell has loaded the initialization script. At the command prompt, type a natural language description of the command you want to execute. For example: list all files.

Then press the configured hotkey (default is F1) to invoke lazycli. After the command is processed, the content at the command prompt will be automatically replaced with an executable shell command.

Configuration

Default configuration file locations:

  • Linux/macOS: ~/.config/lazycli/config.toml
  • Windows: %USERPROFILE%\.config\lazycli\config.toml

You can also run lazycli config to locate the configuration file path.

Custom Prompt

Optionally, you can add a prompt field to config.toml to inject additional instructions. This custom prompt is not a replacement for the built-in system prompt — instead, it is sent as a separate message (role "system") in the API request, placed before the runtime context. This allows you to guide the LLM with extra context or constraints without affecting the core instruction template.

prompt = "Prefer PowerShell cmdlets over native executables when possible."

Retry on Invalid Response

You can configure the maximum number of retries when the LLM returns an invalid response (e.g., malformed JSON). The default is 3:

max_retries = 5

Preview the full rendered messages to see exactly what is sent to the model.

Supported LLM Backends

Currently supported:

  • OpenAI-compatible APIs

License

MIT License

About

Natural Language to Shell Command via LLM

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages