Use gum file browser for folder selection in target picker

Replace manual path input with gum file --directory for browsing
and selecting folders. Adds duplicate detection. Shows selected
count in menu header.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-05 22:22:33 +02:00
parent a27ae7faf4
commit f80c786597

View File

@@ -139,23 +139,29 @@ ui_target_folder_picker() {
items+=("$i" "$f") items+=("$i" "$f")
((i++)) ((i++))
done done
items+=("ADD" "Add folder") items+=("ADD" "Browse & add folder")
[[ ${#folders[@]} -gt 0 ]] && items+=("REMOVE" "Remove folder") [[ ${#folders[@]} -gt 0 ]] && items+=("REMOVE" "Remove folder")
items+=("DONE" "Finish selection") items+=("DONE" "Finish selection")
local choice local choice
choice=$(ui_menu "Folder Picker" "${items[@]}") || return 1 choice=$(ui_menu "Folder Picker (${#folders[@]} selected)" "${items[@]}") || return 1
case "$choice" in case "$choice" in
ADD) ADD)
local path local path
path=$(ui_inputbox "Add Folder" "Enter absolute folder path:" "/") || continue path=$(gum file --directory --header "Select folder to back up" \
--cursor.foreground "$_GUM_ACCENT" --height 15 /) || continue
[[ -z "$path" ]] && continue [[ -z "$path" ]] && continue
if [[ "$path" != /* ]]; then # Avoid duplicates
ui_msgbox "Path must be absolute (start with /)." local dup=false
continue for f in "${folders[@]}"; do
fi [[ "$f" == "$path" ]] && dup=true
done
if $dup; then
ui_msgbox "Folder '$path' is already selected."
else
folders+=("$path") folders+=("$path")
fi
;; ;;
REMOVE) REMOVE)
local -a rm_items=() local -a rm_items=()