Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions ssh.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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::]])}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the old code comments?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure. Sorry

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// /}"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ssh:, IP: and user: aren't specified this will effectively disable the empty check in line 39 by setting ssh_address to "@", right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I guess I'll have to do something else.

fi

[[ -z ${ssh_address+x} ]] && die "$path: SSH host not defined."
# Default value for flags
ssh_flags="${ssh_flags:-}"

if [[ "$TERM" == "xterm-kitty" ]]; then
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do? Shouldn't this go into your .bashrc / .zshrc?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this wasn't supposed to be in the merge request. This is a personal setting, putting it in .bashrc / .zshrc breaks some other things in my setup. It's the first time I'm trying to do a pull request to a public repo, I guess I will make a branch and make a pull request from there. Sorry for wasting your time. Please cancel this request, I'll try to do it properly next time.

export TERM="xterm-color"
fi
export SSHPASS="$ssh_password"
/usr/bin/sshpass -e -- ssh $ssh_flags "${@:2}" "$ssh_address"
}

ssh_read_data "$@"
ssh_read_data "$@"