A terminal-based Python notebook editor that brings Jupyter-style interactive coding to your command line with intelligent autocomplete for Python, SQL, and more.
Sage lets you write and execute Python code in cells, just like Jupyter notebooks, but entirely in your terminal. Work with the speed and efficiency of a text editor while getting the interactivity of a notebook environment, complete with context-aware autocomplete that understands your code.
-
Context-aware SQL autocomplete: Get table, column, and function suggestions when typing SQL queries
- Automatically activates inside
db.sql("..."),spark.sql("..."), and similar functions - Works with DuckDB and Spark SQL
- Supports f-strings:
db.sql(f"SELECT {var} FROM ...") - Dynamically updates as you create new tables
- Case-insensitive matching with 80+ SQL keywords
- Automatically activates inside
-
Method chain completion: Smart suggestions for chained methods
- Type-aware:
df.groupby(...).agg(...)shows relevant methods - Works with DuckDB relations:
db.sql("...").pl()suggests.pl(),.show(), etc.
- Type-aware:
-
Python autocomplete: Keywords, built-ins, and your defined variables
- Introspects your namespace in real-time
- Suggests module attributes and methods
- Cell-based execution: Organize code with optional
##--delimiters (titled by the text after the marker) - Live output display: View execution results in a dedicated pane
- Multiple kernels: Connect to different Python environments
- Execution state tracking: See cell history and outputs
- No delimiters required: Works with plain Python files too
- Syntax highlighting: Python code with clear visual structure
- Bracket matching: Highlights matching brackets and parentheses
- Find and replace: Search with regex support
- Undo/redo: Full edit history
- Multiple selection modes: Word, line, or custom selections
- Smart indentation: Tab/Shift+Tab for blocks
- Mouse support: Click, drag, scroll - works like a GUI editor
- System clipboard: Copy/paste between applications
- Auto-save indicators: Always know your save status
- Word-level navigation: Ctrl+Arrow keys to jump between words
- Output pane navigation: Scroll through long outputs easily
- Interactive mode: Edit and execute cells in a live session
- Headless execution: Run notebooks from the command line
- Error handling: Clear tracebacks, stops on errors
- Output persistence: Results stay visible until cleared
cargo build --release
./target/release/sagesage myfile.py # Open existing file or create new
sage # Start with empty fileExecute without opening the editor:
sage --execute myfile.py
sage --execute myfile.py --python /path/to/python3Autocomplete automatically shows:
- Tables:
users,orders, etc. - Columns: Both qualified (
users.name) and unqualified (name) - SQL Keywords:
SELECT,FROM,WHERE,JOIN,GROUP BY, etc. - Functions:
COUNT,SUM,AVG, database-specific functions
Ctrl+S: Save fileCtrl+Q: Quit
Ctrl+Z: UndoCtrl+C: CopyCtrl+X: CutCtrl+V: PasteCtrl+A: Select allCtrl+Backspace: Delete word backwardTab: Indent selection (or autocomplete)Shift+Tab: Unindent selection
- Arrow keys: Move cursor
Ctrl+Left/Right: Move by wordCtrl+Home/End: Jump to start/end of filePage Up/Down: Scroll viewportShift+Page Up/Down: Scroll output pane
Ctrl+F: FindCtrl+H: Find and replaceCtrl+Shift+F: Find nextCtrl+Shift+H: Find previous
Ctrl+E: Execute current cellCtrl+K: Select/change Python kernelCtrl+L: Clear cell outputsCtrl+O: Toggle focus (editor β output pane)
- Left click: Position cursor
- Click and drag: Select text
- Double click: Select word (highlights all occurrences)
- Triple click: Select line
- Scroll wheel: Scroll viewport
Cells let you organize code into logical sections. Use ##-- as a delimiter.
Any text after the marker becomes the cell's title in the output pane:
##-- Cell1: import libraries
import pandas as pd
import duckdb as db
##-- Cell 2: Load data
df = pd.read_csv("data.csv")
db.register("data", df)
##-- Cell 3: Query with SQL autocomplete
result = db.sql("SELECT * FROM data WHERE amount > 100")
result.pl() # Method chain autocomplete works here!Pro tip: Cell delimiters are optional! Without them, the entire file runs as one cell.
In SQL mode, statements are split on semicolons, and a leading --## <title>
comment titles that statement's output the same way.
Sage auto-discovers Python interpreters. Press Ctrl+K to:
- View available Python environments
- Switch between Python versions
- Connect to virtual environments
Specify a kernel via shebang:
#!/usr/bin/env python3Or use the --python flag in headless mode.
import duckdb as db
# Module usage (default connection)
db.sql("SELECT * FROM table")
# Explicit connection
conn = duckdb.connect("mydb.duckdb")
conn.sql("SELECT * FROM table")from pyspark.sql import SparkSession
spark = SparkSession.builder.appName("app").getOrCreate()
spark.sql("SELECT * FROM table")Autocomplete works automatically with both! Create tables dynamically and they'll appear in suggestions immediately.
- Double-click any word to highlight all occurrences
- Ctrl+O switches focus to the output pane for scrolling long results
- Ctrl+L clears outputs for a fresh start
- Esc cancels dialogs and operations
- SQL autocomplete is case-insensitive: type
selβ getSELECT - Use method chains with confidence:
.sql(...).pl()knows what methods are available - No delimiters needed: Just write Python and execute with Ctrl+E
Sage aims to combine:
- π The speed of terminal-based editing
- π The interactivity of Jupyter notebooks
- π§ The intelligence of modern IDEs
- π― The simplicity of Python scripts
Perfect for data science, SQL exploration, quick experiments, and interactive development.
MIT License - see LICENSE file for details.