TSHTS - Terminal Spreadsheet
May 18, 2026 ยท View on GitHub
An efficient, lightweight terminal-based spreadsheet application built in Rust. TSHTS brings the power of spreadsheet calculations to your command line with an intuitive interface, comprehensive formula support, and robust data management capabilities.

๐ Quick Start
Installation
# Clone the repository
git clone https://github.com/SamuelSchlesinger/tshts.git
cd tshts
# Build and run
cargo run --release
# Or build for installation
cargo build --release
# Binary will be available at target/release/tshts
First Steps
TSHTS uses vim-style modes. The status bar shows your current mode
(-- NORMAL --, -- INSERT --, -- VISUAL --, etc.).
- Navigate: Arrow keys or
hjklmove between cells. Counts work:5j,10G. - Edit:
i/a/I/A/s/Enterenter Insert mode.o/Oopen a new row. - Formula: Start with
=for formulas (e.g.,=A1+B1,=SUM(A1:A10)) - Visual:
v(cells),V(whole row),Ctrl+V(block). Thenyyank /ddelete /cchange /ppaste. - Save/Quit:
Ctrl+Ssaves;:w/:wq/:q!work from the command palette (:). - Export/Import:
Ctrl+E(CSV export),Ctrl+L(CSV import), or:export <file>/:import <file>. - Search:
/searches across cells and formulas;n/Ncycle results. - Help:
F1or?opens help. Press0to jump to Vim Mode reference;/searches help.
โจ Key Features
๐งฎ Powerful Formula Engine
- Multi-Type System: numbers, strings, booleans, and list (range) values
- Arithmetic:
+,-,*,/,**/^(power),%(modulo) - String Operations:
&(concatenation), string literals with"quotes" - Comparison Operators:
<,>,<=,>=,=,<> - Numeric Functions:
SUM,AVERAGE,MIN,MAX,ABS,SQRT,ROUND,CEILING,FLOOR,INT,MOD,POWER,SIGN,LOG,LN,EXP,PI,RAND,RANDBETWEEN - Conditional Aggregates:
SUMIF,COUNTIF,AVERAGEIF(">5", wildcards) - Lookup:
VLOOKUP,INDEX,MATCH - String Functions:
CONCAT,LEN,UPPER,LOWER,PROPER,TRIM,LEFT,RIGHT,MID,FIND,SUBSTITUTE,REPLACE,REPT,EXACT,CLEAN,CHAR,CODE,TEXT,VALUE,NUMBERVALUE - Date Functions:
TODAY,NOW,DATE,YEAR,MONTH,DAY(Excel serial-day numbers) - Web Functions:
GET(url)โ non-blocking, cached for 5 min; first call returns "Loadingโฆ" and the cell auto-refreshes when the background fetch completes - Logical Functions:
IF,AND,OR,NOT,TRUE,FALSE - Info Functions:
ISBLANK,ISNUMBER,ISTEXT,TYPE,COUNT,COUNTA - Visualization:
SPARKLINE(range)โ unicode bar chart - Cell References:
A1,AA123โ and absolute markers$A\$1,$A1,A\$1 - Range Support:
A1:C3for any range-aware function - Circular Reference Detection: AST-based, prevents infinite loops
- Undo/Redo: 1000-action history with
Ctrl+Z/Ctrl+Y - Range Selection:
Shift+Arrowkeys - Autofill:
Ctrl+Dโ copies formulas with relative-ref adjustment, preserving$-anchored parts
๐ Smart Interface
- Auto-sizing Columns: Columns automatically adjust to content width
- Manual Resize: Use
+for all columns,-/_for individual column adjustment - Scrolling Viewport: Navigate large spreadsheets smoothly with automatic cursor tracking
- Visual Selection: Clear indication of current cell with range selection support
- Status Messages: Real-time feedback for operations and file status
- Search Highlighting: Visual highlighting of search results with navigation
- Multiple View Modes: Normal, editing, help, file operations, and search modes
๐พ File Management
- Native Format: Human-readable
.tshtsfiles in JSON format - Save/Load:
Ctrl+Sto save,Ctrl+Oto load spreadsheet files - CSV Support:
Ctrl+Eto export CSV,Ctrl+I/Ctrl+Lto import CSV - Dependency Tracking: Automatic rebuilding of formula dependencies on load
- Error Handling: Graceful handling of file operations with clear error messages
- Data Integrity: Preserves formulas, values, column widths, and sheet dimensions
๐ฏ Why Choose TSHTS?
Performance: Built in Rust for excellent performance and memory efficiency. Handles large spreadsheets smoothly in terminal environments.
Portability: Cross-platform support (Linux, macOS, Windows) with no GUI dependencies. Perfect for servers, remote work, and headless environments.
Developer-Friendly: Clean architecture following domain-driven design principles. Comprehensive documentation, extensive test coverage, and modular structure make it easy to extend.
Modern Workflow: Git-friendly JSON format, command-line integration, and automation support. Works seamlessly with CI/CD pipelines and version control.
Rich Feature Set: Advanced formula engine with web functions (GET), string manipulation, logical operations, and mathematical functions. Real-time search, undo/redo, and smart autofill capabilities.
Current Capabilities
TSHTS provides a comprehensive spreadsheet experience with:
- โ Formula Engine: Multi-type evaluation (numbers and strings) with 30+ operators and functions
- โ Data Types: Full support for strings, numbers, formulas, and mixed-type operations
- โ
Web Integration:
GETfunction for fetching data from URLs and APIs - โ
String Processing: Comprehensive text manipulation with
UPPER,LOWER,TRIM,FIND,MID, etc. - โ
Mathematical Functions:
SUM,AVERAGE,MIN,MAX,ABS,SQRT,ROUND, and more - โ
Logical Operations:
IF,AND,OR,NOTwith full boolean logic support - โ
Range Operations: Support for cell ranges (
A1:C3) in all applicable functions - โ
File Operations: Native
.tshtsformat and CSV import/export - โ Smart UI: Responsive terminal interface with multiple interaction modes
- โ Search System: Full-text search across cell values and formulas
- โ Undo/Redo: Complete action history with unlimited undo levels
- โ Selection Tools: Range selection and autofill with relative reference adjustment
- โ Error Handling: Circular reference detection and comprehensive error reporting
Roadmap & Contributing
Upcoming features:
- ๐ Charts & Visualization: Basic terminal-based charts (a SPARKLINE function already exists)
- ๐ Excel format support (CSV is shipped)
- ๐ Scripting: Lua/Python integration for custom functions
- ๐ Collaboration: Real-time sharing capabilities
- ๐ Plugins: Extension system for custom functionality
- ๐
Named ranges in formulas,
INDIRECT/OFFSET, conditional formatting, multi-columnVLOOKUP,DATEDIF
Want to contribute? Check our issues for good first contributions. We welcome:
- Bug reports and feature requests
- Documentation improvements
- Performance optimizations
- New formula functions
- Platform-specific enhancements
๐ Comprehensive Formula Reference
TSHTS supports a powerful multi-type formula system that handles both numbers and strings seamlessly.
๐ข Numeric Operations
Basic Arithmetic
=2+3 โ 5
=10-4 โ 6
=A1*B1 โ Multiplies values in A1 and B1
=15/3 โ 5
=2**3 โ 8 (2 to the power of 3)
=10%3 โ 1 (10 modulo 3)
Numeric Functions
=SUM(A1,B1,C1) โ Sum of individual cells
=SUM(A1:A10) โ Sum of range A1 through A10
=AVERAGE(A1:A10) โ Average of range
=MIN(A1:C3) โ Minimum value in range
=MAX(A1:C3) โ Maximum value in range
=ABS(-5) โ 5 (absolute value)
=SQRT(16) โ 4 (square root)
=ROUND(3.14159) โ 3 (round to integer)
=ROUND(3.14159, 2) โ 3.14 (round to 2 decimal places)
๐ค String Operations
String Literals and Concatenation
="Hello World" โ Hello World
="" โ (empty string)
="Hello" & " " & "World" โ Hello World
="Number: " & 42 โ Number: 42
="Result: " & (2+3) โ Result: 5
String Functions
=LEN("Hello") โ 5 (string length)
=UPPER("hello") โ HELLO (convert to uppercase)
=LOWER("WORLD") โ world (convert to lowercase)
=TRIM(" spaces ") โ spaces (remove leading/trailing spaces)
String Extraction (0-based indexing)
=LEFT("Hello World", 5) โ Hello (first 5 characters)
=RIGHT("Hello World", 5) โ World (last 5 characters)
=MID("Hello World", 6, 5) โ World (5 chars starting at position 6)
=FIND("lo", "Hello") โ 3 (position of "lo" in "Hello")
=FIND("World", "Hello World") โ 6 (position of "World")
Advanced String Operations
=CONCAT("A", "B", "C") โ ABC (concatenate multiple values)
=CONCAT("Number: ", 123) โ Number: 123
=FIND("text", A1, 3) โ Find "text" in A1 starting from position 3
๐ Web Functions
=GET("https://api.example.com/data") โ Fetch raw content from API
=GET("https://jsonplaceholder.typicode.com/posts/1") โ Get JSON data
=GET("https://raw.githubusercontent.com/user/repo/main/data.csv") โ Fetch CSV
=LEN(GET("https://example.com")) โ Get length of web content
=UPPER(GET("https://api.service.com")) โ Convert fetched content to uppercase
๐ Comparisons (Work with Numbers and Strings)
=5<10 โ 1 (true)
=A1>=B1 โ 1 if A1 โฅ B1, 0 otherwise
="Hello"="Hello" โ 1 (string equality)
="Hello"<>"World" โ 1 (string inequality)
=A1<>B1 โ 1 if values are different
๐ง Logical Functions
=IF(A1>10, "High", "Low") โ Conditional with string results
=IF(A1="Hello", "Found", "Not Found") โ String condition
=AND(A1>0, B1<10) โ 1 if both conditions true
=OR(A1=0, B1=0) โ 1 if either condition true
=NOT(A1>5) โ 1 if A1 โค 5
๐ Cell References and Ranges
=A1 โ Value from cell A1 (auto-detects number vs string)
=A1+B1 โ Sum if numeric, concatenation if mixed types
=SUM(A1:A10) โ Sum of range A1 through A10
=AVERAGE(B1:B5) โ Average of range B1 through B5
=CONCAT(A1:A3) โ Concatenate all values in range A1:A3
๐ Type Conversion
TSHTS automatically handles type conversion:
- Numeric operations: Strings are converted to numbers (empty/invalid = 0)
- String operations: Numbers are converted to strings
- Comparisons: Like types compared directly, mixed types compared as strings
- Cell values: Auto-detected based on content
๐ Formula Examples
Data Processing
=UPPER(A1) & " - " & LOWER(B1) โ Combine formatted strings
=IF(LEN(A1)>0, A1, "Empty") โ Check for non-empty strings
=LEFT(A1, FIND(" ", A1)-1) โ Extract first word
=MID(A1, FIND(" ", A1)+1, LEN(A1)) โ Extract everything after first space
Data Validation
=IF(AND(LEN(A1)>3, A1<>""), "Valid", "Invalid") โ Validate string length
=IF(OR(A1="", A1="N/A"), "Missing", A1) โ Handle missing data
Complex Calculations
=SUM(A1:A10) & " total items" โ Numeric result with description
=IF(AVERAGE(A1:A10)>50, "PASS", "FAIL") โ Grade based on average
=CONCAT("Hello ", A1, ", you scored ", B1, "%") โ Dynamic messages
โ ๏ธ Important Notes
- String Indexing: All string functions use 0-based indexing (FIND, MID, etc.)
- Case Sensitivity: String comparisons are case-sensitive
- Error Handling: Invalid operations return
#ERROR - Empty Strings:
""is considered different from empty cells - Quotes in Strings: Use double quotes to escape:
"Quote""Test"โQuote"Test
โจ๏ธ Keyboard Shortcuts
Navigation
- Arrow Keys / hjkl: Move cell selection
- Page Up/Down: Fast scrolling
- Home: Jump to cell A1
Editing
- Enter / F2: Start editing current cell
- Esc: Cancel editing
- Enter: Confirm editing
File Operations
- Ctrl+S: Save in place (Save As if no filename yet)
- Ctrl+O: Load spreadsheet (prompts if dirty)
- Ctrl+L: Import CSV (prompts if dirty)
- Ctrl+E: Export CSV
- q: Quit (prompts if dirty)
- Command line:
tshts foo.tshtsopens at startup
Search & Replace
- /: Live search;
n/Nfor next / previous - Ctrl+R: Find and replace (was Ctrl+H โ Ctrl+H is Backspace in many terminals)
:regex on,:case on: search-option toggles
View
- F1 / ?: Show/hide help
- =: Auto-resize current column
- +: Auto-resize all columns
- - / _: Manually adjust column width
๐ง Configuration
TSHTS uses sensible defaults but can be customized:
Default Settings
- Grid Size: 100 rows ร 26 columns
- Column Width: 8 characters (auto-adjusting)
- File Format: JSON (.tshts extension)
- Default Filename:
spreadsheet.tshts
File Format
TSHTS saves files in a clean JSON format that's both human-readable and version-control friendly:
{
"cells": [
[0, 0, {"value": "Hello", "formula": null}],
[1, 1, {"value": "42", "formula": "=6*7"}]
],
"rows": 100,
"cols": 26,
"column_widths": {"0": 15},
"default_column_width": 8
}
๐๏ธ Architecture
TSHTS follows clean architecture and domain-driven design principles:
src/
โโโ domain/ # Core business logic (no external dependencies)
โ โโโ models.rs # Data structures (Spreadsheet, CellData)
โ โโโ services.rs # Formula evaluation engine and CSV operations
โ โโโ parser.rs # Expression parser with formal BNF grammar
โโโ application/ # Application orchestration
โ โโโ state.rs # App state, modes, and business workflows
โโโ infrastructure/ # External integrations
โ โโโ persistence.rs # File I/O operations and serialization
โโโ presentation/ # User interface layer
โ โโโ ui.rs # Terminal rendering with ratatui
โ โโโ input.rs # Keyboard input handling and event processing
โโโ lib.rs # Library interface
โโโ main.rs # Application entry point
Design Benefits
This modular architecture provides:
- Testable: Each layer has comprehensive unit and integration tests
- Maintainable: Clear separation of concerns with well-defined interfaces
- Extensible: Easy to add new functions, operators, and features
- Portable: Domain logic is UI-framework independent
- Type-Safe: Leverages Rust's type system for reliability
- Documentation: Extensive rustdoc comments throughout the codebase
๐งช Testing
TSHTS has comprehensive test coverage:
# Run all tests
cargo test
# Run with coverage
cargo test --release
# Run specific test modules
cargo test domain::
cargo test formula_evaluator
Test categories:
- Unit Tests: Individual component functionality
- Integration Tests: File I/O and persistence
- Formula Tests: Expression evaluation correctness
- UI Tests: Application state management
๐ System Requirements
- Operating System: Linux, macOS, Windows (anywhere Rust runs)
- Terminal: Any terminal with ANSI color and cursor support
- Rust: 1.70+ with 2024 edition support (for building from source)
- Memory: Minimal footprint (~10MB typical usage)
- Storage: Lightweight JSON files (typically <1MB for large sheets)
- Dependencies: Pure Rust implementation with minimal external dependencies
๐ค Getting Help
- In-App Help: Press
F1or?for comprehensive help with scrollable documentation - Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: This README and extensive rustdoc documentation (
cargo doc --open) - Examples: Sample
.tshtsfiles and formula examples in the repository
๐ License
MIT License - see LICENSE file for details.
๐ Acknowledgments
Built with:
- Ratatui - Terminal UI framework
- Crossterm - Cross-platform terminal manipulation
- Serde - Serialization framework
Special thanks to the Rust community for creating an ecosystem that makes building fast, reliable terminal applications a joy.
Ready to supercharge your terminal workflow? Give TSHTS a try and experience the power of spreadsheets without leaving your command line!