Skip to main content

Natural language shell — describe what you want, get the command

Project description

nlsh — natural language shell

Describe what you want to do, get shell commands back. Pick one, it runs.

$ nlsh "find the 3 largest files in this repo"

  ❯ du -ah . | sort -rh | head -4
    find . -type f -exec du -h {} + | sort -rh | head -3
    ls -lhS | head -4

  ──────────────────────────────────────────────────────
  summarize disk usage for all files and dirs
  du -ah .     →  report size of every file and dir
  sort -rh     →  sort human-readable sizes, largest first
  head -4      →  show top 4 results (includes header)

  [↑↓] navigate   [↵] run   [y] copy   [q] quit

Install

Requires Python 3.10+ and an Anthropic API key.

pipx install nlsh

Or with pip:

pip install nlsh

Set your API key (add to ~/.zshrc or ~/.bashrc):

export ANTHROPIC_API_KEY="sk-ant-..."

Optional: zsh widget

Press ctrl+f at any prompt to invoke nlsh inline. The selected command lands in your prompt and executes immediately.

nlsh --install-widget
source ~/.zshrc

To change the keybinding, edit ~/.config/nlsh/widget.zsh.

Usage

# basic
nlsh "compress this directory as a tarball"

# add context — URL (fetched) or plain text, repeatable
nlsh "start the dev server" -c "https://vitejs.dev/guide/"
nlsh "run tests" -c "we use pnpm, not npm"
nlsh "deploy" -c "https://fly.io/docs/launch/" -c "app name is my-api"

# fix a failed command — pipe in the error
npm run build 2>&1 | nlsh --fix
cargo build 2>&1 | nlsh --fix

# or describe what broke
nlsh --fix "permission denied writing to /usr/local"

# flat output (no TUI) — useful for scripting
nlsh -v "list open ports"

# see commands without running
nlsh --dry-run "clean up docker"

How it works

  1. Captures your current directory, git status, and file listing as context
  2. Sends your query to Claude (Haiku) with that context
  3. Gets back 3–5 {command, explanation} suggestions as JSON
  4. Shows them in an interactive picker — explanation only for the item you're hovering on
  5. Runs the chosen command via your shell

Security

nlsh executes AI-generated shell commands. A few things to know:

  • Review before running — the picker lets you read the command before pressing enter. Use --dry-run if you want to see suggestions without any risk of execution.
  • Your API key — store it in a file with restricted permissions (chmod 600), not directly in .zshrc where it might be shared or version-controlled.
  • Network-c URLs are fetched over HTTPS. Content is sent to the Anthropic API along with your query.

Configuration

Environment variable Default Description
ANTHROPIC_API_KEY Required. Your Anthropic API key.

More configuration options (model choice, default context, keybinding) are on the roadmap.

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

nlsh_tool_beta-0.1.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

nlsh_tool_beta-0.1.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nlsh_tool_beta-0.1.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for nlsh_tool_beta-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c2ca14cf59da3f1594af5ed79b54a5445396a236356ff895a69a3b3ea971d87
MD5 0a87be4faf44a12c3a4c56831041d03e
BLAKE2b-256 bdfcd464a62d7192b7461c97242421163da71ae9f95f05e249cc0ef66afc879d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nlsh_tool_beta-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for nlsh_tool_beta-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b19b5a473c96565179f2f5e4b4f4c4cfba9f11696e608c0a8eb750eadc246b7
MD5 7a0a815a0764dbe9f64d20156175f453
BLAKE2b-256 589ede51cea8f50249898d556004919fad92769cabc256a2217fe7199d8d2fac

See more details on using hashes here.

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