Skip to main content

Generate and optionally run bash commands using an LLM provider.

Project description

lmbash

Generate bash commands from natural-language requests using an LLM provider. lmbash always shows the generated command first and only runs it after explicit confirmation.

Installation

pipx install lmbash

Or install with pip:

python3 -m pip install lmbash

Requirements

  • Python 3.9 or newer
  • An LLM provider endpoint and model

Providers

lmbash supports these provider protocols:

  • openai-compatible: OpenAI, OpenRouter, LM Studio, Ollama, and compatible chat completions servers.
  • claude-compatible: Anthropic Claude and compatible Messages API servers.

Common base URLs:

  • OpenAI: https://api.openai.com/v1
  • OpenRouter: https://openrouter.ai/api/v1
  • LM Studio: http://localhost:1234/v1
  • Ollama: http://localhost:11434/v1
  • Anthropic: https://api.anthropic.com

Configuration

Run the setup wizard:

lmbash config

Show the saved configuration:

lmbash config --show

Reset the saved configuration:

lmbash config --reset

Configuration is stored at:

~/.config/lmbash/config.json

API keys are stored locally in that file. The config file is written with 0600 permissions where supported, and lmbash config --show masks API keys.

You can override saved configuration with environment variables:

export LMBASH_PROVIDER="openai-compatible"
export LMBASH_BASE_URL="https://openrouter.ai/api/v1"
export LMBASH_API_KEY="your-api-key"
export LMBASH_MODEL="your/model-name"
export LMBASH_PROXY_URL="socks5h://127.0.0.1:7890"

The setup wizard can also save an optional proxy URL. Supported proxy schemes:

  • http://...
  • https://...
  • socks5://...
  • socks5h://...

For SOCKS proxies, socks5h://127.0.0.1:7890 is usually the best choice because DNS resolution also goes through the proxy.

Usage

Pass the request as arguments:

lmbash list files sorted by size

If no config exists, lmbash starts the setup wizard before generating a command.

Or run it without arguments and enter the request interactively:

lmbash

lmbash prints the generated command and asks what to do:

Generated command:
ls -lhS
Action? [y] execute, [e] edit, [N] cancel

Choose:

  • y or yes to execute
  • e or edit to ask for a revised command
  • Enter, n, or anything else to cancel

Override the provider API URL:

lmbash --base-url http://localhost:1234/v1 show current directory

Override the model:

lmbash --model your/model-name show current directory

Safety

lmbash generates shell commands with an LLM. Review every command before executing it. Do not run commands you do not understand, especially commands that delete files, change permissions, install software, or send data over the network.

Development

Run tests:

python3 -m unittest -v

Build distributions:

python3 -m build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lmbash-0.1.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lmbash-0.1.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file lmbash-0.1.0.tar.gz.

File metadata

  • Download URL: lmbash-0.1.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lmbash-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1f109b4063dabd014642afa9ef834fcd1108d9c09955c4957a1425282d55224d
MD5 73ef3790bae3f176d1ffef7a99a37a3b
BLAKE2b-256 dff7f5e8954511660f325bed8934e30dc5e8040256e674698f864c66c4394fa6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmbash-0.1.0.tar.gz:

Publisher: publish.yml on craftsignals/lmbash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lmbash-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lmbash-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lmbash-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b9c8410bc06d338a1ae13518c698dcba5775f5f0cee829469aa8123471d8d09
MD5 ae537083ade3e16ee91e5b0e93753cb3
BLAKE2b-256 f51167c57f869db2387080a3d3942cec6933b466d34bfd0fc1ed5373af06129a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lmbash-0.1.0-py3-none-any.whl:

Publisher: publish.yml on craftsignals/lmbash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page