diff --git a/README.md b/README.md index f229f3f..005dfa0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # Sqish Rust Shell. This is an attempt to create a simple shell in Rust, because why not. +TODO: +* Aliases don't currently handle arguments. My alias "vless" does not work with "vless lib.rs" + ## sqishrc (Config) See the included sqishrc.yaml.example file included, and copy it as ~/.sqishrc.yaml diff --git a/src/lib.rs b/src/lib.rs index 5bc4dc0..7a43095 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -425,27 +425,31 @@ pub mod shell { }, Key::Up => { - mycommand = delete_current_cmd(mycommand); - current_number -= 1; - let lastcmd = match get_hist_from_number(¤t_number) { - Some(c) => c, - None => continue - }; - mycommand = lastcmd.trim().to_string(); - (max_pos, current_pos) = get_cmd_curs_pos(&mycommand); - write!(stdout, "{}", mycommand); + if current_number > 2 { + mycommand = delete_current_cmd(mycommand); + current_number -= 1; + let lastcmd = match get_hist_from_number(¤t_number) { + Some(c) => c, + None => continue + }; + mycommand = lastcmd.trim().to_string(); + (max_pos, current_pos) = get_cmd_curs_pos(&mycommand); + write!(stdout, "{}", mycommand); + } }, Key::Down => { - mycommand = delete_current_cmd(mycommand); - current_number += 1; - let lastcmd = match get_hist_from_number(¤t_number) { - Some(c) => c, - None => continue - }; - mycommand = lastcmd.trim().to_string(); - (max_pos, current_pos) = get_cmd_curs_pos(&mycommand); - write!(stdout, "{}", mycommand); + if current_number < get_curr_history_number() { + mycommand = delete_current_cmd(mycommand); + current_number += 1; + let lastcmd = match get_hist_from_number(¤t_number) { + Some(c) => c, + None => continue + }; + mycommand = lastcmd.trim().to_string(); + (max_pos, current_pos) = get_cmd_curs_pos(&mycommand); + write!(stdout, "{}", mycommand); + } }, Key::Ctrl('x') => {