Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ######################################################
- ## GFX version OK
- #!/bin/bash
- LISTPATH="/opt/lampp/htdocs/tinymce_class/lessons/"
- prompt="Please select a file:"
- #options=( $(find -maxdepth 1 -print0 | xargs -0) )
- options=( $(find $LISTPATH -maxdepth 1 -print0 | xargs -0) )
- menu_list='';
- PS3="$prompt "
- count=0
- echo "OPTIONS = "${options[@]}
- for FILE in ${options[@]};
- do
- #menu_list="${menu_list} \"$count\" \"$FILE\" \"off\" "
- #menu_list="${menu_list} \"$FILE\" \"---\" \"off\" "
- menu_list="${menu_list} $FILE \"$count\" \"off\" "
- let "count=count+1"
- #echo $count
- done
- #echo "MENULIST= "$menu_list
- #choice=$(Xdialog --stdout --left --wrap --no-cancel --title "MY OPTIONS" --menu "Please select" 60 100 50 "${options[@]}" )
- ##shows only one###choice=$(Xdialog --stdout --left --wrap --no-cancel --title "MY OPTIONS" --checklist "Please select" 60 100 50 ${menu_list[@]} )
- choice=$(Xdialog --stdout --left --wrap --no-cancel --title "MY OPTIONS" --checklist "Please select" 60 100 50 ${menu_list[@]} )
- echo "YOUR CHOICE : "$choice
- leafpad $choice
- #ls -ld "$choice"
- ######################################################
- ## No GFX version ok working https://stackoverflow.com/questions/15807845/list-files-and-show-them-in-a-menu-with-bash
- LISTPATH="/opt/lampp/htdocs/tinymce_class/lessons/"
- prompt="Please select a file:"
- #options=( $(find -maxdepth 1 -print0 | xargs -0) )
- options=( $(find $LISTPATH -maxdepth 1 -print0 | xargs -0) )
- PS3="$prompt "
- select opt in "${options[@]}" "Quit" ; do
- if (( REPLY == 1 + ${#options[@]} )) ; then
- exit
- elif (( REPLY > 0 && REPLY <= ${#options[@]} )) ; then
- echo "You picked $opt which is file $REPLY"
- break
- else
- echo "Invalid option. Try another one."
- fi
- done
- leafpad "$opt"
- ls -ld "$opt"
- #########################################################
- ## GFX version Simple A working
- #!/bin/bash
- ###https://www.baeldung.com/linux/shell-script-simple-select-menu
- LISTPATH="/opt/lampp/htdocs/tinymce_class/lessons/"
- prompt="Please select a file:"
- #options=( $(find -maxdepth 1 -print0 | xargs -0) )
- options=( $(find $LISTPATH -maxdepth 1 -print0 | xargs -0) )
- menu_list='';
- PS3="$prompt "
- echo $options
- #ANSWER=$(Xdialog --stdout --left --wrap --icon /usr/local/lib/X11/pixmaps/nicOS.png --no-cancel --title "nicOS-Utility-Suite" --checklist "Select ." 60 100 50 ${options})
- choice=$(Xdialog --stdout --left --wrap --no-cancel --title "MY OPTIONS" \
- --menu "Please select" 60 100 50 "${options[@]}" \
- #
- #2>&1 >/dev/tty)
- )
- #ANSWER=$(Xdialog --stdout --left --wrap --icon /usr/local/lib/X11/pixmaps/nicOS.png --no-cancel --title "nicOS-Utility-Suite" --checklist "Select ." 60 100 50 ${menu_list})
- echo "YOUR CHOICE : "$choice
- leafpad "$choice"
- ls -ld "$choice"
- ####################################################
- ### GFX version (better )
Advertisement
Advertisement