Useful ToolsTerminal

Terminal

Interactive terminal utilities: selection menus, yes/no prompts, and inline autocomplete.

Usage

Option 1: Import directly

main.py
from connectonion import pick, yes_no, autocomplete

Option 2: Copy and customize

code
co copy terminal
main.py
from tools.terminal import pick, yes_no, autocomplete # Your local copy

Quick Start

main.py
from connectonion import pick, yes_no, autocomplete # Selection menu choice = pick("Pick a color", ["Red", "Green", "Blue"]) # Yes/No confirmation ok = yes_no("Are you sure?") # Inline autocomplete dropdown (you supply the candidates) files = ["agent.py", "main.py", "utils.py"] selected = autocomplete(files) if selected: print(f"Selected: {selected}")

Want to customize? Run co copy terminal to get an editable copy.

pick()

Single-select menu with keyboard navigation.

main.py
# List options (press 1, 2, 3 or arrow keys) choice = pick("Apply this command?", [ "Yes, apply", "Yes for same command", "No, tell agent how" ]) # Dict options (returns key) choice = pick("Continue?", { "y": "Yes, continue", "n": "No, cancel", })

yes_no()

Simple binary confirmation.

main.py
ok = yes_no("Delete this file?") # Press y → True, n → False

autocomplete()

Inline dropdown with arrow-key navigation over a list you provide. It's a pure UI component — filtering/search is up to the caller.

main.py
selected = autocomplete(["agent.py", "main.py", "utils.py"], max_visible=5) # Arrow keys to navigate, Enter to select # Returns the chosen string, or None if cancelled (Esc)

Pair it with connectonion.tui.Input for a text field with built-in @-triggered file autocomplete.

Keyboard Controls

KeyAction
↑/↓Navigate options (pick, autocomplete)
1-9 / lettersQuick select by key (pick, list or dict options)
EnterConfirm selection
EscCancel (autocomplete only — pick() has no Esc handler, use Ctrl+C)
Ctrl+C / Ctrl+DCancel with KeyboardInterrupt (pick, yes_no)
y / nAnswer directly (yes_no)

Customizing

Need to modify terminal utilities? Copy the source to your project:

code
co copy terminal

Then import from your local copy:

main.py
# from connectonion import pick, yes_no # Before from tools.terminal import pick, yes_no # After - customize freely!

Star us on GitHub

If ConnectOnion saves you time, a ⭐ goes a long way — and earns you a coffee chat with our founder.