menu, do a quick search, and then quick select using the quick selection
character.
### User Defined Menus
In case you find that the default menus are not enough for you and you have
the need to create your own menu, Nushell can help you with that.
In order to add a new menu that fulfills your needs, you can use one of the default
layouts as a template. The templates available in nushell are columnar, list or
description.
The columnar menu will show you data in a columnar fashion adjusting the column
number based on the size of the text displayed in your columns.
The list type of menu will always display suggestions as a list, giving you the
option to select values using `!` plus number combination.
The description type will give you more space to display a description for some
values, together with extra information that could be inserted into the buffer.
Let's say we want to create a menu that displays all the variables created
during your session, we are going to call it `vars_menu`. This menu will use a
list layout (layout: list). To search for values, we want to use only the things
that are written after the menu has been activated (only_buffer_difference:
true).
With that in mind, the desired menu would look like this
```nu
$env.config = {
...
menus = [
...
{
name: vars_menu
only_buffer_difference: true
marker: "# "
type: {
layout: list
page_size: 10
}
style: {
text: green
selected_text: green_reverse
description_text: yellow
}
source: { |buffer, position|
scope variables
| where name =~ $buffer
| sort-by name
| each { |row| {value: $row.name description: $row.type} }
}
}
...
]
...
```
As you can see, the new menu is identical to the `history_menu` previously
described. The only huge difference is the new field called [`source`](/commands/docs/source.md). The
[`source`](/commands/docs/source.md) field is a nushell definition of the values you want to display in the
menu. For this menu we are extracting the data from `scope variables` and we
are using it to create records that will be used to populate the menu.
The required structure for the record is the next one
```nu
{
value: # The value that will be inserted in the buffer