Can now grep the history :D
This commit is contained in:
17
src/lib.rs
17
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 {
|
||||
|
||||
Reference in New Issue
Block a user