oh-my-git/terminal.gd

22 lines
622 B
GDScript3
Raw Normal View History

2020-06-10 18:25:41 +02:00
extends Node2D
var thread
func send_command(command):
thread = Thread.new()
thread.start(self, "run_command_in_a_thread", command)
func run_command_in_a_thread(command):
var cwd = game.run("pwd")
var output = []
var hacky_command = command
hacky_command = "cd /tmp/githydragit;"+hacky_command
hacky_command = "export EDITOR=fake-editor;"+hacky_command
hacky_command = "export PATH=\"$PATH\":"+cwd+"/scripts;"+hacky_command
OS.execute("/bin/sh", ["-c", hacky_command], true, output, true)
$Input.text = ""
$Output.text = $Output.text + "$ " + command + "\n" + output[0]
$Output.scroll_vertical = 999999