Skip to main content

nlshell

A very small Python package that generates shell commands from a "natural language" description. It will provide a explanation of the command and prefill the command line with the generated command.

You must provide a url to an openai compatible api, e.g. a local model served by e.g. Ollama, or a remote model.

⚠️ IMPORTANT! Never run a generated command without understanding what it does. The generated command may be harmful. There is no guarantee whatsoever that what the LLM suggests is correct! DON'T BLINDLY TRUST THE GENERATED SUGGESTION!

Table of Contents

Installation

Install nlshell from PyPI with either pip or uv.

# Using pip
pip install nlshell

# Using uv
uv tool install nlshell

Development

To run the test suite with the project-managed environment:

uv sync --group dev
uv run pytest -q

Usage

Activate the virtual environment where the package is installed to use the nlshell command.

Set the base_url

The package uses the openai client to call an LLM. By specifying a base-url you can use your own model, e.g. a local model.

c --base-url http://localhost:11434/v1

If no base_url is explicitly set, the package will ask which url to use.

Create a command

c list all files in the current directory, including hidden files

where c is the nlshell command. This command will generate a response like this:

The 'ls' command lists directory contents. The option '-l' provides a long listing format which includes file permissions, number of links, owner, group, size, and time of last modification. The '-a' option ensures hidden files (those starting with a dot .) are also listed.
$ ls -la

Set the API key

export NLSHELL_API_KEY="your-api-key"

The API key is read from the NLSHELL_API_KEY environment variable only. It is not stored in ~/.config/nlshell/settings.ini.

Even if you run a local model you may need to set an API key since the OpenAI client requires one, even if the key is just a dummy value.

Set the model

c --set-model qwen3:8b

If no model is specified the package will ask which model to use.

Switch between local and open-router models

You can easily switch between using a local model (via Ollama) or an open-router remote model:

# Use local model
c --use-local

# Use open-router remote model
c --use-open-router

The setting is saved to ~/.config/nlshell/settings.ini and persists between sessions. Defaults to local mode.

Use from any environment

If you have installed the package in a virtual environment you can use it from any environment by adding a simple shell script to e.g. ~/.local/bin:

  1. Create a file ~/.local/bin/c with the following content:

    #!/bin/bash
    # Activate the venv and run the command from it
    source /path/to/your/environment/.venv/bin/activate
    exec c "$@"
    
  2. Make the script executable:

    chmod +x ~/.local/bin/c
    

Now you can use the c command from any terminal session.

License

Distributed under the MIT License. See LICENSE for more information.

GitHub

https://github.com/mbrycke/nlshell

Release files for nlshell 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nlshell 0.1.2
File Size Uploaded
nlshell-0.1.2.tar.gz 38.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nlshell 0.1.2
File Interpreter ABI Platform
nlshell-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 46.7 kB

Release files / nlshell-0.1.2.tar.gz

Download URL nlshell-0.1.2.tar.gz
Size 38.7 kB
Tags Source
SHA-256 checksum
How to use checksums
da0a004dee40a9012ab580adbe6f1f5e2435bcb4c44345197803e1ca3a2e647d
BLAKE2b-256 checksum
How to use checksums
c2c72a56783ceff862a85625447a410fe6090711a9d012218f6c7c14b19f1899
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / nlshell-0.1.2-py3-none-any.whl

Download URL nlshell-0.1.2-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9524fc5f93e03a9c0644aa46f2dd40e9a80f0aef2cf5a9ba6c3216d3e01dc89
BLAKE2b-256 checksum
How to use checksums
60679bc5ad6532c369dded2e0a30809d17298b68aad6b4534950a0c3e45103bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page