refactor: use fc for bash

This commit is contained in:
iff 2025-01-06 13:35:19 +01:00
parent 5791c2fc20
commit 0a799db5e5
2 changed files with 4 additions and 6 deletions

View file

@ -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

View file

@ -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" "{}")
}}
{}