-
Notifications
You must be signed in to change notification settings - Fork 2
Selector Options
Selector options control how the picker displays shell output and what value
is returned when the user makes a selection. They are appended after --- on
any variable definition line.
var name = <shell> --- <options>
var name --- <options>
var name := <value> --- <options>
The --- separator is required. Options are space-separated; quote values
that contain spaces.
| Option | Effect |
|---|---|
--header "..." |
Header text shown above the picker |
--delimiter "X" |
Split each output line by X into columns |
--column N |
Show column N (1-indexed) in the picker (display only)
|
--select-column N |
Return column N (1-indexed) as the value |
--map "cmd" |
Pipe the selected value through cmd via stdin |
--multi |
Enable multi-select using Space to toggle checkboxes |
Shows a label above the selection list or input prompt:
var host --- --header "Enter the target hostname"
var container = docker ps --format "{{.Names}}" --- --header "Select container"
Works on all three variable forms (prompt-only, shell, literal).
Split each line into columns for display. --column controls what the user
sees in the picker; it never affects the return value.
var service = systemctl list-units --type=service --no-legend \
--- --delimiter " " --column 1 --header "Service"
Controls what value is returned when the user picks a row. Without this, the full original line is returned.
var auth = printf 'key\tUse SSH key\npassword\tUse password\n' \
--- --delimiter '\t' --column 2 --select-column 1 --header "Auth method"
The user sees the description (column 2: "Use SSH key") but the variable gets the key (column 1: "key").
When the user selects a line:
-
--select-columnextracts the column from the original line -
--maptransforms the extracted value
--column is display-only and never participates in the return pipeline.
Pipes the selected value through a shell command via stdin. Use this when a column extract isn't enough - for transformations like lower-casing, regex extraction, or JSON field access.
var bucket = aws s3 ls --- --map "awk '{print \$3}'" --header "Bucket"
var lower = printf 'A\nB\nC' --- --map "tr '[:upper:]' '[:lower:]'"
aws s3 ls outputs 2024-01-15 12:00:00 my-bucket per line. --map
extracts just the bucket name.
Enables selecting multiple options from a single variable prompt. This allows users to build up a list of values.
var ports = echo -e "80\n443\n8080" --- --multi --delimiter ,
When --multi is provided:
- The picker list renders interactive
[x]and[ ]checkboxes. - The user can press
Spaceto toggle an option. - The user can press
Enterto confirm their selections.
If multiple options are selected, they are mapped (if --map is used) and joined together using the --delimiter character. If --delimiter is empty, they will be joined with a comma (,) by default.
A complete example showing all options together:
var target = kubectl get pods -o wide --no-headers \
--- --delimiter " " \
--column 1 \
--select-column 6 \
--map "cut -d: -f1" \
--header "Select pod (showing name, returning IP)"