From a85249e47302b50760aeb9c648e882522c5d99d7 Mon Sep 17 00:00:00 2001 From: thek4n Date: Thu, 17 Oct 2024 15:27:30 +0300 Subject: [PATCH] tmux session ssh add hosts from history --- home/user/.tmux/ssh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/home/user/.tmux/ssh b/home/user/.tmux/ssh index e1b0a1e..91e8c84 100755 --- a/home/user/.tmux/ssh +++ b/home/user/.tmux/ssh @@ -3,8 +3,10 @@ set -eu SSH_SERVERS="$(grep 'Host ' "${HOME}/.ssh/config" | sed 's/^Host //')" -HOSTS=$(grep -v '^#' /etc/hosts) -ALL_HOSTS="$(echo "$SSH_SERVERS" "$HOSTS" | grep -v '\*'| sed 's/ /\n/g' | sed '/^$/d' | sort | uniq)" +HOSTS="$(grep -v '^#' /etc/hosts)" +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)"