#!/bin/bash # What scripts are available #set -x . /home/default clear #Variable settings # # No need to change anything below # The parameters. TEXT="What do local scripts do?" PROGRAMS "$DIALOG" #Where to look DIR="$HOME/bin/ /usr/local/bin/" if [[ $EUID -eq 0 ]] then DIR='/root/bin/ /usr/local/bin/ /usr/local/sbin/' fi #Program specific # Make the list of all programs for FILE in `find $DIR -maxdepth 1 -executable -type f|grep -v \~` do ABOUT=`sed -n '2p' $FILE|grep ^#|grep -v "set -x"|cut -b 1-$WIDTH` if [ "$ABOUT" = "" ] then ABOUT="Edit with vi" fi ABOUT=`echo $ABOUT|sed 's/^#//g'|sed 's/^ //g'` #|sed 's/ /_/g'` NAME=`basename $FILE` echo "$NAME \"$ABOUT\" $FILE" >> $TMP done #Sort the stuff sort $TMP > $TMP.mnu #Turn it all into a menu eval "menu=( $(< $TMP.mnu) )" $DIALOG --backtitle "$TEXT" \ --item-help --title "Program selector" \ --no-cancel \ --menu "These are all the programs in\n$DIR\n" 40 60 40 \ "${menu[@]}" \ 2> $TMP #Run the command if possible KEY=$? CHOICE=`cat $TMP` clear case $KEY in 0) LINE "${txtblu}${CHOICE}${txtoff}" grep "^${CHOICE} " $TMP.mnu|sed 's/"/\n/g'|sed 's/^ //g'|awk 'FNR>1' echo "" echo "Copy and paste the above and it will run. If not, bad luck." #exec $CHOICE > /dev/null 2>&1 & ;; 1) LINE "Cancel selected";; 2) LINE "Help selected";; 255) LINE "ESC selected";; esac #End parameters exit