diff --git a/core/src/shell.rs b/core/src/shell.rs index 79c9c9d..becf7a5 100644 --- a/core/src/shell.rs +++ b/core/src/shell.rs @@ -694,7 +694,7 @@ pub fn get_shell() -> String { pub fn shell_syntax(shell: &str, command: &str) -> String { #[allow(clippy::single_match)] match shell { - "nu" => command.replace("&&", ";").to_string(), + "nu" => command.replace("&&\n", ";\n").to_string(), _ => command.to_string(), } } diff --git a/rules/cd.toml b/rules/cd.toml index 187b520..1a55639 100644 --- a/rules/cd.toml +++ b/rules/cd.toml @@ -11,7 +11,7 @@ cd {{typo[1](file)}} ''', ''' #[!shell(nu)] -mkdir --parents {{command[1]}} && \ +mkdir --parents {{command[1]}} && cd {{command[1]}} ''' ] diff --git a/rules/cp.toml b/rules/cp.toml index 3c9ae9b..4c1b790 100644 --- a/rules/cp.toml +++ b/rules/cp.toml @@ -16,7 +16,7 @@ pattern = [ suggest = [ ''' #[err_contains(no such file or directory)] -mkdir -p {{cmd::(?m)\s(\S+[\\\/])\S*\s*$}} && \ +mkdir -p {{cmd::(?m)\s(\S+[\\\/])\S*\s*$}} && {{command[0]}} {{opt::(?:\s)(-[\w]+)}} {{command[1:]}} ''' ] diff --git a/rules/git.toml b/rules/git.toml index ee09980..c350cc3 100644 --- a/rules/git.toml +++ b/rules/git.toml @@ -119,7 +119,7 @@ pattern = [ suggest = [ ''' #[cmd_contains(push)] -git pull && \ +git pull && {{command}} ''', ''' #[cmd_contains(push)] @@ -136,8 +136,8 @@ suggest = [ #[cmd_contains(pull)] {{command}} --rebase --autostash ''', ''' -git stash && \ -{{command}} && \ +git stash && +{{command}} && git stash pop ''' ] diff --git a/rules/mv.toml b/rules/mv.toml index f335c65..15aabc2 100644 --- a/rules/mv.toml +++ b/rules/mv.toml @@ -7,7 +7,7 @@ pattern = [ ] suggest = [ ''' -mkdir --parents {{command[-1]}} && \ +mkdir --parents {{command[-1]}} && {{command}} ''' ] diff --git a/rules/touch.toml b/rules/touch.toml index 92903f8..3de35bb 100644 --- a/rules/touch.toml +++ b/rules/touch.toml @@ -4,14 +4,19 @@ command = "touch" pattern = [ "no such file or directory" ] suggest = [ ''' -mkdir --parents {{cmd::(?:\s)+(.*[\\\/])(?:\s)*}} && \ +#[!shell(nu)] +mkdir --parents {{cmd::(?:\s)+(.*[\\\/])(?:\s)*}} && touch {{command[1:]}} ''' ] [[match_err]] -pattern = [ "nu::shell::create_not_possible" ] +pattern = [ + "nu::shell::create_not_possible", + "no such file or directory", +] suggest = [ ''' -mkdir {{cmd::(?:\s)+(.*[\\\/])(?:\s)*}} and \ +#[shell(nu)] +mkdir {{cmd::(?:\s)+(.*[\\\/])(?:\s)*}}; touch {{command[1:]}} ''' ]