macos: can set env vars on new terminal
parent
f8bc9b547c
commit
027171bd5d
|
|
@ -30,6 +30,13 @@ struct NewTerminalIntent: AppIntent {
|
||||||
)
|
)
|
||||||
var workingDirectory: IntentFile?
|
var workingDirectory: IntentFile?
|
||||||
|
|
||||||
|
@Parameter(
|
||||||
|
title: "Environment Variables",
|
||||||
|
description: "Environment variables in `KEY=VALUE` format.",
|
||||||
|
default: []
|
||||||
|
)
|
||||||
|
var env: [String]
|
||||||
|
|
||||||
@Parameter(
|
@Parameter(
|
||||||
title: "Parent Terminal",
|
title: "Parent Terminal",
|
||||||
description: "The terminal to inherit the base configuration from."
|
description: "The terminal to inherit the base configuration from."
|
||||||
|
|
@ -58,6 +65,15 @@ struct NewTerminalIntent: AppIntent {
|
||||||
config.workingDirectory = dir.path(percentEncoded: false)
|
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
|
// Determine if we have a parent and get it
|
||||||
let parent: Ghostty.SurfaceView?
|
let parent: Ghostty.SurfaceView?
|
||||||
if let parentParam = self.parent {
|
if let parentParam = self.parent {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue