2020-02-22 19:40:41 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-06-01 11:41:37 +00:00
|
|
|
|
2020-02-18 01:32:08 +00:00
|
|
|
# Load wal colours
|
|
|
|
. ~/.cache/wal/colors.sh
|
|
|
|
|
2019-06-01 11:41:37 +00:00
|
|
|
# get hostnames from ~/.ssh/known_hosts
|
2020-02-18 01:32:08 +00:00
|
|
|
ssh_host="$(awk -F "[ ,]+" '{print $1}' ~/.ssh/known_hosts | tr -d '[]' | uniq | sort -n | dmenu -nb "$color0" -nf "$color15" -sb "$color1" -sf "$color15" "$@")"
|
2019-06-01 11:41:37 +00:00
|
|
|
# split hostnames into array { hostname, port }
|
|
|
|
mapfile -t params < <(echo "$ssh_host" | awk -F ":" '{print $1} {if ($2) print $2}')
|
|
|
|
|
2020-01-05 23:05:06 +00:00
|
|
|
if [ -n "$ssh_host" ]; then
|
|
|
|
# If array size is two then second parameter is port number
|
|
|
|
if [ ${#params[@]} -eq 2 ]; then
|
2020-02-19 13:47:52 +00:00
|
|
|
alacritty -e ssh "${params[0]}" -p "${params[1]}"
|
2020-01-05 23:05:06 +00:00
|
|
|
else
|
2020-02-19 13:47:52 +00:00
|
|
|
alacritty -e ssh "${params[0]}"
|
2020-01-05 23:05:06 +00:00
|
|
|
fi
|
2019-06-01 11:41:37 +00:00
|
|
|
fi
|