sheets-terminal-spreadsheet

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Sheets Terminal Spreadsheet

Sheets 终端电子表格

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.

ara.so 开发的Skill — 2026每日技能合集。
Sheets是一款基于终端的电子表格TUI(终端用户界面),可直接在终端中查看和编辑CSV文件。它支持vim风格的导航、公式、可视化选择、搜索、撤销/重做以及命令模式,所有操作都无需离开终端。

Installation

安装

Using Go

使用Go安装

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

Download Binary

下载二进制文件

Download a prebuilt binary from GitHub Releases.
GitHub Releases 下载预编译的二进制文件。

Verify Installation

验证安装

bash
sheets --help

bash
sheets --help

CLI Usage

CLI使用说明

Launch the TUI

启动TUI

bash
sheets budget.csv
bash
sheets budget.csv

Read from stdin

从标准输入读取内容

bash
sheets <<< "ID,Name,Age
1,Alice,24
2,Bob,32
3,Charlie,26"
Or pipe from another command:
bash
cat data.csv | sheets
bash
sheets <<< "ID,Name,Age
1,Alice,24
2,Bob,32
3,Charlie,26"
或者从其他命令管道传入:
bash
cat data.csv | sheets

Read a Specific Cell

读取指定单元格

bash
sheets budget.csv B9
bash
sheets budget.csv B9

Output: 2760

输出: 2760

undefined
undefined

Read a Cell Range

读取单元格范围

bash
sheets budget.csv B1:B3
bash
sheets budget.csv B1:B3

Output:

输出:

1200

1200

950

950

810

810

undefined
undefined

Modify Cells (Non-Interactive)

非交互式修改单元格

bash
undefined
bash
undefined

Set one cell

设置单个单元格

sheets budget.csv B7=10
sheets budget.csv B7=10

Set multiple cells

设置多个单元格

sheets budget.csv B7=10 B8=20

---
sheets budget.csv B7=10 B8=20

---

Navigation Keybindings

导航快捷键

Basic Movement

基础移动

KeyAction
h
,
j
,
k
,
l
Move left, down, up, right
gg
Jump to top
G
Jump to bottom
5G
Jump to row 5
gB9
Jump to cell B9
0
Jump to first column
^
Jump to first non-empty column in row
$
Jump to last non-empty column in row
H
/
M
/
L
Jump to top / middle / bottom visible row
ctrl+u
/
ctrl+d
Move half page up / down
按键操作
h
,
j
,
k
,
l
向左、向下、向上、向右移动
gg
跳转到顶部
G
跳转到底部
5G
跳转到第5行
gB9
跳转到B9单元格
0
跳转到第一列
^
跳转到当前行第一个非空列
$
跳转到当前行最后一个非空列
H
/
M
/
L
跳转到可见区域的顶部/中部/底部行
ctrl+u
/
ctrl+d
向上/向下移动半页

View Alignment

视图对齐

KeyAction
zt
Align current row to top of window
zz
Align current row to middle of window
zb
Align current row to bottom of window
按键操作
zt
将当前行对齐到窗口顶部
zz
将当前行对齐到窗口中部
zb
将当前行对齐到窗口底部

Search

搜索

KeyAction
/
Search forward
?
Search backward
n
Repeat last search (forward)
N
Repeat last search (backward)
按键操作
/
向前搜索
?
向后搜索
n
重复上一次搜索(向前)
N
重复上一次搜索(向后)

Marks & Jump List

标记与跳转列表

KeyAction
ma
Set mark
a
at current cell
'a
Jump to mark
a
ctrl+o
Move backward through jump list
ctrl+i
Move forward through jump list

按键操作
ma
在当前单元格设置标记
a
'a
跳转到标记
a
ctrl+o
在跳转列表中回退
ctrl+i
在跳转列表中前进

Editing Keybindings

编辑快捷键

Insert Mode

插入模式

KeyAction
i
Edit current cell
I
Edit from start of cell
c
Clear cell and start editing
ESC
Leave insert / visual / command mode
enter
Commit and move down
tab
Commit and move right
shift+tab
Commit and move left
ctrl+n
Commit and move down
ctrl+p
Commit and move up
按键操作
i
编辑当前单元格
I
从单元格起始位置开始编辑
c
清空单元格后进入编辑
ESC
退出插入/可视化/命令模式
enter
提交修改并向下移动
tab
提交修改并向右移动
shift+tab
提交修改并向左移动
ctrl+n
提交修改并向下移动
ctrl+p
提交修改并向上移动

Row Operations

行操作

KeyAction
o
Insert row below and start editing
O
Insert row above and start editing
dd
Delete current row
按键操作
o
在下方插入行并进入编辑
O
在上方插入行并进入编辑
dd
删除当前行

Copy / Cut / Paste

复制/剪切/粘贴

KeyAction
y
Yank (copy) current cell
yy
Yank current row(s)
x
Cut current cell or selection
p
Paste current register
按键操作
y
复制当前单元格
yy
复制当前行
x
剪切当前单元格或选中内容
p
粘贴当前寄存器内容

Undo / Redo

撤销/重做

KeyAction
u
Undo
ctrl+r
Redo
U
Undo all changes
.
Repeat last change

按键操作
u
撤销
ctrl+r
重做
U
撤销所有修改
.
重复上一次修改

Visual Mode

可视化模式

Enter visual mode with
v
(cell selection) or
V
(row selection).
KeyAction
v
Start visual cell selection
V
Start visual row selection
=
Insert formula after selected range (e.g.,
=|(B1:B8)
)

v
(单元格选择)或
V
(行选择)进入可视化模式。
按键操作
v
启动单元格可视化选择
V
启动行可视化选择
=
在选中范围后插入公式(例如
=|(B1:B8)

Command Mode

命令模式

Press
:
to open the command prompt.
CommandAction
:w
Save file
:w path.csv
Save to a new file
:e path.csv
Open another CSV file
:q
Quit
:wq
Save and quit
:goto B9
Jump to cell B9
:B9
Jump to cell B9 (shorthand)

:
打开命令提示符。
命令操作
:w
保存文件
:w path.csv
保存为新文件
:e path.csv
打开另一个CSV文件
:q
退出
:wq
保存并退出
:goto B9
跳转到B9单元格
:B9
跳转到B9单元格(简写)

Common Patterns

常用使用场景

Create a New CSV and Edit It

新建CSV并编辑

bash
undefined
bash
undefined

Create a CSV with headers

创建带表头的CSV

echo "Name,Amount,Category" > budget.csv sheets budget.csv
undefined
echo "Name,Amount,Category" > budget.csv sheets budget.csv
undefined

Pipe CSV Data and Edit

管道传入CSV数据并编辑

bash
undefined
bash
undefined

Generate CSV from a database query and edit in sheets

从数据库查询生成CSV并在sheets中编辑

psql -c "COPY (SELECT * FROM sales) TO STDOUT WITH CSV HEADER" | sheets
undefined
psql -c "COPY (SELECT * FROM sales) TO STDOUT WITH CSV HEADER" | sheets
undefined

Script: Update a Cell Programmatically

脚本:程序化更新单元格

bash
#!/bin/bash
bash
#!/bin/bash

Update Q4 value in financial report

更新财务报告中的Q4数值

sheets report.csv D4=95000 D5=102000 D6=88000 echo "Updated Q4 values in report.csv"
undefined
sheets report.csv D4=95000 D5=102000 D6=88000 echo "已更新report.csv中的Q4数值"
undefined

Script: Extract a Range for Processing

脚本:提取范围数据用于处理

bash
#!/bin/bash
bash
#!/bin/bash

Extract column B rows 1-10 and sum them in bash

提取B列1-10行并在bash中求和

values=$(sheets data.csv B1:B10) total=0 while IFS= read -r line; do total=$((total + line)) done <<< "$values" echo "Total: $total"
undefined
values=$(sheets data.csv B1:B10) total=0 while IFS= read -r line; do total=$((total + line)) done <<< "$values" echo "总和: $total"
undefined

Script: Read a Specific Cell in a Shell Script

脚本:在Shell脚本中读取指定单元格

bash
#!/bin/bash
bash
#!/bin/bash

Get current budget total from spreadsheet

从电子表格获取当前预算总额

budget_total=$(sheets budget.csv C15) if [ "$budget_total" -gt 10000 ]; then echo "Budget exceeded!" fi
undefined
budget_total=$(sheets budget.csv C15) if [ "$budget_total" -gt 10000 ]; then echo "预算超支!" fi
undefined

Go Integration Example

Go集成示例

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应用需要生成CSV供sheets使用:
go
package main

import (
    "encoding/csv"
    "fmt"
    "os"
    "os/exec"
)

func createAndOpenSpreadsheet(data [][]string, filename string) error {
    // 写入CSV数据
    f, err := os.Create(filename)
    if err != nil {
        return fmt.Errorf("创建文件失败: %w", err)
    }
    defer f.Close()

    w := csv.NewWriter(f)
    if err := w.WriteAll(data); err != nil {
        return fmt.Errorf("写入CSV失败: %w", err)
    }
    w.Flush()

    // 在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, "错误: %v\n", err)
        os.Exit(1)
    }
}

Go: Read a Cell Non-Interactively

Go:非交互式读取单元格

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)
}

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("读取单元格%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("读取范围%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("错误:", err)
        return
    }
    fmt.Println("预算总额:", total)

    values, err := readRange("budget.csv", "B1:B6")
    if err != nil {
        fmt.Println("错误:", err)
        return
    }
    fmt.Println("月度数值:", values)
}

Tips for AI Agents

给AI Agent的使用提示

Suggesting Sheets for CSV Tasks

为CSV处理任务推荐Sheets

When a user wants to view or edit CSV files in the terminal, suggest sheets:
bash
undefined
当用户需要在终端中查看或编辑CSV文件时,推荐使用sheets:
bash
undefined

Instead of cat data.csv

替代cat data.csv

sheets data.csv
sheets data.csv

Instead of awk/sed edits for simple changes

替代awk/sed做简单修改

sheets data.csv B3=new_value
undefined
sheets data.csv B3=new_value
undefined

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)
  1. 导航到你要插入公式的列
  2. v
    进入可视化模式
  3. 选择范围(例如B1:B8)
  4. =
    在选中范围后插入公式:
    =|(B1:B8)

Efficient Navigation (Vim Users)

高效导航(Vim用户)

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

Sheets使用vim风格的导航,熟悉vim的用户可以立刻上手:
  • gg
    /
    G
    跳转到顶部/底部
  • hjkl
    移动光标
  • i
    /
    c
    进入插入模式
  • dd
    删除行
  • u
    /
    ctrl+r
    撤销/重做
  • /
    搜索

Troubleshooting

故障排查

sheets
command not found

找不到
sheets
命令

bash
undefined
bash
undefined

Ensure Go bin directory is in PATH

确保Go bin目录已加入PATH

export PATH=$PATH:$(go env GOPATH)/bin
export PATH=$PATH:$(go env GOPATH)/bin

Or install again and verify

或者重新安装验证

go install github.com/maaslalani/sheets@main which sheets
undefined
go install github.com/maaslalani/sheets@main which sheets
undefined

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.
在命令模式使用
:w
保存,或
:wq
保存并退出。仅按
q
ctrl+c
不保存直接退出

TUI Rendering Issues

TUI渲染异常

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
Sheets依赖终端能力,如果显示异常:
  • 确认你的终端支持256色或真彩色
  • 尝试其他终端模拟器(iTerm2、Alacritty、Ghostty、WezTerm)
  • 检查
    TERM
    环境变量:
    echo $TERM

Reading Non-CSV Files

读取非CSV文件

Sheets is designed for CSV format. Convert other formats first:
bash
undefined
Sheets专为CSV格式设计,请先转换其他格式:
bash
undefined

Excel to CSV (using Python)

Excel转CSV(使用Python)

python3 -c "import pandas as pd; pd.read_excel('data.xlsx').to_csv('data.csv', index=False)" sheets data.csv
undefined
python3 -c "import pandas as pd; pd.read_excel('data.xlsx').to_csv('data.csv', index=False)" sheets data.csv
undefined

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.
对于非常大的CSV文件,直接跳转到指定单元格而非滚动:
:goto A1000
或者按
5G
直接跳转到第5行。