Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

26 Commits

Repository files navigation

inline-cli

Lazist way to ask AI without leaving your command line.
Type a question, press Shift+Enter, get a streaming answer — right where you are.

InstallHow it worksConfigurationSupported terminals


inline-cli4

No context switching. No new window. The answer streams in below your prompt and you keep working. Just press Shift+Enter to trigger an AI response.

Install

curl -sSL https://raw.githubusercontent.com/CCALITA/inline-cli/main/scripts/install.sh | sh

Or build from source:

git clone https://github.com/CCALITA/inline-cli.git
cd inline-cli
make build # → ./build/inline-cli
cp ./build/inline-cli ~/.local/bin/inline-cli # or anywhere in your PATH

Then set up your shell and backend:

# 1. Add shell integration (pick one)echo'eval "$(inline-cli init zsh)"'>>~/.zshrc # zshecho'eval "$(inline-cli init bash)"'>>~/.bashrc # bash# 2. Choose a backend
inline-cli setup
# 3. Restart your shellexec$SHELL

How it works

 ┌─────────────────┐ Unix socket ┌──────────────┐ HTTPS/SSE ┌───────────┐
│ shell widget │ ──────────────────> │ daemon │ ─────────────────>│ AI │
│ captures buffer │ <── NDJSON stream── │ per-dir │ <── streaming ── │ backend │
│ renders output │ │ sessions │ └───────────┘
└─────────────────┘ │ │
│ │ ───> Anthropic API
│ │ ───> claude CLI
│ │ ───> gemini CLI
│ │ ───> opencode CLI
└──────────────┘

Three pieces:

  1. Shell integration — A zsh ZLE widget or bash readline binding captures your command-line buffer on Shift+Enter (or Ctrl+J) and pipes it to the CLI.
  2. Background daemon — A long-lived Go process manages conversation sessions over a Unix domain socket. Sub-millisecond IPC. No cold start per query.
  3. Pluggable backend — Talks to Claude via direct API, the claude CLI, Gemini CLI, or OpenCode CLI. Streams responses as markdown to your terminal.

Directory-scoped sessions

Every directory gets its own conversation. Ask a follow-up question in the same directory and the daemon remembers context. Change directories and the old session stops automatically.

A session indicator appears in your prompt while a session is active:

👀 ~/project $ explain the auth middleware ⇧↵
... (streaming response) ...
👀 ~/project $ what about the rate limiter? ⇧↵
... (knows you're still talking about this project) ...
cd ~/other-project
(previous session ends, 👀 disappears)
~/other-project $ how does the build work here? ⇧↵
... (fresh session, 👀 appears again) ...

The indicator auto-detects your prompt framework (Powerlevel10k, Starship, plain zsh/bash) and injects itself without overwriting your existing prompt. Set INLINE_CLI_NO_PROMPT=1 to disable it.

Auto-start

The daemon starts itself on the first query. No setup, no systemd, no launchd. When your shell exits, it cleans up.

Usage

The primary interface is the keybinding — type and press Shift+Enter or Ctrl+J. But you can also use the CLI directly:

# Ask a question (type in your shell, then press Shift+Enter or Ctrl+J)# Check what's running
inline-cli status
# Manage backends
inline-cli setup # Interactive first-time setup
inline-cli backend list # List backends with install status
inline-cli backend show # Show current backend
inline-cli backend set gemini # Switch backend (auto-restarts daemon)# Manage the daemon
inline-cli daemon start
inline-cli daemon stop

Configuration

Config lives at ~/.inline-cli/config.toml. All fields are optional — defaults are sensible.

# Backend: "api" (default), "claude", "gemini", "opencode"backend = "api"# API backend settingsapi_key = "sk-ant-..."# or set ANTHROPIC_API_KEY env varmodel = "claude-sonnet-4-20250514"# default modelapi_base_url = ""# custom API endpoint (proxy, gateway)# CLI backend paths (auto-detected from PATH if empty)cli_path = ""gemini_path = ""opencode_path = ""# Session settingsmax_session_idle_minutes = 30max_messages = 50

Backends

BackendConfigWhat it does
api (default)Needs ANTHROPIC_API_KEYDirect HTTPS to Anthropic Messages API with SSE streaming
claudeNeeds claude in PATHExecs claude -p <prompt> and streams stdout. Uses your existing Claude CLI auth.
geminiNeeds gemini in PATHExecs gemini -p <prompt> -o text and streams stdout. Uses Gemini CLI auth.
opencodeNeeds opencode in PATHExecs opencode run --format json and parses the JSON event stream.

Switch backends via the CLI or config file:

# Interactive setup (detects installed CLIs)
inline-cli setup
# Direct switch
inline-cli backend set gemini

Environment variables

VariablePurpose
ANTHROPIC_API_KEYAPI key (required for api backend)
INLINE_CLI_MODELOverride model
INLINE_CLI_SOCKETCustom socket path
INLINE_CLI_API_BASE_URLCustom API endpoint
INLINE_CLI_CLI_PATHPath to claude binary
INLINE_CLI_GEMINI_PATHPath to gemini binary
INLINE_CLI_OPENCODE_PATHPath to opencode binary
INLINE_CLI_MAX_IDLESession idle timeout (minutes)
INLINE_CLI_NO_PROMPTSet to 1 to disable prompt indicator

Precedence: env vars > config file > defaults.

Supported shells

ShellIntegrationKeybinding
zshZLE widgetCtrl+J, Shift+Enter (CSI u / xterm)
bashbind -x / readlineCtrl+J, Shift+Enter (terminal remap)

Supported terminals

Shift+Enter works automatically (zsh)

inline-cli enables the kitty keyboard protocol during line editing, so Shift+Enter works out of the box in modern terminals:

TerminalShift+EnterNotes
GhosttyAutomatic
kittyAutomatic
WezTermAutomatic
iTerm2 (3.5+)Automatic
footAutomatic
xtermAutomaticVia modifyOtherKeys
VTE-based (GNOME Terminal, Tilix)Automatic

Bash: terminal configuration required

Bash's readline cannot bind CSI sequences, so Shift+Enter requires a terminal-side remap to \n (0x0a). Ctrl+J always works without configuration.

TerminalConfig
Ghosttykeybind = shift+enter=text:\n
kittymap shift+enter send_text all \x0a
WezTerm{ key = "Enter", mods = "SHIFT", action = SendString("\x0a") }
iTerm2Keys > Key Mappings > Shift+Return > Send Hex Code 0a

Fallback: Ctrl+J

Terminals that support neither protocol use Ctrl+J:

TerminalKeybinding
Terminal.app (macOS)Ctrl+J
AlacrittyCtrl+J

tmux note: Extended key sequences are stripped by default. Ctrl+J always works. For Shift+Enter, add set -g extended-keys on and set -g extended-keys-format csi-u to your tmux config.

Prompt indicator

A 👀 emoji appears in your prompt while a session is active for the current directory. It auto-detects your setup:

Prompt frameworkHow it works
Powerlevel10kAuto-registers inline_cli segment in right prompt
Starshipprecmd hook prints indicator above the prompt
Plain zshPrepends $(inline_cli_prompt_info) to PROMPT
oh-my-zshSame as plain zsh
bashPrepends $(_inline_cli_indicator) to PS1

Set INLINE_CLI_NO_PROMPT=1 to disable auto-injection. The inline_cli_prompt_info function is still available for manual use.

Cross-compilation

Build release binaries for all supported platforms:

make release

Produces {linux,darwin}_{amd64,arm64} tarballs in ./build/ with SHA-256 checksums.

Make targets

TargetWhat it does
make buildBuild binary → ./build/inline-cli
make testRun all tests with -race -cover
make lintRun go vet
make cleanRemove ./build/
make releaseCross-compile + tarball + SHA-256 checksums

Architecture

inline-cli/
├── cmd/inline-cli/ # CLI entry point + embedded shell scripts
├── internal/
│ ├── backend/ # Backend interface + implementations (API, Claude CLI, Gemini CLI, OpenCode CLI)
│ ├── claude/ # Claude API client + SSE streaming parser
│ ├── config/ # Config loading (TOML + env vars)
│ ├── daemon/ # Daemon lifecycle + Unix socket server
│ ├── ipc/ # IPC protocol (NDJSON over Unix socket)
│ ├── render/ # Terminal renderer + markdown (glamour)
│ └── session/ # Directory-scoped session manager
└── scripts/ # Install/uninstall scripts

Single Go binary, ~14MB. No runtime dependencies.

Requirements

  • Go 1.26+ (build only)
  • macOS or Linux
  • zsh or bash
  • One of: Anthropic API key, claude CLI, gemini CLI, or opencode CLI

Uninstall

inline-cli daemon stop
rm "$(which inline-cli)"

Remove the # >>> inline-cli >>> block from your .zshrc or .bashrc.

License

MIT

About

lazist to use ai in terminal

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages