mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
macos: can set env vars on new terminal
This commit is contained in:
@@ -30,6 +30,13 @@ struct NewTerminalIntent: AppIntent {
|
||||
)
|
||||
var workingDirectory: IntentFile?
|
||||
|
||||
@Parameter(
|
||||
title: "Environment Variables",
|
||||
description: "Environment variables in `KEY=VALUE` format.",
|
||||
default: []
|
||||
)
|
||||
var env: [String]
|
||||
|
||||
@Parameter(
|
||||
title: "Parent Terminal",
|
||||
description: "The terminal to inherit the base configuration from."
|
||||
@@ -58,6 +65,15 @@ struct NewTerminalIntent: AppIntent {
|
||||
config.workingDirectory = dir.path(percentEncoded: false)
|
||||
}
|
||||
|
||||
// Parse environment variables from KEY=VALUE format
|
||||
for envVar in env {
|
||||
if let separatorIndex = envVar.firstIndex(of: "=") {
|
||||
let key = String(envVar[..<separatorIndex])
|
||||
let value = String(envVar[envVar.index(after: separatorIndex)...])
|
||||
config.environmentVariables[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
// Determine if we have a parent and get it
|
||||
let parent: Ghostty.SurfaceView?
|
||||
if let parentParam = self.parent {
|
||||
|
Reference in New Issue
Block a user