if only one container, auto select it

This commit is contained in:
Heavybullets8 2022-08-10 16:30:07 -06:00
parent 074b3d09cf
commit 6f7f18d6a4

View File

@ -31,27 +31,31 @@ for pod in "${pod_id[@]}"
do do
echo "$search" | grep "$pod" | awk '{print $4}' echo "$search" | grep "$pod" | awk '{print $4}'
done | nl -s ") " | column -t) done | nl -s ") " | column -t)
while true if [[ "${#pod_id[@]}" == 1 ]]; then
do container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}')
clear -x else
title while true
echo "$containers" do
echo clear -x
echo "0) Exit" title
read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; } echo "$containers"
if [[ $selection == 0 ]]; then echo
echo "Exiting.." echo "0) Exit"
exit read -rt 120 -p "Choose a container by number: " selection || { echo -e "\nFailed to make a selection in time" ; exit; }
elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then if [[ $selection == 0 ]]; then
echo "Error: \"$selection\" was not an option.. Try again" echo "Exiting.."
sleep 3 exit
continue elif ! echo -e "$containers" | grep -qs ^"$selection)" ; then
else echo "Error: \"$selection\" was not an option.. Try again"
break sleep 3
fi continue
done else
container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}') break
container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') fi
done
container=$(echo "$containers" | grep ^"$selection)" | awk '{print $2}')
container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}')
fi
while true while true
do do
clear -x clear -x