diff --git a/README.md b/README.md index 0d0b93a..5346536 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ TODO: * Aliases don't currently handle arguments. My alias "vless" does not work with "vless lib.rs" * A shortcut / implemented command to show all Hotkeys * git commit -m "message" does not work -* Impossible to grep history / maybe implement Ctrl+R ? * Can't cd to a directory containing spaces in its name * Startup script section in sqishrc diff --git a/src/lib.rs b/src/lib.rs index 3c25d16..f8cc5e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,6 +8,7 @@ pub mod shell { use std::path::Path; use std::env; use std::str; + use std::fs::File; use std::process::Stdio; use termion::event::Key; use termion::input::TermRead; @@ -60,15 +61,17 @@ pub mod shell { //let stdout = Stdio::inherit(); let res = get_history(); match res { - Ok(r) => println!("{}", r), - Err(e) => eprintln!(" Err: {}", e), + Ok(r) => { + let filepath = dirs::home_dir().unwrap().join(".history.sqish"); + let file = File::open(filepath).unwrap(); + *&mut previous_command = Some(Stdio::from(file)); + if !commands.peek().is_some() { + print!("{}", r); + } + }, + Err(e) => eprintln!(" Err reading history: {}", e), } }, -// "ssh" => { -// let ssh_args = args.peekable().peek().map_or(" ", |x| *x); -// let mut child = Command::new("ssh").arg(ssh_args).spawn().unwrap(); -// let _ = child.wait().unwrap(); -// }, command => { if commands.peek().is_some() { let stdin = match previous_command {