I would like to try out a shell script that makes use of whiptail, but I am on a MAC and whiptail doesn't seem to exist there. Does anyone know if there exists a drop-in alternative (like, for example exa for ls)?
This is the script I would like to test out (It's a WP-CLI script that would allow me to select local WordPress installs, using a dialog. Found it at the bottom of this page):
#!/bin/bash
WP_TOP_PATH="/home/"
MENU_TEXT="Choose an installation"
GAUGE_TEXT="Searching for WordPress"
declare -a MENU
WPS="$(wp --allow-root find "$WP_TOP_PATH" --field=version_path)"
WP_TOTAL="$(wc -l <<< "$WPS")"
WP_COUNT="0"
while read -r WP; do
WP_LOCAL="${WP%wp-includes/version.php}"
NAME="$(cd "$WP_LOCAL"; sudo -u "$(stat . -c %U)" -- wp --no-debug --quiet option get blogname)"
if [ -z "$NAME" ]; then
NAME="(unknown)"
fi
MENU+=( "$WP_LOCAL" "$NAME" )
echo "$((++WP_COUNT * 100 / WP_TOTAL))".
done <<< "$WPS" > >(whiptail --gauge "$GAUGE_TEXT" 7 74 0)
WP_LOCAL="$(whiptail --title "WordPress" --menu "$MENU_TEXT" $((${#MENU[*]} / 2 + 7)) 74 10 "${MENU[@]}" 3>&1 1>&2 2>&3)"
if [ $? -ne 0 ] || [ ! -d "$WP_LOCAL" ]; then
echo "Cannot find '${WP_LOCAL}'" 1>&2
exit 100
fi
echo "cd ${WP_LOCAL}"