diff --git a/CHANGELOG.md b/CHANGELOG.md index 6303c44..f1c81ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Running standard modules in a separated thread +- Bash init: use `fc` instead of history ## [0.6.8] - 2025-01-02 diff --git a/core/src/shell.rs b/core/src/shell.rs index 5b06a42..ff0afae 100644 --- a/core/src/shell.rs +++ b/core/src/shell.rs @@ -352,10 +352,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, @@ -456,7 +453,7 @@ pub fn initialization(init: &mut Init) { match init.shell.as_str() { "bash" => { - last_command = "$(history 2)"; + last_command = "$(fc -ln -1)"; shell_alias = "`alias`"; } "zsh" => { @@ -583,7 +580,7 @@ end initialize = format!( r#" command_not_found_handle() {{ - eval $(_PR_LAST_COMMAND="_ $@" _PR_SHELL="{}" _PR_ALIAS="{}" _PR_MODE="cnf" "{}") + eval $(_PR_LAST_COMMAND="$@" _PR_SHELL="{}" _PR_ALIAS="{}" _PR_MODE="cnf" "{}") }} {}