Unlock Clickable File Links in Ghostty: A Simple eza & Zsh Hack

AI 摘要

Fix Clickable File Hyperlinks in Ghostty Terminal with eza & Zsh Aliases. Learn how to enable one-click file access in Ghostty using eza and Zsh aliases, boosting your productivity.

mqpbjcmfa500m388i4bYazi插件配置报错及修复.png

Problem Background

iTerm2 natively supports OSC 8 hyperlinks generated by modern CLI tools like eza. Hold Cmd and click any file listed by eza --hyperlink, and the file opens instantly.

Ghostty, however, does not parse file path hyperlinks out of the box by default. When you run vanilla ls or even basic eza commands in Ghostty, filenames remain plain static text—no clickable links work without manual configuration. This creates friction if you switch from iTerm2 to Ghostty and want the same one-click file access workflow.

Simple Solution Overview

We use two lightweight, zero-plugin adjustments:

  1. Replace native ls with eza (Rust-based ls alternative) that outputs standard OSC 8 file hyperlinks

  2. Create permanent Zsh aliases so you keep using familiar ls/ll shortcuts

No complex Ghostty regex link rules or extra Zsh plugins are required.

Step 1: Install eza

macOS (Homebrew)

brew install eza

Debian / Ubuntu

sudo apt update && sudo apt install eza

Step 2: Add Zsh Aliases to Enable Hyperlinks

Open your Zsh config file:

nano ~/.zshrc

Paste these alias lines at the bottom:

# Override ls commands to generate clickable OSC8 hyperlinks
alias ls='eza --hyperlink'
alias ll='eza -l --hyperlink'
alias la='eza -la --hyperlink'

Save the file and reload config to activate immediately:

source ~/.zshrc

Step 3: How to Use Clickable Files in Ghostty

Run ll or ls to list your directory.

  • macOS: Hold Cmd + left-click any filename

  • Linux: Hold Ctrl + left-click any filename

Ghostty will recognize the embedded OSC 8 escape sequences from eza and trigger your system’s default app to open the target file or folder.

Quick Troubleshooting

  1. Click does nothing Confirm the --hyperlink flag exists in your aliases, then run source ~/.zshrc again to refresh shell settings.

  2. Native ls still runs instead of eza Run type ls to verify the alias loads correctly. If missing, re-save and reload .zshrc.

  3. Hyperlinks break inside Tmux Remove mouse-shift-capture = true from your Ghostty config file to restore modifier-click hyperlink behavior.

Wrap-Up

Unlike iTerm2, Ghostty requires explicit OSC 8 hyperlink output from command-line tools to support clickable files. Eza’s built-in --hyperlink flag handles all link formatting, and simple Zsh aliases let you retain your usual directory listing workflow without learning new commands. This minimal setup delivers the exact click-to-open file experience you expect in Ghostty terminal.