You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/custom_completions.md
+4-6Lines changed: 4 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ In the second line, `string@animals` tells Nushell two things—the shape of the
29
29
The third line is demonstration of the completion. Type the name of the custom command `my-command`, followed by a space, and then the <kbd>Tab</kbd> key. This displays a menu with the possible completions. Custom completions work the same as other completions in the system, allowing you to type `e` followed by the <kbd>Tab</kbd> key to complete "eel" automatically.
30
30
31
31
::: tip
32
-
When the completion menu is displayed, the prompt changes to include the `|` character by default. To change the prompt marker, modify the `marker` value of the record, where the `name` key is `completion_menu`, in the `$env.config.menus` list. See also [the completion menu configuration](/book/line_editor.md#completion-menu).
32
+
When the completion menu is displayed, the prompt changes to include the `|` character by default. To change the prompt marker, modify the `marker` value of the record, where the `name` key is `completion_menu`, in the `$env.config.menus` list. See also [the completion menu configuration](/book/line_editor.md#completion-menu).
33
33
:::
34
34
35
35
::: tip
@@ -42,8 +42,7 @@ If you want to choose how your completions are filtered and sorted, you can also
42
42
43
43
-`sort` - Set this to `false` to stop Nushell from sorting your completions. By default, this is `true`, and completions are sorted according to `$env.config.completions.sort`.
44
44
-`case_sensitive` - Set to `true` for the custom completions to be matched case sensitively, `false` otherwise. Used for overriding `$env.config.completions.case_sensitive`.
45
-
-`completion_algorithm` - Set this to either `prefix` or `fuzzy` to choose how your completions are matched against the typed text. Used for overriding `$env.config.completions.algorithm`.
46
-
-`positional` - When prefix matching is used, setting this to `false` will use substring matching instead. `true` by default.
45
+
-`completion_algorithm` - Set this to `prefix`, `substring`, or `fuzzy` to choose how your completions are matched against the typed text. Used for overriding `$env.config.completions.algorithm`.
47
46
48
47
Here's an example demonstrating how to set these options:
49
48
@@ -52,8 +51,7 @@ def animals [] {
52
51
{
53
52
options: {
54
53
case_sensitive: false,
55
-
completion_algorithm: prefix,
56
-
positional: false,
54
+
completion_algorithm: substring,
57
55
sort: false,
58
56
},
59
57
completions: [cat, rat, bat]
@@ -69,7 +67,7 @@ Now, if you try to complete `A`, you get the following completions:
69
67
cat rat bat
70
68
```
71
69
72
-
Because we made matching case-insensitive and used `positional: false`, Nushell will find the substring "a" in all of the completion suggestions. Additionally, because we set `sort: false`, the completions will be left in their original order. This is useful if your completions are already sorted in a particular order unrelated to their text (e.g. by date).
70
+
Because we made matching case-insensitive, Nushell will find the substring "a" in all of the completion suggestions. Additionally, because we set `sort: false`, the completions will be left in their original order. This is useful if your completions are already sorted in a particular order unrelated to their text (e.g. by date).
0 commit comments