remote?: string@"nu-complete git remotes", # the name of the remote
refspec?: string@"nu-complete git branches" # the branch / refspec
...
]
```
Custom completions will serve the same role in this example as in the previous examples. The examples above call into two different custom completions, based on the position the user is currently in.
## Custom Descriptions and Styles
As an alternative to returning a list of strings, a completion function can also return a list of records with a `value` field as well as optional `description` and `style` fields. The style can be one of the following:
- A string with the foreground color, either a hex code or a color name such as `yellow`. For a list of valid color names, see `ansi --list`.
- A record with the fields `fg` (foreground color), `bg` (background color), and `attr` (attributes such as underline and bold). This record is in the same format that `ansi --escape` accepts. See the [`ansi`](/commands/docs/ansi) command reference for a list of possible values for the `attr` field.
- The same record, but converted to a JSON string.
```nu
def my_commits [] {
[
{ value: "5c2464", description: "Add .gitignore", style: red },
# "attr: ub" => underlined and bolded
{ value: "f3a377", description: "Initial commit", style: { fg: green, bg: "#66078c", attr: ub } }
]
}
```
::: tip Note
With the following snippet:
```nu
def my-command [commit: string@my_commits] {
print $commit
}
```
... be aware that, even though the completion menu will show you something like
```ansi
>_ [36mmy-command[0m <TAB>
[1;31m5c2464[0m [33mAdd .gitignore[0m
[1;4;48;2;102;7;140;32mf3a377 [0m[33mInitial commit[0m
```
... only the value (i.e., "5c2464" or "f3a377") will be used in the command arguments!
:::
## External Completions
External completers can also be integrated, instead of relying solely on Nushell ones.
For this, set the `external_completer` field in `config.nu` to a [closure](types_of_data.md#closures) which will be evaluated if no Nushell completions were found.
```nu
$env.config.completions.external = {
enable: true
max_results: 100
completer: $completer
}
```
You can configure the closure to run an external completer, such as [carapace](https://github.com/rsteube/carapace-bin).
An external completer is a function that takes the current command as a string list, and outputs a list of records with `value` and `description` keys, like custom completion functions. When the closure returns `null`, it defaults to file completion.
::: tip Note
This closure will accept the current command as a list. For example, typing `my-command --arg1 <tab>` will receive `[my-command --arg1 " "]`.
:::
This example will enable carapace external completions:
```nu
let carapace_completer = {|spans|
carapace $spans.0 nushell ...$spans | from json
}
```
[More examples of custom completers can be found in the cookbook](../cookbook/external_completers.md).