From 74b3507b21e4fd868b66555b3cc0322be2c17d51 Mon Sep 17 00:00:00 2001 From: Soeun Park Date: Sun, 10 May 2026 23:13:40 +0900 Subject: [PATCH] feat: configurable macOS terminal app via EditorPrefs The macOS branch of TerminalLauncher.CreateTerminalProcessStartInfo hardcoded `open -a Terminal`, which forces Terminal.app to spawn even when the user prefers another terminal (iTerm2, Warp, etc.). macOS LaunchServices resolves `-a Terminal` by name, so iTerm's "Make iTerm2 default term" setting cannot redirect it. Read the terminal app name from the new `MCPForUnity.MacOSTerminalApp` EditorPref. Empty/unset falls back to "Terminal" so existing behavior is preserved for users who never touch the setting. The key is registered in EditorPrefsWindow's `knownPrefTypes` so it shows up in the EditorPrefs window as a String entry. Argument is now quoted (`-a "{app}"`) to handle names with spaces such as "iTerm 2". Co-Authored-By: Claude Opus 4.7 (1M context) --- MCPForUnity/Editor/Constants/EditorPrefKeys.cs | 2 ++ MCPForUnity/Editor/Services/Server/TerminalLauncher.cs | 6 +++++- MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/MCPForUnity/Editor/Constants/EditorPrefKeys.cs b/MCPForUnity/Editor/Constants/EditorPrefKeys.cs index d8aa8e3f5..498034767 100644 --- a/MCPForUnity/Editor/Constants/EditorPrefKeys.cs +++ b/MCPForUnity/Editor/Constants/EditorPrefKeys.cs @@ -71,5 +71,7 @@ internal static class EditorPrefKeys internal const string LogRecordEnabled = "MCPForUnity.LogRecordEnabled"; internal const string ExecuteCodeCompiler = "MCPForUnity.ExecuteCode.Compiler"; + + internal const string MacOSTerminalApp = "MCPForUnity.MacOSTerminalApp"; } } diff --git a/MCPForUnity/Editor/Services/Server/TerminalLauncher.cs b/MCPForUnity/Editor/Services/Server/TerminalLauncher.cs index 49ec84817..7431c9d96 100644 --- a/MCPForUnity/Editor/Services/Server/TerminalLauncher.cs +++ b/MCPForUnity/Editor/Services/Server/TerminalLauncher.cs @@ -1,6 +1,8 @@ using System; using System.IO; +using MCPForUnity.Editor.Constants; using MCPForUnity.Editor.Helpers; +using UnityEditor; using UnityEngine; namespace MCPForUnity.Editor.Services.Server @@ -45,10 +47,12 @@ public System.Diagnostics.ProcessStartInfo CreateTerminalProcessStartInfo(string "clear\n" + $"{command}\n"); ExecPath.TryRun("/bin/chmod", $"+x \"{scriptPath}\"", Application.dataPath, out _, out _, 3000); + string terminalApp = EditorPrefs.GetString(EditorPrefKeys.MacOSTerminalApp, "Terminal"); + if (string.IsNullOrWhiteSpace(terminalApp)) terminalApp = "Terminal"; return new System.Diagnostics.ProcessStartInfo { FileName = "/usr/bin/open", - Arguments = $"-a Terminal \"{scriptPath}\"", + Arguments = $"-a \"{terminalApp}\" \"{scriptPath}\"", UseShellExecute = false, CreateNoWindow = true }; diff --git a/MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs b/MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs index b683a21a5..f11d80409 100644 --- a/MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs +++ b/MCPForUnity/Editor/Windows/EditorPrefs/EditorPrefsWindow.cs @@ -77,6 +77,7 @@ public class EditorPrefsWindow : EditorWindow { EditorPrefKeys.LastLocalHttpServerPidArgsHash, EditorPrefType.String }, { EditorPrefKeys.LastLocalHttpServerPidFilePath, EditorPrefType.String }, { EditorPrefKeys.LastLocalHttpServerInstanceToken, EditorPrefType.String }, + { EditorPrefKeys.MacOSTerminalApp, EditorPrefType.String }, }; // Templates