diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs index 5854272..b0db2e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -108,6 +108,7 @@ fn main() { let mut buffer = [0u8; 1]; let mut line = LineBuf::new(); + let mut history = Vec::new(); print!("{PROMPT}"); @@ -127,6 +128,7 @@ fn main() { let line = line.dump(); if !line.is_empty() { print!("\r\n"); + history.push(line.clone()); run_command(&raw, line); } } @@ -164,6 +166,14 @@ fn main() { } } + b'|' if line.is_empty() && !history.is_empty() => { + let mut cmd = history[history.len()-1].clone(); + cmd.extend_from_slice(b" | "); + io::stdout().write_all(&cmd).unwrap(); + io::stdout().flush().unwrap(); + line.set_content(cmd); + } + // Normal character x => { line.add(x); |
