diff --git a/src/shell.rs b/src/shell.rs index 37ab0bf..261b206 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -54,10 +54,7 @@ pub fn last_command(shell: &str) -> String { }; match shell { - "bash" => { - let first_line = last_command.lines().next().unwrap().trim(); - first_line.split_once(' ').unwrap().1.to_string() - } + "bash" => last_command, "zsh" => last_command, "fish" => last_command, "nu" => last_command, @@ -152,7 +149,7 @@ pub fn initialization(shell: &str, binary_path: &str, auto_alias: &str, cnf: boo match shell { "bash" => { - last_command = "$(history 2)"; + last_command = r"$(history 2 | head -n 1 | sed 's/^\s*[0-9]*//')"; alias = "$(alias)" } "zsh" => {