mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2026-02-02 07:35:10 +01:00
chore: don't run merge multiple times
This commit is contained in:
parent
fea920ac7a
commit
0f5f3b70e7
2 changed files with 10 additions and 3 deletions
|
|
@ -650,13 +650,13 @@ pub fn shell_syntax(shell: &str, command: &str) -> String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shell_evaluated_commands(shell: &str, command: &str, cd: bool) {
|
pub fn shell_evaluated_commands(shell: &str, command: &str, success: bool) {
|
||||||
let lines = command
|
let lines = command
|
||||||
.lines()
|
.lines()
|
||||||
.map(|line| line.trim().trim_end_matches(['\\', ';', '|', '&']))
|
.map(|line| line.trim().trim_end_matches(['\\', ';', '|', '&']))
|
||||||
.collect::<Vec<&str>>();
|
.collect::<Vec<&str>>();
|
||||||
|
|
||||||
let cd = if cd {
|
let cd = if success {
|
||||||
let dirs = {
|
let dirs = {
|
||||||
let mut dirs = Vec::new();
|
let mut dirs = Vec::new();
|
||||||
for line in lines {
|
for line in lines {
|
||||||
|
|
@ -692,6 +692,7 @@ pub fn shell_evaluated_commands(shell: &str, command: &str, cd: bool) {
|
||||||
struct FishTemplate<'a> {
|
struct FishTemplate<'a> {
|
||||||
command: &'a str,
|
command: &'a str,
|
||||||
cd: Option<&'a str>,
|
cd: Option<&'a str>,
|
||||||
|
success: bool,
|
||||||
}
|
}
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "eval.nu", escape = "none")]
|
#[template(path = "eval.nu", escape = "none")]
|
||||||
|
|
@ -729,6 +730,7 @@ pub fn shell_evaluated_commands(shell: &str, command: &str, cd: bool) {
|
||||||
let template = FishTemplate {
|
let template = FishTemplate {
|
||||||
command: &command,
|
command: &command,
|
||||||
cd: cd.as_deref(),
|
cd: cd.as_deref(),
|
||||||
|
success,
|
||||||
};
|
};
|
||||||
template.render().unwrap()
|
template.render().unwrap()
|
||||||
}
|
}
|
||||||
|
|
@ -741,5 +743,8 @@ pub fn shell_evaluated_commands(shell: &str, command: &str, cd: bool) {
|
||||||
template.render().unwrap()
|
template.render().unwrap()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
println!("{}", print.trim());
|
let print = print.trim();
|
||||||
|
if !print.is_empty() {
|
||||||
|
println!("{}", print);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
builtin history append "{{ command }}";
|
builtin history append "{{ command }}";
|
||||||
|
{%- if success %}
|
||||||
builtin history merge;
|
builtin history merge;
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{%- if let Some(cd) = self.cd %}
|
{%- if let Some(cd) = self.cd %}
|
||||||
cd {{ cd }}
|
cd {{ cd }}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue