From 1eb22767d744e7a043358141c3ddda9fc302bbb6 Mon Sep 17 00:00:00 2001 From: Penwing Date: Tue, 16 Jan 2024 12:53:03 +0100 Subject: [PATCH] working terminal --- src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index c61fcdb..44ba08b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use eframe::egui; use std::fs; use std::path::Path; +use std::process::Command; const TERMINAL_HEIGHT : f32 = 200.0; @@ -26,7 +27,13 @@ fn main() -> Result<(), eframe::Error> { } fn run_command(cmd : String) -> String { - cmd + let command = "> ".to_owned() + &cmd.clone() + "\n"; + let output = Command::new("sh") + .arg("-c") + .arg(cmd) + .output() + .expect("failed to execute process"); + (command + &String::from_utf8_lossy(&output.stdout)).to_string() } @@ -38,6 +45,7 @@ struct MyApp { command_history: String, } + impl Default for MyApp { fn default() -> Self { Self {