sheets-terminal-spreadsheet
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSheets 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@mainbash
go install github.com/maaslalani/sheets@mainDownload Binary
下载二进制文件
Download a prebuilt binary from GitHub Releases.
从 GitHub Releases 下载预编译的二进制文件。
Verify Installation
验证安装
bash
sheets --helpbash
sheets --helpCLI Usage
CLI使用说明
Launch the TUI
启动TUI
bash
sheets budget.csvbash
sheets budget.csvRead 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 | sheetsbash
sheets <<< "ID,Name,Age
1,Alice,24
2,Bob,32
3,Charlie,26"或者从其他命令管道传入:
bash
cat data.csv | sheetsRead a Specific Cell
读取指定单元格
bash
sheets budget.csv B9bash
sheets budget.csv B9Output: 2760
输出: 2760
undefinedundefinedRead a Cell Range
读取单元格范围
bash
sheets budget.csv B1:B3bash
sheets budget.csv B1:B3Output:
输出:
1200
1200
950
950
810
810
undefinedundefinedModify Cells (Non-Interactive)
非交互式修改单元格
bash
undefinedbash
undefinedSet 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
基础移动
| Key | Action |
|---|---|
| Move left, down, up, right |
| Jump to top |
| Jump to bottom |
| Jump to row 5 |
| Jump to cell B9 |
| Jump to first column |
| Jump to first non-empty column in row |
| Jump to last non-empty column in row |
| Jump to top / middle / bottom visible row |
| Move half page up / down |
| 按键 | 操作 |
|---|---|
| 向左、向下、向上、向右移动 |
| 跳转到顶部 |
| 跳转到底部 |
| 跳转到第5行 |
| 跳转到B9单元格 |
| 跳转到第一列 |
| 跳转到当前行第一个非空列 |
| 跳转到当前行最后一个非空列 |
| 跳转到可见区域的顶部/中部/底部行 |
| 向上/向下移动半页 |
View Alignment
视图对齐
| Key | Action |
|---|---|
| Align current row to top of window |
| Align current row to middle of window |
| Align current row to bottom of window |
| 按键 | 操作 |
|---|---|
| 将当前行对齐到窗口顶部 |
| 将当前行对齐到窗口中部 |
| 将当前行对齐到窗口底部 |
Search
搜索
| Key | Action |
|---|---|
| Search forward |
| Search backward |
| Repeat last search (forward) |
| Repeat last search (backward) |
| 按键 | 操作 |
|---|---|
| 向前搜索 |
| 向后搜索 |
| 重复上一次搜索(向前) |
| 重复上一次搜索(向后) |
Marks & Jump List
标记与跳转列表
| Key | Action |
|---|---|
| Set mark |
| Jump to mark |
| Move backward through jump list |
| Move forward through jump list |
| 按键 | 操作 |
|---|---|
| 在当前单元格设置标记 |
| 跳转到标记 |
| 在跳转列表中回退 |
| 在跳转列表中前进 |
Editing Keybindings
编辑快捷键
Insert Mode
插入模式
| Key | Action |
|---|---|
| Edit current cell |
| Edit from start of cell |
| Clear cell and start editing |
| Leave insert / visual / command mode |
| Commit and move down |
| Commit and move right |
| Commit and move left |
| Commit and move down |
| Commit and move up |
| 按键 | 操作 |
|---|---|
| 编辑当前单元格 |
| 从单元格起始位置开始编辑 |
| 清空单元格后进入编辑 |
| 退出插入/可视化/命令模式 |
| 提交修改并向下移动 |
| 提交修改并向右移动 |
| 提交修改并向左移动 |
| 提交修改并向下移动 |
| 提交修改并向上移动 |
Row Operations
行操作
| Key | Action |
|---|---|
| Insert row below and start editing |
| Insert row above and start editing |
| Delete current row |
| 按键 | 操作 |
|---|---|
| 在下方插入行并进入编辑 |
| 在上方插入行并进入编辑 |
| 删除当前行 |
Copy / Cut / Paste
复制/剪切/粘贴
| Key | Action |
|---|---|
| Yank (copy) current cell |
| Yank current row(s) |
| Cut current cell or selection |
| Paste current register |
| 按键 | 操作 |
|---|---|
| 复制当前单元格 |
| 复制当前行 |
| 剪切当前单元格或选中内容 |
| 粘贴当前寄存器内容 |
Undo / Redo
撤销/重做
| Key | Action |
|---|---|
| Undo |
| Redo |
| Undo all changes |
| Repeat last change |
| 按键 | 操作 |
|---|---|
| 撤销 |
| 重做 |
| 撤销所有修改 |
| 重复上一次修改 |
Visual Mode
可视化模式
Enter visual mode with (cell selection) or (row selection).
vV| Key | Action |
|---|---|
| Start visual cell selection |
| Start visual row selection |
| Insert formula after selected range (e.g., |
按(单元格选择)或(行选择)进入可视化模式。
vV| 按键 | 操作 |
|---|---|
| 启动单元格可视化选择 |
| 启动行可视化选择 |
| 在选中范围后插入公式(例如 |
Command Mode
命令模式
Press to open the command prompt.
:| Command | Action |
|---|---|
| Save file |
| Save to a new file |
| Open another CSV file |
| Quit |
| Save and quit |
| Jump to cell B9 |
| Jump to cell B9 (shorthand) |
按打开命令提示符。
:| 命令 | 操作 |
|---|---|
| 保存文件 |
| 保存为新文件 |
| 打开另一个CSV文件 |
| 退出 |
| 保存并退出 |
| 跳转到B9单元格 |
| 跳转到B9单元格(简写) |
Common Patterns
常用使用场景
Create a New CSV and Edit It
新建CSV并编辑
bash
undefinedbash
undefinedCreate a CSV with headers
创建带表头的CSV
echo "Name,Amount,Category" > budget.csv
sheets budget.csv
undefinedecho "Name,Amount,Category" > budget.csv
sheets budget.csv
undefinedPipe CSV Data and Edit
管道传入CSV数据并编辑
bash
undefinedbash
undefinedGenerate CSV from a database query and edit in sheets
从数据库查询生成CSV并在sheets中编辑
psql -c "COPY (SELECT * FROM sales) TO STDOUT WITH CSV HEADER" | sheets
undefinedpsql -c "COPY (SELECT * FROM sales) TO STDOUT WITH CSV HEADER" | sheets
undefinedScript: Update a Cell Programmatically
脚本:程序化更新单元格
bash
#!/bin/bashbash
#!/bin/bashUpdate Q4 value in financial report
更新财务报告中的Q4数值
sheets report.csv D4=95000 D5=102000 D6=88000
echo "Updated Q4 values in report.csv"
undefinedsheets report.csv D4=95000 D5=102000 D6=88000
echo "已更新report.csv中的Q4数值"
undefinedScript: Extract a Range for Processing
脚本:提取范围数据用于处理
bash
#!/bin/bashbash
#!/bin/bashExtract 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"
undefinedvalues=$(sheets data.csv B1:B10)
total=0
while IFS= read -r line; do
total=$((total + line))
done <<< "$values"
echo "总和: $total"
undefinedScript: Read a Specific Cell in a Shell Script
脚本:在Shell脚本中读取指定单元格
bash
#!/bin/bashbash
#!/bin/bashGet current budget total from spreadsheet
从电子表格获取当前预算总额
budget_total=$(sheets budget.csv C15)
if [ "$budget_total" -gt 10000 ]; then
echo "Budget exceeded!"
fi
undefinedbudget_total=$(sheets budget.csv C15)
if [ "$budget_total" -gt 10000 ]; then
echo "预算超支!"
fi
undefinedGo 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
undefinedInstead 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
undefinedsheets data.csv B3=new_value
undefinedFormula Insertion Workflow
公式插入流程
- Navigate to the column where you want the formula
- Enter visual mode with
v - Select the range (e.g., B1:B8)
- Press to insert formula after the selection:
==|(B1:B8)
- 导航到你要插入公式的列
- 按进入可视化模式
v - 选择范围(例如B1:B8)
- 按在选中范围后插入公式:
==|(B1:B8)
Efficient Navigation (Vim Users)
高效导航(Vim用户)
Sheets uses vim-style navigation — users familiar with vim can be productive immediately:
- /
ggfor top/bottomG - for movement
hjkl - /
ifor insert modesc - to delete rows
dd - /
ufor undo/redoctrl+r - for search
/
Sheets使用vim风格的导航,熟悉vim的用户可以立刻上手:
- /
gg跳转到顶部/底部G - 移动光标
hjkl - /
i进入插入模式c - 删除行
dd - /
u撤销/重做ctrl+r - 搜索
/
Troubleshooting
故障排查
sheets
command not found
sheets找不到sheets
命令
sheetsbash
undefinedbash
undefinedEnsure 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
undefinedgo install github.com/maaslalani/sheets@main
which sheets
undefinedFile Not Saved After Editing
编辑后文件未保存
Use in command mode to save, or to save and quit. Just pressing or quits without saving.
:w:wqqctrl+c在命令模式使用保存,或保存并退出。仅按或会不保存直接退出。
:w:wqqctrl+cTUI 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 environment variable:
TERMecho $TERM
Sheets依赖终端能力,如果显示异常:
- 确认你的终端支持256色或真彩色
- 尝试其他终端模拟器(iTerm2、Alacritty、Ghostty、WezTerm)
- 检查环境变量:
TERMecho $TERM
Reading Non-CSV Files
读取非CSV文件
Sheets is designed for CSV format. Convert other formats first:
bash
undefinedSheets专为CSV格式设计,请先转换其他格式:
bash
undefinedExcel 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
undefinedpython3 -c "import pandas as pd; pd.read_excel('data.xlsx').to_csv('data.csv', index=False)"
sheets data.csv
undefinedLarge Files Performance
大文件性能优化
For very large CSV files, navigate directly to specific cells rather than scrolling:
:goto A1000or press to jump to row 5 directly.
5G对于非常大的CSV文件,直接跳转到指定单元格而非滚动:
:goto A1000或者按直接跳转到第5行。
5G