From 607152ec6d2487ab10fb1cf5de6e0519baf8a21b Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Thu, 7 May 2026 11:14:55 +0200 Subject: [PATCH] macOS: normalize working directory paths with FilePath This fixes for nuShell when opening Ghostty via Finder service and Shortcuts, also makes path parsing more robust in AppleScript. --- .../Ghostty/Surface View/SurfaceView.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView.swift b/macos/Sources/Ghostty/Surface View/SurfaceView.swift index d9fe83cd6..a17d8d704 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView.swift @@ -1,6 +1,7 @@ import SwiftUI import UserNotifications import GhosttyKit +import System extension Ghostty { /// Render a terminal for the active app in the environment. @@ -611,8 +612,20 @@ extension Ghostty { /// Explicit font size to use in points var fontSize: Float32? + private var normalizedWorkingDirectory: String? /// Explicit working directory to set - var workingDirectory: String? + var workingDirectory: String? { + get { normalizedWorkingDirectory } + set { + guard let newValue else { + normalizedWorkingDirectory = nil + return + } + // We use FilePath to normalize separators by removing redundant intermediary separators + // and stripping any trailing separators. + normalizedWorkingDirectory = FilePath(newValue).string + } + } /// Explicit command to set var command: String?