Skip to main content Skills Marketplace Descubre y explora habilidades de IA creadas por la comunidad.
Ocupaciones relacionadas SOC
Basado en la clasificación ocupacional SOC
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Copiar promptMostrar detalles del prompt Un comando directo omite el prompt de revisión. Revisa el origen antes de ejecutarlo.
npx skills add https://github.com/majiayu000/claude-skill-registry --skill interactive-menu-builderEl comando permanece en una sola línea. Desplázate horizontalmente para revisarlo antes de copiarlo.
¿Prefieres una copia local? Descarga los archivos que SkillsMP tiene disponibles ahora.
Descargar Zip Descargando... Explorador de archivos
2 archivos name interactive-menu-builder version 1.0.0 description Build multi-level interactive CLI menus for bash scripts author workspace-hub category bash tags ["bash","menu","cli","interactive","tui","navigation"] platforms ["linux","macos"]
Interactive Menu Builder
Patterns for building professional multi-level interactive menus in bash scripts. Extracted from workspace-hub's workspace CLI and repository_sync tools.
When to Use This Skill
✅ Use when:
Building user-friendly CLI tools
Need navigation through multiple options
Complex tools with many sub-commands
Tools used by humans (not just automation)
Consolidating multiple scripts into one interface
❌ Avoid when:
Scripts meant for automation/CI
Simple single-purpose scripts
When a plain command-line interface is sufficient
Core Capabilities
1. Basic Menu Structure
Single-level menu with numbered options:
#!/bin/bash
CYAN='\033[0;36m'
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
show_menu () {
clear
echo -e "${CYAN} ═══════════════════════════════════════${NC} "
echo -e "${CYAN} Main Menu${NC} "
echo -e "${CYAN} ═══════════════════════════════════════${NC} "
echo ""
echo " 1) Option One"
echo " 2) Option Two"
echo " 3) Option Three"
echo ""
echo " 0) Exit"
echo ""
echo -e "${CYAN} ═══════════════════════════════════════${NC} "
echo ""
}
handle_choice () {
local choice="$1 "
case "$choice " in
1)
echo
;;
2)
;;
3)
;;
0)
0
;;
*)
-e
;;
}
;
show_menu
-p choice
handle_choice
-p
2. Multi-Level Menu System
Hierarchical menu with breadcrumb navigation:
#!/bin/bash
declare -a MENU_STACK=("main" )
CURRENT_MENU="main"
declare -A MENU_TITLES=(
["main" ]="Main Menu"
["repo" ]="Repository Management"
["repo_ops" ]="Repository Operations"
["compliance" ]="Compliance & Standards"
["tools" ]="Development Tools"
)
push_menu () {
local menu="$1 "
MENU_STACK+=("$menu " )
CURRENT_MENU="$menu "
}
pop_menu () {
if [[ ${#MENU_STACK[@]} -gt 1 ]]; then
unset 'MENU_STACK[-1]'
CURRENT_MENU="${MENU_STACK[-1]} "
fi
}
show_breadcrumb () {
local crumb=""
for menu in "${MENU_STACK[@]} " ; do
[[ -n " " ]] && crumb+=
crumb+=
-e
}
() {
clear
-e
-e
-e
show_breadcrumb
}
() {
clear
-e
show_breadcrumb
-e
}
() {
choice=
main)
1) push_menu ;;
2) push_menu ;;
3) push_menu ;;
4) run_system_config ;;
5) run_help ;;
0) 0 ;;
;;
repo)
1) run_repo_sync ;;
2) run_configure_urls ;;
3) run_check_status ;;
4) push_menu ;;
0) pop_menu ;;
;;
}
() {
main) show_main_menu ;;
repo) show_repo_menu ;;
}
;
show_current_menu
-p choice
handle_menu
3. Table Display
Display data in formatted tables:
#!/bin/bash
print_table_header () {
local -a headers=("$@ " )
local format=""
for header in "${headers[@]} " ; do
format+="%-20s "
done
echo ""
printf "${CYAN} ${format} ${NC} \n" "${headers[@]} "
printf "${CYAN} %s${NC} \n" "$(printf '─%.0s' {1..80}) "
}
print_table_row () {
local format=""
local -a values=("$@ " )
for _ in "${values[@]} " ; do
format+="%-20s "
done
printf "${format} \n" "${values[@]} "
}
() {
print_table_header
repo ;
category=$(get_category )
status=$(get_status )
branch=$(get_branch )
) status= ;;
) status= ;;
) status= ;;
print_table_row
}
4. Selection Lists
Let users select from a list:
#!/bin/bash
select_single () {
local prompt="$1 "
shift
local -a options=("$@ " )
echo ""
for i in "${!options[@]} " ; do
echo " $((i+1) )) ${options[$i]} "
done
echo ""
echo " 0) Cancel"
echo ""
read -p "$prompt : " choice
if [[ "$choice " == "0" ]]; then
return 1
elif [[ "$choice " -ge 1 && "$choice " -le ${#options[@]} ]]; then
SELECTED="${options[$((choice-1))]} "
return 0
else
echo -e "${RED} Invalid selection "
1
}
() {
prompt=
-a options=( )
-a selected=()
i ;
-p input
[[ == ]];
SELECTED=( )
0
num ;
[[ -ge 1 && -le ]];
selected+=( )
SELECTED=( )
[[ -gt 0 ]]
}
repos=( )
select_single ;
select_multiple ;
5. Confirmation Dialogs
Request user confirmation:
#!/bin/bash
confirm () {
local prompt="${1:-Are you sure?} "
local default="${2:-n} "
if [[ "$default " == "y" ]]; then
prompt+=" [Y/n]: "
else
prompt+=" [y/N]: "
fi
read -p "$prompt " response
response="${response:-$default } "
[[ "${response,,} " == "y" || "${response,,} " == "yes" ]]
}
confirm_action () {
local action="$1 "
local details="$2 "
echo ""
echo -e "${YELLOW} ⚠ Confirmation Required${NC} "
echo ""
echo "Action: $action "
[[ -n ]] &&
confirm
}
() {
action=
confirm_word=
-e
-e
-p response
[[ == ]]
}
confirm ;
-rf logs/*
confirm_dangerous ;
6. Progress Indicators
Show progress during operations:
#!/bin/bash
spinner () {
local pid=$1
local message="${2:-Processing} "
local spin='⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
local i=0
while kill -0 "$pid " 2>/dev/null; do
i=$(( (i+1 ) % ${#spin} ))
printf "\r${CYAN} %s${NC} %s" "${spin:$i:1} " "$message "
sleep 0.1
done
printf "\r${GREEN} ✓${NC} %s\n" "$message "
}
long_running_task &
spinner $! "Running long task..."
progress_bar () {
local current=$1
local total=$2
local width=40
local percent=$((current * 100 / total))
local filled=$((current * width / total))
local empty=$((width - filled))
printf
|
|
}
total=100
i $( 1 );
progress_bar
0.05
() {
message=
}
() {
message=
-e
}
() {
message=
-e
}
() {
message=
-e
}
Complete Example: Multi-Level Menu System
Full implementation from workspace CLI:
#!/bin/bash
set -e
SCRIPT_NAME="$(basename "$0 " ) "
VERSION="1.0.0"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
MAGENTA='\033[0;35m'
BOLD='\033[1m'
NC='\033[0m'
CURRENT_MENU="main"
declare -a MENU_HISTORY=()
clear_screen () {
printf "\033c"
}
print_header () {
local title="$1 "
local width=60
echo ""
echo -e "${CYAN} $(printf '═%.0s' $(seq 1 $width) )${NC} "
printf "${CYAN} %*s${NC} \n" $((( +width)/ ))
-e
}
() {
[[ -gt 0 ]];
path=
menu ;
[[ -n ]] && path+=
path+=
path+=
-e
}
() {
num=
text=
desc=
[[ -n ]] &&
}
() {
-p
}
() {
MENU_HISTORY+=( )
CURRENT_MENU=
}
() {
[[ -gt 0 ]];
CURRENT_MENU=
}
() {
clear_screen
print_header
print_option 1
print_option 2
print_option 3
print_option 4
print_option 5
print_option 6
print_option 0
}
() {
clear_screen
print_header
print_breadcrumb
print_option 1
print_option 2
print_option 3
print_option 4
print_option 0
}
() {
clear_screen
print_header
print_breadcrumb
print_option 1
print_option 2
print_option 3
print_option 0
}
() {
-e
-e
wait_key
}
() {
-e
wait_key
}
() {
choice=
1) navigate_to ;;
2) navigate_to ;;
3) navigate_to ;;
4) run_system_config ;;
5) run_help ;;
6) run_about ;;
0) ; 0 ;;
*) -e ; 1 ;;
}
() {
choice=
1) run_sync_repos ;;
2) run_clone_repos ;;
3) run_check_status ;;
4) navigate_to ;;
0) navigate_back ;;
*) -e ; 1 ;;
}
() {
choice=
1) run_propagate_config ;;
2) run_verify_compliance ;;
3) run_install_hooks ;;
0) navigate_back ;;
*) -e ; 1 ;;
}
() {
;
main)
show_main_menu
-p choice
handle_main_menu
;;
repo)
show_repo_menu
-p choice
handle_repo_menu
;;
compliance)
show_compliance_menu
-p choice
handle_compliance_menu
;;
*)
CURRENT_MENU=
;;
}
main
Best Practices
1. Consistent Navigation
0 always goes back/exits
Numbers 1-9 for options
Use q as alternative to 0 for exit
2. Clear Visual Hierarchy
Headers separate sections
Indentation shows grouping
Colors indicate meaning
3. Feedback on Actions
Show progress during operations
Confirm completion
Display errors clearly
4. Graceful Error Handling
Invalid input shouldn't crash
Show helpful error messages
Allow retry
Resources
Version History
1.0.0 (2026-01-14): Initial release - extracted from workspace-hub CLI tools
"Running Option One..."
echo
"Running Option Two..."
echo
"Running Option Three..."
echo
"Goodbye!"
exit
echo
"${RED} Invalid option${NC} "
esac
while
true
do
read
"Select option: "
"$choice "
echo
""
read
"Press Enter to continue..."
done
$crumb
" > "
"${MENU_TITLES[$menu]} "
done
echo
"${CYAN} $crumb${NC} "
show_main_menu
echo
"${CYAN} ═══════════════════════════════════════════════════════${NC} "
echo
"${CYAN} Workspace Hub - Management Console${NC} "
echo
"${CYAN} ═══════════════════════════════════════════════════════${NC} "
echo
""
echo
""
echo
" 1) Repository Management"
echo
" 2) Compliance & Standards"
echo
" 3) Development Tools"
echo
" 4) System Configuration"
echo
" 5) Help & Documentation"
echo
""
echo
" 0) Exit"
echo
""
show_repo_menu
echo
"${CYAN} ═══════════════════════════════════════════════════════${NC} "
echo
"${CYAN} ═══════════════════════════════════════════════════════${NC} "
echo
""
echo
" 1) Repository Sync Manager"
echo
" 2) Configure Repository URLs"
echo
" 3) Check All Repository Status"
echo
" 4) Clone Repositories"
echo
""
echo
" 0) Back"
echo
""
handle_menu
local
"$1 "
case
"$CURRENT_MENU "
in
case
"$choice "
in
"repo"
"compliance"
"tools"
exit
esac
case
"$choice "
in
"repo_ops"
esac
esac
show_current_menu
case
"$CURRENT_MENU "
in
esac
while
true
do
read
"Select option: "
"$choice "
done
show_repo_table
"Repository"
"Category"
"Status"
"Branch"
for
in
"${REPOS[@]} "
do
local
"$repo "
local
"$repo "
local
"$repo "
case
"$status "
in
"Clean"
"${GREEN} Clean${NC} "
"Modified"
"${YELLOW} Modified${NC} "
"Untracked"
"${RED} Untracked${NC} "
esac
"$repo "
"$category "
"$status "
"$branch "
done
${NC}
return
fi
select_multiple
local
"$1 "
shift
local
"$@ "
local
echo
""
echo
"Enter numbers separated by spaces (or 'all' for all):"
echo
""
for
in
"${!options[@]} "
do
echo
" $((i+1) )) ${options[$i]} "
done
echo
""
read
"$prompt : "
if
"$input "
"all"
then
"${options[@]} "
return
fi
for
in
$input
do
if
"$num "
"$num "
${#options[@]}
then
"${options[$((num-1))]} "
fi
done
"${selected[@]} "
${#SELECTED[@]}
"repo1"
"repo2"
"repo3"
"repo4"
if
"Select repository"
"${repos[@]} "
then
echo
"You selected: $SELECTED "
fi
if
"Select repositories"
"${repos[@]} "
then
echo
"You selected: ${SELECTED[*]} "
fi
"$details "
echo
"Details: $details "
echo
""
"Proceed?"
"n"
confirm_dangerous
local
"$1 "
local
"${2:-DELETE} "
echo
""
echo
"${RED} ⚠ DANGEROUS OPERATION${NC} "
echo
""
echo
"This action cannot be undone!"
echo
"Action: $action "
echo
""
echo
"Type '${YELLOW} ${confirm_word} ${NC} ' to confirm:"
read
"> "
"$response "
"$confirm_word "
if
"Delete all logs?"
then
rm
fi
if
"Delete all repositories"
"DELETE"
then
echo
"Proceeding..."
fi
"\r["
printf
"%${filled} s"
tr
' '
'█'
printf
"%${empty} s"
tr
' '
'░'
printf
"] %3d%% (%d/%d)"
"$percent "
"$current "
"$total "
for
in
seq
$total
do
$i
$total
sleep
done
echo
""
status_line
local
"$1 "
printf
"\r\033[K%s"
"$message "
mark_done
local
"$1 "
echo
"${GREEN} ✓${NC} $message "
mark_fail
local
"$1 "
echo
"${RED} ✗${NC} $message "
mark_skip
local
"$1 "
echo
"${YELLOW} ⊘${NC} $message "
${#title}
2
"$title "
echo
"${CYAN} $(printf '═%.0s' $(seq 1 $width) )${NC} "
echo
""
print_breadcrumb
if
${#MENU_HISTORY[@]}
then
local
""
for
in
"${MENU_HISTORY[@]} "
do
"$path "
" > "
"$menu "
done
" > $CURRENT_MENU "
echo
"${BLUE} $path${NC} "
echo
""
fi
print_option
local
"$1 "
local
"$2 "
local
"${3:-} "
printf
" ${BOLD} %2s)${NC} %-25s"
"$num "
"$text "
"$desc "
printf
"${CYAN} %s${NC} "
"$desc "
echo
""
wait_key
echo
""
read
"Press Enter to continue..."
navigate_to
"$CURRENT_MENU "
"$1 "
navigate_back
if
${#MENU_HISTORY[@]}
then
"${MENU_HISTORY[-1]} "
unset
'MENU_HISTORY[-1]'
fi
show_main_menu
"Workspace Hub Management Console"
echo
" ${BOLD} Workspace Management:${NC} "
echo
""
"Repository Management"
"Git operations"
"Compliance & Standards"
"Code standards"
"Development Tools"
"Dev utilities"
"System Configuration"
"Setup"
echo
""
echo
" ${BOLD} Information:${NC} "
echo
""
"Help & Documentation"
"About"
echo
""
"Exit"
echo
""
show_repo_menu
"Repository Management"
"Sync All Repositories"
"Pull/push all"
"Clone Missing Repos"
"Download new"
"Check Status"
"Git status"
"Branch Operations"
"Branch management"
echo
""
"Back"
echo
""
show_compliance_menu
"Compliance & Standards"
"Propagate Configuration"
"Sync settings"
"Verify Compliance"
"Check standards"
"Install Hooks"
"Git hooks"
echo
""
"Back"
echo
""
run_sync_repos
echo
""
echo
"${CYAN} Syncing all repositories...${NC} "
echo
"${GREEN} ✓ Sync complete${NC} "
run_check_status
echo
""
echo
"${CYAN} Checking repository status...${NC} "
handle_main_menu
local
"$1 "
case
"$choice "
in
"repo"
"compliance"
"tools"
echo
"Goodbye!"
exit
echo
"${RED} Invalid option${NC} "
sleep
esac
handle_repo_menu
local
"$1 "
case
"$choice "
in
"branches"
echo
"${RED} Invalid option${NC} "
sleep
esac
handle_compliance_menu
local
"$1 "
case
"$choice "
in
echo
"${RED} Invalid option${NC} "
sleep
esac
main
while
true
do
case
"$CURRENT_MENU "
in
read
"Select option: "
"$choice "
read
"Select option: "
"$choice "
read
"Select option: "
"$choice "
echo
"Unknown menu: $CURRENT_MENU "
"main"
esac
done
"$@ "