Skip to content

macOS: cmd-click fails to open file paths containing tilde (~) #10864

@AlexFeijoo44

Description

@AlexFeijoo44

Description

Cmd-clicking a file path containing ~ (e.g. ~/Documents/file.txt) fails to open the file on macOS. The path highlights and appears clickable, but nothing happens.

Absolute paths (e.g. /Users/username/Documents/file.txt) work correctly.

Root Cause

In Ghostty.App.swift's openURL(), when the URL string has no scheme it falls through to:

url = URL(filePath: action.url)

Swift's URL(filePath:) does not perform tilde expansion. A path like ~/Documents/file.txt produces a URL pointing to a non-existent file, and NSWorkspace.open silently fails.

Suggested Fix

Use NSString.expandingTildeInPath to resolve ~ before constructing the file URL:

let expandedPath = NSString(string: action.url).expandingTildeInPath
url = URL(filePath: expandedPath)

Reproduction

  1. Run a terminal application that outputs file paths with ~ prefixes (e.g. Claude Code outputs Written to ~/Sites/file.md)
  2. Cmd-click the path in Ghostty on macOS
  3. The file does not open (fails silently)

Environment

  • Ghostty 1.2.3 (stable)
  • macOS 15 (Darwin 24.6.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions