tmux session ssh add hosts from history
This commit is contained in:
parent
2a4f583d33
commit
a85249e473
@ -3,8 +3,10 @@
|
|||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
SSH_SERVERS="$(grep 'Host ' "${HOME}/.ssh/config" | sed 's/^Host //')"
|
SSH_SERVERS="$(grep 'Host ' "${HOME}/.ssh/config" | sed 's/^Host //')"
|
||||||
HOSTS=$(grep -v '^#' /etc/hosts)
|
HOSTS="$(grep -v '^#' /etc/hosts)"
|
||||||
ALL_HOSTS="$(echo "$SSH_SERVERS" "$HOSTS" | grep -v '\*'| sed 's/ /\n/g' | sed '/^$/d' | sort | uniq)"
|
HISTORY_HOSTS="$(grep ssh "${HOME}/.zsh_history" | grep -o -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')"
|
||||||
|
|
||||||
|
ALL_HOSTS="$(echo "$SSH_SERVERS" "$HOSTS" "$HISTORY_HOSTS" | grep -v '\*'| sed 's/ /\n/g' | sed '/^$/d' | sort | uniq | tac)"
|
||||||
|
|
||||||
SSH_SERVER="$(echo -n "$ALL_HOSTS" | fzf +m --print-query --bind 'tab:replace-query' | tail -n 1)"
|
SSH_SERVER="$(echo -n "$ALL_HOSTS" | fzf +m --print-query --bind 'tab:replace-query' | tail -n 1)"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user