Sheets Terminal Spreadsheet

作者 reason-machines2384a003145a无许可证83 个星标收录于 2026年10月8日更新于 2026年10月8日仓库3个月前更新

Terminal-based spreadsheet TUI tool written in Go for editing CSV files in the terminal with vim-like keybindings

仅含说明Documents & Office
AI 生成的概览

Sheets 终端电子表格 TUI 的参考指南,涵盖安装、vim 风格快捷键以及 CSV 单元格读写命令。

功能
该技能介绍 Sheets 终端电子表格 TUI,这是一个用 Go 编写、用于在终端中查看和编辑 CSV 文件的程序。内容包括安装步骤、读取单元格与区域的命令行用法、非交互式单元格修改、导航与编辑快捷键、可视模式与命令模式,以及故障排查说明。还提供 shell 与 Go 代码片段,演示如何在脚本中调用该工具。
适用场景
适用于用户希望在终端中查看或编辑 CSV 文件、需要 vim 风格的电子表格导航,或想从命令行读取、设置特定单元格的场景。也适合编写脚本提取或更新 CSV 单元格。
运行要求
需要 Sheets 可执行文件(通过 Go 安装或下载预编译版本),以及支持 256 色或真彩色的终端。该技能不附带脚本,仅为说明文档。

Sheets Terminal Spreadsheet

Skill by ara.so — Daily 2026 Skills collection.

Sheets is a terminal-based spreadsheet TUI (Terminal User Interface) for viewing and editing CSV files directly in your terminal. It features vim-style navigation, formula support, visual selection, search, undo/redo, and a command mode — all without leaving the terminal.


Installation

Using Go

bash
go install github.com/maaslalani/sheets@main

Download Binary

Download a prebuilt binary from GitHub Releases.

Verify Installation

bash
sheets --help

CLI Usage

Launch the TUI

bash
sheets budget.csv

Read from stdin

bash
sheets <<< "ID,Name,Age1,Alice,242,Bob,323,Charlie,26"

Or pipe from another command:

bash
cat data.csv | sheets

Read a Specific Cell

bash
sheets budget.csv B9# Output: 2760

Read a Cell Range

bash
sheets budget.csv B1:B3# Output:# 1200# 950# 810

Modify Cells (Non-Interactive)

bash
# Set one cellsheets budget.csv B7=10
# Set multiple cellssheets budget.csv B7=10 B8=20

Navigation Keybindings

Basic Movement

KeyAction
h, j, k, lMove left, down, up, right
ggJump to top
GJump to bottom
5GJump to row 5
gB9Jump to cell B9
0Jump to first column
^Jump to first non-empty column in row
$Jump to last non-empty column in row
H / M / LJump to top / middle / bottom visible row
ctrl+u / ctrl+dMove half page up / down

View Alignment

KeyAction
ztAlign current row to top of window
zzAlign current row to middle of window
zbAlign current row to bottom of window

Search

KeyAction
/Search forward
?Search backward
nRepeat last search (forward)
NRepeat last search (backward)

Marks & Jump List

KeyAction
maSet mark a at current cell
'aJump to mark a
ctrl+oMove backward through jump list
ctrl+iMove forward through jump list

Editing Keybindings

Insert Mode

KeyAction
iEdit current cell
IEdit from start of cell
cClear cell and start editing
ESCLeave insert / visual / command mode
enterCommit and move down
tabCommit and move right
shift+tabCommit and move left
ctrl+nCommit and move down
ctrl+pCommit and move up

Row Operations

KeyAction
oInsert row below and start editing
OInsert row above and start editing
ddDelete current row

Copy / Cut / Paste

KeyAction
yYank (copy) current cell
yyYank current row(s)
xCut current cell or selection
pPaste current register

Undo / Redo

KeyAction
uUndo
ctrl+rRedo
UUndo all changes
.Repeat last change

Visual Mode

Enter visual mode with v (cell selection) or V (row selection).

KeyAction
vStart visual cell selection
VStart visual row selection
=Insert formula after selected range (e.g., =|(B1:B8))

Command Mode

Press : to open the command prompt.

CommandAction
:wSave file
:w path.csvSave to a new file
:e path.csvOpen another CSV file
:qQuit
:wqSave and quit
:goto B9Jump to cell B9
:B9Jump to cell B9 (shorthand)

Common Patterns

Create a New CSV and Edit It

bash
# Create a CSV with headersecho "Name,Amount,Category" > budget.csvsheets budget.csv

Pipe CSV Data and Edit

bash
# Generate CSV from a database query and edit in sheetspsql -c "COPY (SELECT * FROM sales) TO STDOUT WITH CSV HEADER" | sheets

Script: Update a Cell Programmatically

bash
#!/bin/bash# Update Q4 value in financial reportsheets report.csv D4=95000 D5=102000 D6=88000echo "Updated Q4 values in report.csv"

Script: Extract a Range for Processing

bash
#!/bin/bash# Extract column B rows 1-10 and sum them in bashvalues=$(sheets data.csv B1:B10)total=0while IFS= read -r line; do    total=$((total + line))done <<< "$values"echo "Total: $total"

Script: Read a Specific Cell in a Shell Script

bash
#!/bin/bash# Get current budget total from spreadsheetbudget_total=$(sheets budget.csv C15)if [ "$budget_total" -gt 10000 ]; then    echo "Budget exceeded!"fi

Go Integration Example

If building a Go application that generates CSV for use with sheets:

go
package main
import (    "encoding/csv"    "fmt"    "os"    "os/exec")
func createAndOpenSpreadsheet(data [][]string, filename string) error {    // Write CSV data    f, err := os.Create(filename)    if err != nil {        return fmt.Errorf("creating file: %w", err)    }    defer f.Close()
    w := csv.NewWriter(f)    if err := w.WriteAll(data); err != nil {        return fmt.Errorf("writing CSV: %w", err)    }    w.Flush()
    // Open in sheets TUI    cmd := exec.Command("sheets", filename)    cmd.Stdin = os.Stdin    cmd.Stdout = os.Stdout    cmd.Stderr = os.Stderr    return cmd.Run()}
func main() {    data := [][]string{        {"Month", "Revenue", "Expenses", "Profit"},        {"January", "12000", "8500", "3500"},        {"February", "13500", "9200", "4300"},        {"March", "11800", "8900", "2900"},    }
    if err := createAndOpenSpreadsheet(data, "monthly_report.csv"); err != nil {        fmt.Fprintf(os.Stderr, "Error: %v\n", err)        os.Exit(1)    }}

Go: Read a Cell Non-Interactively

go
package main
import (    "fmt"    "os/exec"    "strings")
func readCell(csvFile, cell string) (string, error) {    out, err := exec.Command("sheets", csvFile, cell).Output()    if err != nil {        return "", fmt.Errorf("reading cell %s: %w", cell, err)    }    return strings.TrimSpace(string(out)), nil}
func readRange(csvFile, cellRange string) ([]string, error) {    out, err := exec.Command("sheets", csvFile, cellRange).Output()    if err != nil {        return nil, fmt.Errorf("reading range %s: %w", cellRange, err)    }    lines := strings.Split(strings.TrimSpace(string(out)), "\n")    return lines, nil}
func main() {    total, err := readCell("budget.csv", "B9")    if err != nil {        fmt.Println("Error:", err)        return    }    fmt.Println("Budget total:", total)
    values, err := readRange("budget.csv", "B1:B6")    if err != nil {        fmt.Println("Error:", err)        return    }    fmt.Println("Monthly values:", values)}

Tips for AI Agents

Suggesting Sheets for CSV Tasks

When a user wants to view or edit CSV files in the terminal, suggest sheets:

bash
# Instead of cat data.csvsheets data.csv
# Instead of awk/sed edits for simple changessheets data.csv B3=new_value

Formula Insertion Workflow

  1. Navigate to the column where you want the formula
  2. Enter visual mode with v
  3. Select the range (e.g., B1:B8)
  4. Press = to insert formula after the selection: =|(B1:B8)

Efficient Navigation (Vim Users)

Sheets uses vim-style navigation — users familiar with vim can be productive immediately:

  • gg/G for top/bottom
  • hjkl for movement
  • i/c for insert modes
  • dd to delete rows
  • u/ctrl+r for undo/redo
  • / for search

Troubleshooting

sheets command not found

bash
# Ensure Go bin directory is in PATHexport PATH=$PATH:$(go env GOPATH)/bin
# Or install again and verifygo install github.com/maaslalani/sheets@mainwhich sheets

File Not Saved After Editing

Use :w in command mode to save, or :wq to save and quit. Just pressing q or ctrl+c quits without saving.

TUI Rendering Issues

Sheets relies on terminal capabilities. If the display looks broken:

  • Ensure your terminal supports 256 colors or truecolor
  • Try a different terminal emulator (iTerm2, Alacritty, Ghostty, WezTerm)
  • Check TERM environment variable: echo $TERM

Reading Non-CSV Files

Sheets is designed for CSV format. Convert other formats first:

bash
# Excel to CSV (using Python)python3 -c "import pandas as pd; pd.read_excel('data.xlsx').to_csv('data.csv', index=False)"sheets data.csv

Large Files Performance

For very large CSV files, navigate directly to specific cells rather than scrolling:

:goto A1000

or press 5G to jump to row 5 directly.

来源与署名

来源:reason-machines/trending-skills位于skills/sheets-terminal-spreadsheet提交2384a00

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架