Open file browser immediately in folder picker
- First gum file browser opens right after target name entry - Shows selected folders list, then offers Add/Remove/Done - No extra menu step before the first folder selection Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -132,27 +132,36 @@ ui_target_folder_picker() {
|
|||||||
IFS=',' read -ra folders <<< "$existing"
|
IFS=',' read -ra folders <<< "$existing"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# If no existing folders, open file browser immediately
|
||||||
|
if [[ ${#folders[@]} -eq 0 ]]; then
|
||||||
|
local path
|
||||||
|
path=$(gum file --directory --header "Select folder to back up (Esc when done)" \
|
||||||
|
--cursor.foreground "$_GUM_ACCENT" --height 15 /) || return 1
|
||||||
|
[[ -z "$path" ]] && return 1
|
||||||
|
[[ "$path" != /* ]] && path="/$path"
|
||||||
|
folders+=("$path")
|
||||||
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
local -a items=()
|
# Show current selection and options
|
||||||
local i=1
|
local selected_list=""
|
||||||
for f in "${folders[@]}"; do
|
local i
|
||||||
items+=("$i" "$f")
|
for i in "${!folders[@]}"; do
|
||||||
((i++))
|
selected_list+=" $(( i + 1 )). ${folders[$i]}\n"
|
||||||
done
|
done
|
||||||
items+=("ADD" "Browse & add folder")
|
|
||||||
[[ ${#folders[@]} -gt 0 ]] && items+=("REMOVE" "Remove folder")
|
|
||||||
items+=("DONE" "Finish selection")
|
|
||||||
|
|
||||||
local choice
|
local action
|
||||||
choice=$(ui_menu "Folder Picker (${#folders[@]} selected)" "${items[@]}") || return 1
|
action=$(ui_menu "Selected folders:\n${selected_list}" \
|
||||||
|
"ADD" "Add another folder" \
|
||||||
|
"REMOVE" "Remove a folder" \
|
||||||
|
"DONE" "Done — use these ${#folders[@]} folder(s)") || return 1
|
||||||
|
|
||||||
case "$choice" in
|
case "$action" in
|
||||||
ADD)
|
ADD)
|
||||||
local path
|
local path
|
||||||
path=$(gum file --directory --header "Select folder to back up" \
|
path=$(gum file --directory --header "Select folder to back up" \
|
||||||
--cursor.foreground "$_GUM_ACCENT" --height 15 /) || continue
|
--cursor.foreground "$_GUM_ACCENT" --height 15 /) || continue
|
||||||
[[ -z "$path" ]] && continue
|
[[ -z "$path" ]] && continue
|
||||||
# gum file returns path relative to start dir — make absolute
|
|
||||||
[[ "$path" != /* ]] && path="/$path"
|
[[ "$path" != /* ]] && path="/$path"
|
||||||
# Avoid duplicates
|
# Avoid duplicates
|
||||||
local dup=false
|
local dup=false
|
||||||
@@ -173,9 +182,18 @@ ui_target_folder_picker() {
|
|||||||
((j++))
|
((j++))
|
||||||
done
|
done
|
||||||
local idx
|
local idx
|
||||||
idx=$(ui_menu "Remove Folder" "${rm_items[@]}") || continue
|
idx=$(ui_menu "Remove which folder?" "${rm_items[@]}") || continue
|
||||||
unset 'folders[idx]'
|
unset 'folders[idx]'
|
||||||
folders=("${folders[@]}")
|
folders=("${folders[@]}")
|
||||||
|
if [[ ${#folders[@]} -eq 0 ]]; then
|
||||||
|
ui_msgbox "All folders removed. Please select at least one."
|
||||||
|
local path
|
||||||
|
path=$(gum file --directory --header "Select folder to back up" \
|
||||||
|
--cursor.foreground "$_GUM_ACCENT" --height 15 /) || return 1
|
||||||
|
[[ -z "$path" ]] && return 1
|
||||||
|
[[ "$path" != /* ]] && path="/$path"
|
||||||
|
folders+=("$path")
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
DONE)
|
DONE)
|
||||||
local result
|
local result
|
||||||
|
|||||||
Reference in New Issue
Block a user