Skip to content

[ghostty][fish] 配置 Ghostty 默认 shell 为 fish #48

Description

@nzcv

Ghostty 配置默认 shell 为 fish

在 macOS 上将 Ghostty 终端的默认 shell 从系统 zsh 改为 Homebrew 安装的 fish。

环境

  • fish 路径:/opt/homebrew/bin/fish
  • fish 版本:4.7.1
  • 系统默认 shell:/bin/zsh

配置

创建配置文件 ~/.config/ghostty/config

# Default shell
command = /opt/homebrew/bin/fish

Ghostty 会优先使用 command 指定的 shell,而不是 $SHELL 或系统 passwd 中的默认值。

使配置生效

  • 新开一个 Ghostty 窗口,或
  • Shift + Command + , 重载配置(macOS)

验证:

echo $SHELL

应显示 fish 的路径。

Shell Integration

Ghostty 对 fish 有自动 shell integration(语义 prompt、光标形状等),一般无需额外配置。

若未自动生效,可在 ~/.config/fish/config.fish 中加入:

if set -q GHOSTTY_RESOURCES_DIR
    source "$GHOSTTY_RESOURCES_DIR/shell-integration/fish/ghostty.fish"
end

可选:系统级默认 shell

若希望所有终端(不仅是 Ghostty)都使用 fish:

echo /opt/homebrew/bin/fish | sudo tee -a /etc/shells
chsh -s /opt/homebrew/bin/fish

推荐组合

  • Ghostty 内单独指定 fish:command = /opt/homebrew/bin/fish(不影响系统默认 shell)
  • 需要全局 fish 时,再执行 chsh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions