Configs2026年5月19日·1 分钟阅读

Elvish — Expressive Programming Shell for the Modern Terminal

Elvish is a cross-platform shell that combines a powerful scripting language with a modern interactive experience including structured data pipelines, a built-in file manager, and persistent shared command history.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Elvish Shell
通用 CLI 安装命令
npx tokrepo install 157aaa0c-533a-11f1-9bc6-00163e2b0d79

Introduction

Elvish is a shell designed to be both a comfortable interactive environment and a real programming language. It supports structured data (lists, maps) in pipelines instead of plain text, has a built-in file navigation mode, and stores command history in a searchable database shared across sessions.

What Elvish Does

  • Passes structured data (lists, maps) through pipelines alongside traditional byte streams
  • Provides a real programming language with closures, exceptions, namespaces, and modules
  • Offers an interactive navigation mode for browsing directories, history, and locations
  • Stores command history in a persistent database with instant fuzzy search across all sessions
  • Supports syntax highlighting and completion as you type without additional plugins

Architecture Overview

Elvish is a single Go binary with no external dependencies. The shell implements its own language parser, compiler, and bytecode evaluator. Pipelines carry two parallel channels: a byte stream (compatible with Unix pipes) and a value stream for structured data. The interactive frontend uses a custom terminal rendering engine that supports multi-line editing and UI modes (navigation, history, location). Modules are loaded from ~/.config/elvish/lib/ using an import system with explicit namespaces.

Self-Hosting & Configuration

  • Install a single binary—no dependencies beyond a terminal emulator
  • Configuration lives in ~/.config/elvish/rc.elv, the equivalent of .bashrc
  • Modules install by placing .elv files in ~/.config/elvish/lib/
  • Environment variables set in rc.elv with set-env NAME value or set E:NAME = value
  • Customize keybindings by modifying $edit:insert:binding and other binding maps

Key Features

  • Value pipelines: pass lists and maps between commands, not just text lines
  • Built-in ctrl-N navigation mode for browsing the filesystem without cd
  • Directory history with ctrl-L for instant access to frequently visited paths
  • Exception handling with try/catch/finally blocks for robust scripts
  • First-class closures and functional programming constructs (each, map, filter)

Comparison with Similar Tools

  • Bash/Zsh — text-based pipelines only; Elvish adds structured data and a real type system
  • Fish — user-friendly with autosuggestions; Elvish adds structured data and a more expressive scripting language
  • Nushell — also structured pipelines; Elvish uses a more traditional shell syntax and has a smaller binary
  • PowerShell — object pipelines on .NET; Elvish is a lightweight Go binary that runs natively on Unix and Windows
  • Oil/Oils — aims to fix Bash syntax; Elvish is a clean-slate design rather than a Bash superset

FAQ

Q: Can I use Elvish as my daily login shell? A: Yes. Elvish is a fully functional login shell. Add it to /etc/shells and set it with chsh. It can run most simple sh-compatible commands, though complex Bash scripts should still be run with bash.

Q: Does Elvish run Bash scripts? A: No. Elvish has its own language that is not Bash-compatible. You can call Bash scripts explicitly with bash script.sh from within Elvish.

Q: How does the structured pipeline work in practice? A: Commands can output values with put, and downstream commands receive them as arguments. For example: put a b c | each {|x| echo $x } passes three string values through the pipeline.

Q: Is Elvish fast enough for daily use? A: Yes. Elvish is compiled to bytecode and runs promptly. The Go runtime adds a small startup cost compared to C-based shells, but it is imperceptible in interactive use.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产