commit d3561f28d1623120c909d240d513d08c5d1cb06b parent 881a2d19e0069473be7cccb4f02902580792fea0 Author: cipher <haris@2f30.org> Date: Tue, 11 Jul 2017 23:20:32 +0300 Parse ssh hosts through fzf and pass to xargs/ssh Diffstat:
A | smenu.sh | | | 15 | +++++++++++++++ |
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/smenu.sh b/smenu.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +# Parses ~/.ssh/{config,known_hosts}. Fzf[0] takes over for fuzzy selection and +# passes argument to xargs. + +set -A complete_ssh $( + (awk '!/\*/ && /^Host /{print $2}' ~/.ssh/config; + # awk '{sub(",.*$","",$1);print $1}' ~/.ssh/known_hosts + )|sort -u +) + +printf "%s\n" "${complete_ssh[@]}" | fzf | xargs -o ssh + + +# [0]: https://github.com/junegunn/fzf