I am doing a theming tool script. I want to make a selection menu of zip files (zip file contain theme) in a directory, then users will choose a zip file they want to install

Example: in /theme/zipfiles/ has theme1.zip, theme2.zip, theme3.zip (users can add more theme zip file)

And I want to list those zip files in script like this:

Choose a theme zip file to install:
1) theme1.zip
2) theme2.zip
3) theme3.zip
# When users add more zip files and this menu will display more

Then I type 1 and Enter. The theme1.zip should be installing


You could use select. First, set $PS3 for the prompt, and then, use select like a loop, breaking when you have correct data to get the desired information:

PS3="Choose a theme zip file to install:"
select theme_file in *.zip; do
    [[ -f "$theme_file" ]] && break

echo "Installing ${theme_file%.zip} from ${theme_file}..."
  • PS3=`echo -e "\e[1mChoose\e[21m a theme zip file to install:"` if you want to emphasize "choose" Jul 5 '16 at 20:56
  • I don't see any code to show the theme file directory Jul 6 '16 at 4:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.