fix: use Host line instead of HostName

This commit is contained in:
Jeffrey Serio 2023-07-12 23:49:23 -05:00
parent a2540ce77e
commit af87759ab1

10
gumssh
View File

@ -18,16 +18,16 @@ logins=()
# Read Users from ssh config and store them in usern_array.
while IFS= read -r line; do
if [[ "$line" == *"User"* ]]; then
usern=$(echo $line | awk '{ print $2 }')
usern_array+=($usern)
usern=$(echo "$line" | awk '{ print $2 }')
usern_array+=("$usern")
fi
done < "${SSH_CONFIG}"
# Read HostNames from ssh config and store them in hostn_array.
while IFS= read -r line; do
if [[ "$line" == *"HostName"* ]]; then
if [[ "$line" == *"Host "* ]]; then
hostn=$(echo $line | awk '{ print $2 }')
hostn_array+=($hostn)
hostn_array+=("$hostn")
fi
done < "${SSH_CONFIG}"
@ -38,7 +38,7 @@ let "array_len = ${#usern_array[@]} - 1"
# pairs, then store them in the logins array in "user@host" format.
for i in $(seq 0 $array_len); do
userhost=$(printf "%s@%s" "${usern_array[i]}" "${hostn_array[i]}")
logins+=($userhost)
logins+=("$userhost")
done
# Print each member of logins array on a new line and pipe to gum choose.