diff --git a/ssh.bash b/ssh.bash index 435c4c2..e0afe7a 100755 --- a/ssh.bash +++ b/ssh.bash @@ -15,21 +15,36 @@ ssh_read_data() { read -r ssh_password < <(echo "$contents") while read -r line; do - if [[ "$line" == ssh:* ]]; then - local ssh_address=${line#"ssh:"} - ssh_address=${ssh_address##+([[:space:]])} - fi - if [[ "$line" == sshflags:* ]]; then - local ssh_flags=${line#"sshflags:"} - ssh_flags=${ssh_flags##+([[:space:]])} - fi + if [[ "$line" == ssh:* ]]; then + local ssh_address=${line#"ssh:"} + ssh_address=${ssh_address##+([[:space:]])} + fi + if [[ "$line" == sshflags:* ]]; then + local ssh_flags=${line#"sshflags:"} + ssh_flags=${ssh_flags##+([[:space:]])} + fi + if [[ "$line" == user:* ]]; then + local ssh_user=${line#"user:"} +# ssh_user=${ssh_user##+([[:space::]])} + fi + if [[ "$line": == IP:* ]]; then + local ssh_host=${line#"IP:"} +# ssh_host=${ssh_host##+([[:space::]])} + fi done < <(echo "$contents") + if [[ -z ${ssh_address+x} ]]; then + ssh_address="${ssh_user// /}@${ssh_host// /}" + fi + [[ -z ${ssh_address+x} ]] && die "$path: SSH host not defined." # Default value for flags ssh_flags="${ssh_flags:-}" + if [[ "$TERM" == "xterm-kitty" ]]; then + export TERM="xterm-color" + fi export SSHPASS="$ssh_password" /usr/bin/sshpass -e -- ssh $ssh_flags "${@:2}" "$ssh_address" } -ssh_read_data "$@" \ No newline at end of file +ssh_read_data "$@"