Skip to main content

Natural language terminal powered by Gemma 4 via llama.cpp

Project description

gterm

Local natural-language terminal powered by Gemma 4 via llama.cpp.

Describe what you want in plain English. gterm turns that into shell commands, shows the exact command before execution, and keeps enough context to help with follow-up requests.

What it does

  • Runs fully local inference with Gemma 4 GGUF models
  • Picks a model that fits your hardware and downloads it on first use
  • Learns your projects and common directories from shell history, with explicit consent
  • Suggests a corrected command automatically when a command fails
  • Gives a short follow-up summary after non-trivial command output
  • Hands off full-terminal tools like codex, aider, vim, and lazygit without breaking their UI

Install

From PyPI:

uv tool install gterm

or:

pip install gterm

From source:

uv tool install git+https://github.com/lsgrep/gterm

llama-cpp-python builds from source during install. Gemma 4 models with the gemma4 architecture are currently forced onto CPU on macOS because of an upstream Metal crash in llama.cpp.

Quickstart

gterm

On first run, gterm:

  1. detects your hardware
  2. picks the best matching Gemma 4 model
  3. offers to download it if needed
  4. asks whether it may read your shell history for project context

Useful commands:

gterm models            # list all bundled model variants
gterm download "26b q4" # download a specific model
gterm use "e4b q8"      # set a default model

Once initialized, you can say things like:

❯ show me memory usage
❯ go to the gterm project
❯ open my overlay-web repo in codex
❯ explain that error

REPL behavior

Example prompt:

  ~/code/lsgrep/personal/gterm   main ●  gterm
❯ show me memory usage

The prompt shows:

  • current directory
  • git branch and dirty state
  • whether you are ahead or behind the remote

For each request, the model responds in exactly one mode:

  • Shell command: a fenced shell block that gterm asks you to confirm
  • # ANSWER:: a direct answer when you ask to explain or summarize output
  • # CLARIFY:: only when the request is genuinely ambiguous or destructive

Before execution, you get:

  [y]es  [n]o  [e]dit

e opens the generated command in $EDITOR so you can modify it before running.

After execution:

  • successful multi-line output gets a short automatic summary
  • failed commands trigger an automatic repair attempt
  • cd changes update the REPL working directory without spawning a subshell

Built-in commands

Command Description
/model Open the model picker
/model <name> Switch to a model by fuzzy name match
/models List available models with fit/download status
/init Rebuild project and directory context from shell history
/clear Clear conversation history
/history Show recent conversation turns
/cwd Print current directory
/help Show command help
exit / quit / Ctrl-D Quit

The REPL also supports tab completion for built-ins and model names after /model.

Project-aware navigation

If you allow shell-history access, gterm extracts:

  • known projects
  • frequent directories

That enables requests like:

❯ go to the germ project
❯ open segue in codex
❯ start aider in my api repo

Nothing is uploaded anywhere. The derived context is stored locally in ~/.config/gterm/state.json.

Interactive tools

gterm can launch full-terminal programs directly instead of trying to capture their output. That includes:

  • claude
  • aider
  • codex
  • gemini
  • vim
  • nvim
  • nano
  • emacs
  • hx
  • micro
  • less
  • htop
  • btop
  • lazygit
  • tig

Typical handoff:

❯ open my overlay project in codex
→ cd /path/to/project
→ codex

Models

gterm ships with a registry of Gemma 4 GGUF variants from Bartowski's Hugging Face repos and chooses the largest model that fits your machine.

Families currently included:

Model Notes Smallest bundled quant
Gemma 4 31B dense model IQ1_M
Gemma 4 26B-A4B MoE IQ2_XXS
Gemma 4 E4B MoE IQ2_M
Gemma 4 E2B MoE IQ2_M

Selection is based on available RAM or Metal-accessible memory. Downloaded models live under ~/.config/gterm/models/.

Configuration

Configuration can come from environment variables or ~/.config/gterm/config.toml.

Examples:

export GTERM_MODEL_PATH=/path/to/custom.gguf
export GTERM_N_CTX=4096
export GTERM_N_GPU_LAYERS=-1
export GTERM_N_THREADS=10
export GTERM_N_BATCH=2048
export GTERM_TEMPERATURE=0.2
export GTERM_MAX_TOKENS=512
export GTERM_HISTORY_LIMIT=20
export GTERM_HF_TOKEN=hf_...
export GTERM_PARANOID_MODE=true

Example config.toml:

model_path = "/path/to/model.gguf"
n_ctx = 4096
temperature = 0.2
paranoid_mode = false

paranoid_mode adds a stricter confirmation path for dangerous commands.

Context and privacy

Shell history is read only after explicit consent. gterm currently looks at standard shell history files such as ~/.zsh_history and ~/.bash_history to infer project paths and frequently used directories.

To revoke consent or reset the cached context:

echo '{"history_consent": false}' > ~/.config/gterm/state.json

or:

rm ~/.config/gterm/state.json
gterm

Requirements

  • Python 3.11+
  • macOS or Linux
  • enough free disk and RAM for your chosen model

License

Apache 2.0. See LICENSE.

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

gterm-0.1.2.tar.gz (69.4 kB view details)

Uploaded Source

Built Distribution

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

gterm-0.1.2-py3-none-any.whl (34.9 kB view details)

Uploaded Python 3

File details

Details for the file gterm-0.1.2.tar.gz.

File metadata

  • Download URL: gterm-0.1.2.tar.gz
  • Upload date:
  • Size: 69.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gterm-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ba353228007dd5ae67edea6c34babb688fa53a7d00fe33316cd41d1f2e81b83f
MD5 3c3b801d5e360c77f669b086c36fae47
BLAKE2b-256 7a25f2e50c2872daa7e691cf826c88c4e282bad55212726a1a0754f09ab6ee9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for gterm-0.1.2.tar.gz:

Publisher: release.yml on lsgrep/gterm

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

File details

Details for the file gterm-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gterm-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 34.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gterm-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5f6136988605309e72940e1af7252857a25dcefb5b7cb1df519e699a8d63cb6d
MD5 f88beb79d877daeee60e1b992765a530
BLAKE2b-256 77510714ab20f4b97ea40db16708aabfe24067e6799e5a8f1dac43c5777cbc84

See more details on using hashes here.

Provenance

The following attestation bundles were made for gterm-0.1.2-py3-none-any.whl:

Publisher: release.yml on lsgrep/gterm

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