Skip to content

Instantly share code, notes, and snippets.

@dohq
Created March 24, 2023 04:37
Show Gist options
  • Save dohq/164de7bc95de765d9b3202d401b4549d to your computer and use it in GitHub Desktop.
Save dohq/164de7bc95de765d9b3202d401b4549d to your computer and use it in GitHub Desktop.
function fzf-ssh-consul () {
local selected_host=$(consul catalog nodes | grep -v "DC" | awk '{print $1}' | fzf --query "$LBUFFER" --prompt="Consul Nodes SSH Remote > ")
if [ -n "$selected_host" ]; then
BUFFER="ssh ${selected_host}.node.consul"
zle accept-line
fi
zle reset-prompt
}
zle -N fzf-ssh-consul
bindkey '^f' fzf-ssh-consul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment