Skip to content

Commit b1b16d5

Browse files
committed
imp(Completions): adds fallbacks to Bash completions
With these options, in case the completion function cannot provide suggestions, Bash will perform its default completions, based on e.g. files, directories, and variable names. This is particularly useful for argument values.
1 parent 69541d6 commit b1b16d5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/completions/bash.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl<'a, 'b> BashGen<'a, 'b> {
5858
esac
5959
}}
6060
61-
complete -F _{name} {name}
61+
complete -F _{name} -o bashdefault -o default {name}
6262
",
6363
name = self.p.meta.bin_name.as_ref().unwrap(),
6464
name_opts = self.all_options_for_path(self.p.meta.bin_name.as_ref().unwrap()),

tests/completions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ fn test_generation() {
2121
let last_line = string.lines().rev().nth(0).unwrap();
2222

2323
assert_eq!(first_line, "_myapp() {");
24-
assert_eq!(last_line, "complete -F _myapp myapp");
24+
assert_eq!(last_line, "complete -F _myapp -o bashdefault -o default myapp");
2525
}

0 commit comments

Comments
 (0)