1
0
mirror of https://github.com/alrayyes/dotfiles/ synced 2023-11-14 15:56:30 +00:00
dotfiles/private_dot_local/bin/executable_ssh-dmenu

16 lines
570 B
Plaintext
Raw Normal View History

2020-02-22 19:40:41 +00:00
#!/usr/bin/env bash
# get hostnames from ~/.ssh/known_hosts
2022-10-09 15:30:41 +00:00
ssh_host="$(awk -F "[ ,]+" '{print $1}' ~/.ssh/known_hosts | tr -d '[]' | uniq | sort -n | dmenu -fn "FuraCode Nerd Font" "$@")"
# 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
2020-07-24 10:24:25 +00:00
# If array size is two then second parameter is port number
if [ ${#params[@]} -eq 2 ]; then
alacritty -e ssh "${params[0]}" -p "${params[1]}"
else
alacritty -e ssh "${params[0]}"
fi
fi