torrent/nushell/examples/menu.nu
2024-01-13 13:01:54 +03:00

32 lines
947 B
Plaintext

let new_menu = {
name: new_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|
$nu.scope.vars
| where name =~ $buffer
| sort-by name
| each { |it| {value: $it.name description: $it.type} }
}
}
$env.config.menus = ($env.config.menus | append $new_menu)
# let $nu.scope.vars = [{
# value: # The value that will be inserted in the buffer
# description: # Optional. Description that will be display with the selected value
# span: { # Optional. Span indicating what section of the string will be replaced by the value
# start:
# end:
# }
# extra: [string] # Optional. A list of strings that will be displayed with the selected value. Only works with a description menu
# }]