Skip to content

Instantly share code, notes, and snippets.

@StewartLynch
Last active March 18, 2026 18:31
Show Gist options
  • Select an option

  • Save StewartLynch/994f86ed4060ddfff7b4ca8e6076367f to your computer and use it in GitHub Desktop.

Select an option

Save StewartLynch/994f86ed4060ddfff7b4ca8e6076367f to your computer and use it in GitHub Desktop.
TUIKit Shell Function
func shell(_ command: String) -> String {
let task = Process()
let pipe = Pipe()
task.standardOutput = pipe
task.standardError = Pipe()
task.launchPath = "/bin/bash"
task.arguments = ["-c", command]
task.environment = ProcessInfo.processInfo.environment
try? task.run()
task.waitUntilExit()
return (String(data: pipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "")
.trimmingCharacters(in: .whitespacesAndNewlines)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment