2023-08-04 16:20:09 +03:00
|
|
|
# select
|
|
|
|
|
|
|
|
> Bash builtin construct for creating menus.
|
|
|
|
> More information: <https://www.gnu.org/software/bash/manual/bash.html#index-select>.
|
|
|
|
|
|
|
|
- Create a menu out of individual words:
|
|
|
|
|
2024-03-03 11:29:38 +01:00
|
|
|
`select {{word}} in {{apple orange pear banana}}; do echo ${{word}}; done`
|
2023-08-04 16:20:09 +03:00
|
|
|
|
2024-02-25 18:51:18 +02:00
|
|
|
- Create a menu from the output of another command:
|
2023-08-04 16:20:09 +03:00
|
|
|
|
2024-02-25 18:51:18 +02:00
|
|
|
`select {{line}} in $({{command}}); do echo ${{line}}; done`
|
|
|
|
|
|
|
|
- Specify the prompt string for `select` and create a menu for picking a file or folder from the current directory:
|
|
|
|
|
|
|
|
`PS3="{{Select a file: }}"; select {{file}} in *; do echo ${{file}}; done`
|
2023-08-04 16:20:09 +03:00
|
|
|
|
|
|
|
- Create a menu from a Bash array:
|
|
|
|
|
$, case, continue, coproc, getopts, select, suspend, ulimit, while: refresh page (#17687)
Refreshed $, case, continue, coproc, getopts, select, suspend, ulimit, while .md pages
2025-08-16 21:28:41 +03:00
|
|
|
`{{fruits}}={{(apple orange pear banana)}}; select {{word}} in ${{{fruits[@]}}}; do echo ${{word}}; done`
|