# Nushell — A New Type of Shell for the Modern Era > Nushell is a new type of shell that treats data as structured tables rather than plain text. Pipelines operate on structured data (tables, records, lists) instead of raw strings. Built in Rust with cross-platform support. Think of it as a shell meets a spreadsheet. ## Install Save in your project root: ## Quick Use ```bash # Install brew install nushell # macOS cargo install nu # Rust winget install nushell # Windows # Launch nu ``` Structured data pipelines: ```nu # List files as a table ls | sort-by size -r | first 5 # Filter and transform ls | where size > 1mb | select name size | sort-by size -r # HTTP request → structured data http get https://api.github.com/repos/nushell/nushell | select stargazers_count forks_count # CSV processing open sales.csv | where region == "APAC" | math sum revenue # JSON manipulation open config.json | upsert database.port 5433 | save config.json # System info as table sys host | select name os_version ps | where cpu > 10 | sort-by cpu -r # Custom commands def greet [name: string] { $"Hello, ($name)!" } greet William ``` ## Intro Nushell (nu) is a new type of shell written in Rust. Instead of treating everything as text strings, Nushell pipelines operate on structured data — tables, records, lists, and typed values. Think of it as a shell that understands data formats (JSON, CSV, YAML, TOML, SQLite) natively and lets you query them like a database. - **Repo**: https://github.com/nushell/nushell - **Stars**: 39K+ - **Language**: Rust - **License**: MIT ## What Nushell Does - **Structured pipelines** — data flows as tables, not text - **Built-in data formats** — JSON, CSV, YAML, TOML, XML, SQLite, Parquet - **Type system** — strings, ints, floats, booleans, dates, durations, file sizes - **ls / ps / sys** — system commands return structured data - **HTTP client** — `http get/post` with auto-parsing - **SQL-like queries** — where, select, group-by, sort-by, math - **Custom commands** — `def` with typed parameters - **Modules** — organize code into modules - **Plugins** — extend via compiled plugins - **Completions** — context-aware tab completion ## Architecture Rust binary. Parser produces an AST, engine evaluates pipelines. Each command produces a `PipelineData` value (table, record, string, etc.). Plugins communicate via JSON-RPC. ## Comparison | Shell | Data Model | Language | Cross-platform | |---|---|---|---| | Nushell | Structured tables | Own | Yes | | Bash/Zsh | Text streams | POSIX sh | Unix | | Fish | Text streams | Own | Unix | | PowerShell | .NET objects | Own | Yes | | Xonsh | Python objects | Python | Yes | ## 常见问题 FAQ **Q: 能替代 bash 吗?** A: 交互式使用可以。但 POSIX shell 脚本不兼容——现有 `.sh` 脚本还得用 bash 跑。Nushell 适合新脚本和日常交互。 **Q: 和 PowerShell 像?** A: 理念相似(结构化数据管道)但实现不同。Nushell 更轻量、跨平台原生、类型系统更简洁。 **Q: 性能?** A: Rust 实现,启动快、管道处理快。大文件处理比 awk/sed 稍慢但可读性好 100 倍。 ## 来源与致谢 Sources - Docs: https://www.nushell.sh/book - GitHub: https://github.com/nushell/nushell - License: MIT --- Source: https://tokrepo.com/en/workflows/903323cf-3649-11f1-9bc6-00163e2b0d79 Author: AI Open Source