Skip to main content

Convert natural language descriptions into terminal commands using AI

Project description

Semantic terminal

PyPI Lines of Code License: MIT

A single-purpose command-line tool in the Unix tradition: it does one thing and does it well. sem translates natural language into shell commands using AI. Only Python core functionality is used, no additional dependencies or fancy spinners.

Semantic terminal preview

Install

pip install semantic-terminal

Requires Python 3.10+.

Quick start

  1. Get a free API key at console.groq.com (sposor the project and I'll gladly change default provider option)
  2. Run the setup wizard:
    sem config
    
  3. Start using it:
    sem "find all python files larger than 1MB"
    

Usage

sem <description>        # Generate a command
sem -r <description>     # Generate and execute
sem -r / sem !           # Execute the last generated command
sem -v|--verbose <desc>  # Show detailed breakdown + command
sem -V|--version         # Show version
sem ?                    # Show last request + generated command

sem-run command (optional)

Command execution via sem runs in a subprocess, this creates a problem that executed commands are not stored in a terminal history which might be uncomfortable for many users. Specifically to solve the issue we give additional setup:

sem-setup --shell bash|zsh|powershell

or run sem-setup with no parameters to auto detect terminal. After installation, sem-run behaves like sem -r but keeps executed commands in terminal history.

Verification:

# bash/zsh
type sem-run

# PowerShell
Get-Command sem-run

If PowerShell blocks profile loading, use:

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

How it works

sem sends your description to the configured AI model with a system prompt that instructs it to

  • Either return exactly one shell command or optionally provide a short breakdown of the command
  • Take into account your OS and shell.
  • If command breakdown is requested via --verbose, describe it in the language of the request.

Examples

$ sem "list files sorted by size"
$ ls -lS

$ sem "find processes using port 8080"
$ lsof -i :8080

$ sem "disk usage of current directory, human readable"
$ du -sh .

$ sem "compress all log files in /var/log older than 7 days"
$ find /var/log -name "*.log" -mtime +7 -exec gzip {} \;

$ sem -v покажи 10 последних коммитов деревом
Чтобы показать последние коммиты в виде дерева, вы можете использовать команду git log с опцией --graph. Вот что делает эта команда:
* Показывает последние коммиты в виде дерева, где каждая ветка представлена отдельной линией
* Опция --graph позволяет визуализировать историю коммитов
* Опция -10 ограничивает вывод до 10 последних коммитов
* Команда git log используется для просмотра истории коммитов
git log --graph -10

$ sem -v 使用树显示10个提交
要显示10个提交记录,可以使用git log命令并结合--oneline和--graph选项来以树形结构显示提交历史。以下是关键点:
* git log命令用于显示提交历史
* --oneline选项使每个提交记录只显示一行
* --graph选项使提交历史以树形结构显示
* --all选项显示所有分支的提交记录
* 使用head选项可以限制显示的提交记录数量
git log --graph --oneline --all -10


$ sem -v Mostrar 10 confirmaciones con el árbol
Para mostrar 10 confirmaciones con el árbol, puedes utilizar el comando git log con las opciones --oneline y --graph. Aquí hay algunos puntos clave sobre este comando:
* El comando git log se utiliza para mostrar un registro de confirmaciones.
* La opción --oneline muestra cada confirmación en una sola línea.
* La opción --graph muestra el árbol de confirmaciones.
* La opción -10 limita la salida a las 10 últimas confirmaciones.
* Este comando asume que estás en el directorio raíz de un repositorio git.
git log --oneline --graph -10

The generated command targets your OS and shell automatically.

Configuration

Run the interactive wizard:

sem config

Or manage individual settings:

sem config show                              # View current config
sem config set api_base https://...          # Set API endpoint
sem config set api_key                       # Set API key (hidden prompt)
sem config set model llama-3.3-70b-versatile # Set model

Defaults

Setting Default
Provider Groq (free tier)
Model llama-3.3-70b-versatile
API Base https://api.groq.com/openai/v1

Any OpenAI-compatible API works.

Environment variables

Environment variables take precedence over the config file:

Variable Purpose
SEM_API_KEY API key (highest priority)
SEM_API_BASE API base URL override
SEM_MODEL Model override

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

semantic_terminal-1.2.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

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

semantic_terminal-1.2.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file semantic_terminal-1.2.0.tar.gz.

File metadata

  • Download URL: semantic_terminal-1.2.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for semantic_terminal-1.2.0.tar.gz
Algorithm Hash digest
SHA256 02c87e93bce4c4ea25cf4733bfa1a4cf6aa8fbcb6b4fcb0438000aa0bcc6e51f
MD5 210a8a4df290958b057d1e658aa2e5a1
BLAKE2b-256 defa061353c49bbe594a2dec4711178a0864934db186c035150c652cf34b68c4

See more details on using hashes here.

File details

Details for the file semantic_terminal-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for semantic_terminal-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5351b6f616c7e84936e1a9ca854ca1f631345d39f860beb577c38f752a920479
MD5 f95d0c49da62c5822a7e0003c8b1ec0e
BLAKE2b-256 04953fe48855b6bb8a15e30c78c54ffd9d993c6d8aa569f46290cc11ec7c17af

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