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
.elvfiles in~/.config/elvish/lib/ - Environment variables set in
rc.elvwithset-env NAME valueorset E:NAME = value - Customize keybindings by modifying
$edit:insert:bindingand other binding maps
Key Features
- Value pipelines: pass lists and maps between commands, not just text lines
- Built-in
ctrl-Nnavigation mode for browsing the filesystem withoutcd - Directory history with
ctrl-Lfor instant access to frequently visited paths - Exception handling with
try/catch/finallyblocks 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.