diff --git a/switchboard/Utilities/AppleScriptTemplates.swift b/switchboard/Utilities/AppleScriptTemplates.swift index d1e355a..b518b99 100644 --- a/switchboard/Utilities/AppleScriptTemplates.swift +++ b/switchboard/Utilities/AppleScriptTemplates.swift @@ -84,12 +84,12 @@ enum AppleScriptTemplates { activate end tell - delay 0.5 + delay 0.8 tell application "System Events" tell process "Warp" keystroke "n" using command down - delay 0.3 + delay 1.0 keystroke "assume '\(escapedProfile)'" keystroke return end tell @@ -107,12 +107,12 @@ enum AppleScriptTemplates { activate end tell - delay 0.5 + delay 0.8 tell application "System Events" tell process "Warp" keystroke "n" using command down - delay 0.3 + delay 1.0 keystroke "assume -c '\(escapedProfile)'" keystroke return end tell @@ -136,7 +136,9 @@ enum GhosttyCommands { static func ghosttyArgs(profileName: String, forConsole: Bool) -> [String] { let escapedProfile = profileName.escapedForShell let assumeCmd = forConsole ? "assume -c" : "assume" - return ["-e", "bash", "-c", "\(assumeCmd) '\(escapedProfile)'; exec bash"] + let userShell = ProcessInfo.processInfo.environment["SHELL"] ?? "/bin/zsh" + let shellName = URL(fileURLWithPath: userShell).lastPathComponent + return ["-e", userShell, "-l", "-c", "\(assumeCmd) '\(escapedProfile)'; exec \(shellName)"] } } diff --git a/tests/StringEscapingTests.swift b/tests/StringEscapingTests.swift index 4e51f6c..2e5ebc5 100644 --- a/tests/StringEscapingTests.swift +++ b/tests/StringEscapingTests.swift @@ -145,17 +145,27 @@ final class StringEscapingTests: XCTestCase { func testGhosttyCommand_Assume() { let args = GhosttyCommands.ghosttyArgs(profileName: "test-profile", forConsole: false) - XCTAssertEqual(args, ["-e", "bash", "-c", "assume 'test-profile'; exec bash"]) + XCTAssertEqual(args[0], "-e") + XCTAssertEqual(args[2], "-l") + XCTAssertEqual(args[3], "-c") + XCTAssertTrue(args[4].contains("assume 'test-profile'")) + XCTAssertFalse(args[4].contains("assume -c")) } func testGhosttyCommand_AssumeConsole() { let args = GhosttyCommands.ghosttyArgs(profileName: "test-profile", forConsole: true) - XCTAssertEqual(args, ["-e", "bash", "-c", "assume -c 'test-profile'; exec bash"]) + XCTAssertEqual(args[0], "-e") + XCTAssertEqual(args[2], "-l") + XCTAssertEqual(args[3], "-c") + XCTAssertTrue(args[4].contains("assume -c 'test-profile'")) } func testGhosttyCommand_WithQuotesInProfile() { let args = GhosttyCommands.ghosttyArgs(profileName: "it's-my-profile", forConsole: false) - XCTAssertEqual(args, ["-e", "bash", "-c", "assume 'it'\\''s-my-profile'; exec bash"]) + XCTAssertEqual(args[0], "-e") + XCTAssertEqual(args[2], "-l") + XCTAssertEqual(args[3], "-c") + XCTAssertTrue(args[4].contains("assume 'it'\\''s-my-profile'")) } // MARK: - Edge Cases