Browse Source

Added interface completion + Style

Also, forgot to give a command that's pretty crucial! :O
master
Brandon Nolet 2 years ago
parent
commit
f3d1b6402b
1 changed files with 8 additions and 3 deletions
  1. +8
    -3
      nmcli-basic.sh

+ 8
- 3
nmcli-basic.sh View File

@@ -75,7 +75,7 @@ function conshow() {
read -p "Which interface to configure? " IntID
if [[ ${IntID} != '' ]]; then #empty strings make grep have a fit
nmcli -t con show | cut -d : -f 1 | grep $IntID &> /dev/null
nmcli -t con show | cut -d : -f 1 | grep ${IntID} &> /dev/null
if [[ $? != 0 ]]; then #checking for valid interface name being input
echo
echo "Sorry, that's not the name of a valid interface, try again"
@@ -84,6 +84,8 @@ function conshow() {
conshow #would love to have a non-inception like way to do this.
else
#incomplete entry of interface results in completion by grep ;) Interesting I suppose
IntID=$(nmcli -t con show | cut -d : -f 1 | grep ${IntID} | head -1)
return 0 #If the input matches the name of an interface, move on
fi
else #empty string is empty, prompt again
@@ -107,7 +109,9 @@ function getchoice() {
setstatic
;;
*)
"Sorry, that's not a valid choice"
echo
echo "Sorry, that's not a valid choice"
echo
sleep 1
getchoice
;;
@@ -126,7 +130,8 @@ case "$1" in
usage
;;
"")
getchoice
;;
*)
echo "Sorry, argument '${1}' not understood."
echo "Try passing 'usage' instead"


Loading…
Cancel
Save