aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tmux/.local/bin/tmux-ssh
blob: 2dedc53fd49e86b3deef32792e56b17c2840b5e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

setopt localoptions nonomatch
tmp="$(mktemp)"

tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2>/dev/null | grep -i '^\s*host ' |
	awk '{for (i = 2; i <= NF; i++) print "ssh_config " $i}' | grep -v '[*?%]' >"$tmp"

grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts | tr ',' '\n' | tr -d '[' | awk '{ print  "known_hosts " $1 }' >"$tmp"
grep -v '^\s*\(#\|$\)' /etc/hosts | command grep -Fv '0.0.0.0' >"$tmp"
cat "$tmp"
exit 0
while IFS= read -r host; do
	hosts="$hosts $host"
done <"$tmp"
rm "$tmp"

printf %s\\n "$hosts" | xargs -I{} -d ' ' printf %s\\n {}