Fish Shell配置指南

🐧 WSL + Fish Shell 设置说明

管理 WSL 发行版

1
2
3
4
wsl -l -v                       # List all installed distros with version
wsl --unregister Ubuntu # Remove old Ubuntu instance (⚠️ data loss)
wsl --install -d Ubuntu-24.04 # Install fresh Ubuntu
wsl -s Ubuntu-24.04 # Set Ubuntu as default distro

检查默认 Shell

1
2
echo $SHELL                     # Show current shell
cat /etc/shells # List available shells

更新和升级软件包

1
2
sudo apt update
sudo apt upgrade -y

安装 Fish Shell + 实用工具

1
2
sudo apt install fish -y
sudo apt install w3m -y # Terminal web browser (for fish_config preview)

注册 Fish 到可用 Shell

1
cat /etc/shells                 # Verify fish is listed (usually /usr/bin/fish)

切换到 Fish

1
2
fish                            # Start fish session
chsh -s /usr/bin/fish # Set fish as default login shell

⚠️ In WSL, chsh sometimes doesn’t persist. If it doesn’t stick:⚠️ 在 WSL 中, chsh 有时不持久。如果它不固定:

- Create/edit `~/.wslconfig` (Windows side) or use a `.profile` hack to auto-start fish.

    在 Windows 端创建/编辑 `~/.wslconfig` 或使用 `.profile` 小技巧自动启动 fish。

验证已安装的软件包数量

1
grep -i "installed" /var/log/dpkg.log | wc -l

配置 Fish

1
fish_config
  • Opens a web UI (served locally).打开一个网页界面(本地服务)。
  • Requires w3m or browser to preview themes.需要 w3m 或浏览器来预览主题。
  • Configure prompt, colors, completions, etc.配置提示符、颜色、自动补全等。

安装并配置 Zoxide(可选但推荐)

1
curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh
  • Add to the end of your Fish config (~/.config/fish/config.fish):

    添加到你的 Fish 配置文件的末尾 ( ~/.config/fish/config.fish ):

1
zoxide init fish | source

安装 FZF(可选,用于 Zoxide 补全)

1
sudo apt install fzf
  • FZF provides fuzzy search for directory navigation and works with Zoxide for interactive selection.FZF 提供目录导航的模糊搜索功能,并与 Zoxide 配合使用,实现交互式选择。
  • Ensure the above zoxide init fish | source is in your config for seamless integration.确保上述 zoxide init fish | source 在你的配置文件中,以实现无缝集成。

✅ Next Steps / Tips✅ 下一步 / 小贴士

  • Install Fisher (plugin manager for fish):

    安装 Fisher(fish 的插件管理器):

1
curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
  • Popular plugins: jorgebucaran/nvm.fishilancosman/tide (prompt), patrickf1/fzf.fish.热门插件: jorgebucaran/nvm.fish , ilancosman/tide (提示), patrickf1/fzf.fish 。
  • Set aliases/functions in ~/.config/fish/config.fish.在 ~/.config/fish/config.fish 中设置别名/函数。