From 7e5e40c447ed1b32116782b4fa2937232ed77fd1 Mon Sep 17 00:00:00 2001 From: Zeev Diukman Date: Sun, 18 Jan 2026 08:36:21 +0200 Subject: [PATCH] feat: Make the first item the default selection in `select` menus when no input is provided. --- z.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/z.sh b/z.sh index 7104e50..9eb8006 100755 --- a/z.sh +++ b/z.sh @@ -15,8 +15,11 @@ if [ ${#disks[@]} -eq 0 ]; then exit 1 fi -PS3="Select a disk to choose partitions from: " +PS3="Select a disk to choose partitions from (default 1): " select disk_info in "${disks[@]}"; do + if [[ -z "$REPLY" ]]; then + disk_info="${disks[0]}" + fi if [[ -n "$disk_info" ]]; then selected_disk=$(echo "$disk_info" | awk '{print $1}') break @@ -44,9 +47,12 @@ get_partition() { echo "" echo "$prompt" - PS3="$ps3_val" + PS3="$ps3_val (default 1): " local selection select selection in "${parts[@]}"; do + if [[ -z "$REPLY" ]]; then + selection="${parts[0]}" + fi if [[ -n "$selection" ]]; then eval "$var_name=$(echo "$selection" | cut -d' ' -f1)" break