Skip to main content

AI-powered bash command generator

Project description

terminal-sherpa

A lightweight AI chat interface for fellow terminal dwellers.

Turn natural language into bash commands instantly. Stop googling syntax and start asking.

PyPI - Version GitHub License Python Versions Actions status codecov

🚀 Getting Started

Get up and running:

# Install terminal-sherpa
pip install terminal-sherpa # installs the `ask` CLI tool

# Set your API key
export ANTHROPIC_API_KEY="your-key-here"

# Try it out
ask "find all .py files modified in the last week"

Example output:

find . -name "*.py" -mtime -7

✨ Features

  • Natural language to bash conversion - Describe what you want, get the command
  • Multiple AI provider support - Choose between Anthropic (Claude), OpenAI (GPT), Google (Gemini), and xAI (Grok) models
  • Flexible configuration system - Set defaults, customize models, and manage API keys
  • XDG-compliant config files - Follows standard configuration file locations
  • Verbose logging support - Debug and understand what's happening under the hood

📦 Installation

Requirements

  • Python 3.9+
  • API key for Anthropic, OpenAI, Google, or xAI

Install Methods

Using pip:

pip install terminal-sherpa

From source:

git clone https://github.com/lcford2/terminal-sherpa.git
cd terminal-sherpa
uv sync
uv run ask "your prompt here"

Verify installation:

ask --help

💡 Usage

Basic Syntax

ask "your natural language prompt"

Command Options

Option Description Example
--model provider:model Specify provider and model ask --model anthropic "list files"
ask --model anthropic:sonnet "list files"
ask --model openai "list files"
ask --model gemini "list files"
ask --model gemini:pro "list files"
ask --model grok "list files"
--verbose Enable verbose logging ask --verbose "compress this folder"

Practical Examples

File Operations:

ask "find all files larger than 100MB"
# Example output: find . -size +100M

ask "create a backup of config.txt with timestamp"
# Example output: cp config.txt config.txt.$(date +%Y%m%d_%H%M%S)

Git Commands:

ask "show git log for last 5 commits with one line each"
# Example output: git log --oneline -5

ask "delete all local branches that have been merged"
# Example output: git branch --merged | grep -v "\*\|main\|master" | xargs -n 1 git branch -d

System Administration:

ask "check disk usage of current directory sorted by size"
# Example output: du -sh * | sort -hr

ask "find processes using port 8080"
# Example output: lsof -i :8080

Text Processing:

ask "count lines in all Python files"
# Example output: find . -name "*.py" -exec wc -l {} + | tail -1

ask "replace all tabs with spaces in file.txt"
# Example output: sed -i 's/\t/    /g' file.txt

Network Operations:

ask "download file from URL and save to downloads folder"
# Example output: curl -o ~/Downloads/filename "https://example.com/file"

ask "check if port 443 is open on example.com"
# Example output: nc -zv example.com 443

⚙️ Configuration

Configuration File Locations

Ask follows XDG Base Directory Specification:

  1. $XDG_CONFIG_HOME/ask/config.toml
  2. ~/.config/ask/config.toml (if XDG_CONFIG_HOME not set)
  3. ~/.ask/config.toml (fallback)

Environment Variables

export ANTHROPIC_API_KEY="your-anthropic-key"
export OPENAI_API_KEY="your-openai-key"
export GEMINI_API_KEY="your-gemini-key"
export XAI_API_KEY="your-xai-key"

Example Configuration File

Create ~/.config/ask/config.toml:

[ask]
default_model = "anthropic"

[anthropic]
model = "claude-3-haiku-20240307"
max_tokens = 512

[anthropic.sonnet]
model = "claude-sonnet-4-20250514"
max_tokens = 1024

[openai]
model = "gpt-4o"
max_tokens = 1024

[gemini]
model = "gemini-2.5-flash-lite-preview-06-17"
max_tokens = 150

[gemini.pro]
model = "gemini-2.5-pro"
max_tokens = 1024

[grok]
model = "grok-3-fast"
max_tokens = 150
temperature = 0.0

🤖 Supported Providers

  • Anthropic (Claude)
  • OpenAI (GPT)
  • Google (Gemini)
  • xAI (Grok)

Note: Get API keys from Anthropic Console, OpenAI Platform, Google AI Studio, or xAI Console

🛣️ Roadmap

  • Shell integration and auto-completion
  • Additional providers (Cohere, Mistral)
  • Local model support (Ollama, llama.cpp)

🔧 Development

Setup

git clone https://github.com/lcford2/terminal-sherpa.git
cd ask
uv sync --all-groups
uv run pre-commit install

Testing

uv run python -m pytest

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run pre-commit checks: uv run pre-commit run --all-files
  5. Run tests: uv run task test
  6. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Issues

Found a bug or have a feature request? Please open an issue on GitHub Issues.

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

terminal_sherpa-0.4.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

terminal_sherpa-0.4.0-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file terminal_sherpa-0.4.0.tar.gz.

File metadata

  • Download URL: terminal_sherpa-0.4.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for terminal_sherpa-0.4.0.tar.gz
Algorithm Hash digest
SHA256 1af7d0553b74adda29d30e465d05c557432d254de7f29bcf3b2927e7a77b1598
MD5 d46061de2af42edb1c285a50b7dc1444
BLAKE2b-256 fb80feabb5289251f43721ac3d1977ce86a39afc2e68a45ff09af3fa3dd022d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for terminal_sherpa-0.4.0.tar.gz:

Publisher: publish.yml on lcford2/terminal-sherpa

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

File details

Details for the file terminal_sherpa-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for terminal_sherpa-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b7910e1b2e31462bac078bce3922d2d7cb1e57b349ff42947d48b2107c95a174
MD5 5a4d5cb4cc458026172b40cff3dced84
BLAKE2b-256 e2b0a6ec61d0d23e0af18b0becad0f09b4544910ce054a173c034f5c36ce11f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for terminal_sherpa-0.4.0-py3-none-any.whl:

Publisher: publish.yml on lcford2/terminal-sherpa

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