Still using bash in this day and age? Out-of-the-box modern shells: fish, nu, elvish
Fish works out of the box, with really nice smart completions and colors? Nushell handles data like SQL, everything is an object, but a steep learning curve? Elvish is like a programming language, tightly logical, niche community? Why bother tinkering—just switch shells?
目录20 个章节
Preface
Linux servers generally default to bash as the shell, which isn't very smart. You can use a modern shell to improve the command-line experience.
zsh is a decent choice, but it's ugly by default and pairing it with Oh My Zsh is a hassle. This article covers installing and getting started with some of the newer, out-of-the-box shells.
If you use the chsh command to change the default login shell (Login Shell), some system scripts or automation tasks that depend on Bash-specific environment variables (such as settings in /etc/profile) may error out because they can't find the Bash environment.
Approach: launch the modern shell from within Bash.
Which of the three modern shells is strongest?
Each of the three has its own character—pick according to taste:
🐟 Fish
(Friendly Interactive SHell) The most hassle-free "all-rounder"
- Features: Ready out of the box. Built-in syntax highlighting, smart completions (based on your history and man pages), and very nice colors.
- Verdict: Easiest to pick up. If you don't want to mess with config and just want to get stronger the moment you install it, Fish is the first choice.
- Downsides: Although parts of the engine were rewritten starting with 4.0, it still isn't POSIX-compatible (for example, the
VAR=val cmdsyntax wasn't supported in older Fish).
🦀 Nushell
(Nu) The "futurist" that handles data like SQL
- Features: Everything is an object. In Nu,
lsdoesn't return a string of text—it returns a table. You can write things likels | where size > 10mb. - Verdict: The geekiest and most fun. It's not just a shell—it's more like a modern data-processing tool. If you often deal with JSON, CSV, or large batches of logs, it'll send you flying.
- Downsides: Steeper learning curve; some traditional command syntax takes getting used to.
🧝 Elvish
The programmer's "elegant language"
- Features: It tries to turn the shell into a real, powerful programming language. Supports complex structures (Map, List), and even has its own package manager.
- Verdict: The most solid, with the tightest logic. Suited for people who find Bash script syntax "hellish" and want to write scripts with a modern programming mindset.
- Downsides: Relatively smaller community ecosystem.
Tips
Nushell and Elvish are both cross-platform, meaning you can get a consistent experience on Windows, macOS, and Linux. As for Fish, I've only used it on Linux and haven't looked into whether it works on other systems.
Fish
Installing Fish
# Ubuntu/Debian
sudo apt update && sudo apt install fish -y
Installing Fisher (plugin manager)
This is currently the best tool for the job; I recommend installing it first. Run the following in fish:
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher
Configuring the launch logic
Add the following logic at the end of your ~/.bashrc file:
# 检查是否是交互式会话,且目标 shell 存在
if [[ $- == *i* ]] && command -v fish >/dev/null 2>&1; then
exec fish
fi
[[ $- == \*i\* ]]: Makes sure this only fires in an interactive command line (when you're operating it yourself). If a script is running without a terminal, it won't launch, so you don't break automation.exec: This word is crucial. It replaces the current process with a new one, so when you exitfish, the connection closes directly instead of dropping you back into a blankbash.
A few fun plugins/themes I recommend
Once Fisher is installed, you can run these commands to install some experience-boosting gems:
- Pure (a clean, beautiful theme)
fisher install pure-fish/pureA very clean, modern Prompt theme with excellent visuals. - Done (task-complete notifications)
fisher install franciscolourenco/doneIf you run a long-running command (like a compile or backup), when it finishes it will send you a notification even if you're looking at another window. - Bass (Bash script compatibility)
fisher install edc/bassThis one matters most for you! Because Fish isn't compatible with Bash syntax, commands likesource /etc/profilewill error in Fish. After installing Bass, you can writebass source /etc/profileand it will handle the compatibility for you.
Quick tips
- Web UI configuration: Type
fish_configin the Fish terminal. It will automatically pop up a browser page where you can click around to change color schemes and functions—very intuitive. - Smart completions: Fish completions are based on your history. When you type the first few letters of a command, it shows a suggestion in gray; press the right arrow key (→) or Ctrl + F to fill it in.
I want them all
Nushell (Nu)
Data processing's "higher-dimensional strike"
Nushell is currently the most-discussed, most hardcore modern shell in the community. Its core logic is: everything is structured data.
Why is it fun?
In a traditional shell, ls outputs a string. If you want to filter by file size, you have to painfully slice that string with grep, awk, and cut. In Nushell, ls outputs an in-memory table.
Give it a try:
ls | where size > 10mb | sort-by type
It will filter files larger than 10MB and sort by type, just like SQL, and the output is still a neat table.
A JSON/YAML powerhouse: If you have a config.json, in Nu you just need:
open config.json | get database.port
It pulls the value out directly—no need to install jq at all.
Installation
https://www.nushell.sh/book/installation.html
Nushell is written in Rust and is very fast. You can download the binary directly or use a package manager.
wget -qO- https://apt.fury.io/nushell/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/fury-nushell.gpg
echo "deb [signed-by=/etc/apt/keyrings/fury-nushell.gpg] https://apt.fury.io/nushell/ /" | sudo tee /etc/apt/sources.list.d/fury-nushell.list
sudo apt update
sudo apt install nushell
Elvish
The programmer's "Swiss army knife"
Elvish (elvish language) takes the extreme robustness and programming-friendly route. Its author is Chinese developer Qi Xiao, and the design philosophy is very rigorous.
Why is it fun?
- Pipes that don't break: In Bash, pipes carry a byte stream; in Elvish, pipes can carry complex data structures (lists, dictionaries).
- Built-in file manager: The history search UI with
Ctrl+Ris quite gorgeous;Ctrl+Lenters a floating file-navigation mode similar toranger, so you can pick files right in the shell. - Extremely consistent syntax: It completely abandons Bash's fragmented syntax (like the difference between
[and[[); writing its scripts feels like writing a modern programming language.
Installation
https://elv.sh/get/package-manager.html
sudo apt install elvish
Configuring the launch logic
Put a selector in ~/.bashrc.
Every time you log in it will ask which shell you want to use (personally I'd just go with fish—it works out of the box)
# 交互模式下询问你想进入哪个宇宙
if [[ $- == *i* ]]; then
echo "Choose your shell: [1] Fish [2] Nushell [3] Elvish [Any] Stay in Bash"
read -n 1 -p "Select: " choice
echo
case $choice in
1) exec fish ;;
2) exec nu ;;
3) exec elvish ;;
*) echo "Welcome back to Bash." ;;
esac
fi
_EOF_
Still using bash in this day and age? Out-of-the-box modern shells: fish, nu, elvish
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
SSH 跳板机原理与配置:实现无缝跳板连接,一步直达目标主机
在日常运维或开发工作中,我们常常需要访问部署在内网的服务器。然而出于安全策略或网络拓扑的限制,内网服务器并不会直接向外部暴露端口,导致我们无法“直连”它们。此时,**跳板机**(Jump Host/Bastion Host)就成了必不可少的中转
2025-01-17 · Linux · 约 1 分钟
硬盘空间消失之谜:Linux 服务器存储排查与优化全过程
最近我发现服务器磁盘空间突然占用异常,经过排查,罪魁祸首竟然是 Docker 容器的日志文件!
2024-12-17 · Linux · 约 1 分钟
部署个SSH蜜罐玩玩,既能增强安全性,又能当电子蛐蛐
部署SSH蜜罐?改个端口,装fakessh白嫖密码字典,sshesame当电子蛐蛐记录操作。typora插件更新麻烦,安全测试才是真本事。
2024-11-04 · Linux · 约 1 分钟
经历分享,发现挖矿木马后,服务器快速备份与重装(腾讯云平台)
服务器又中木马?备份重装一套走起,coscli搞定。一键脚本压缩上传,硬盘镜像SSH传输,安全加固到位。AI时代更需小心,重装系统省心省力。
2026-03-04 · Linux · 约 1 分钟
讨论
共 0 条加载评论中…