Skip to content

Instantly share code, notes, and snippets.

@lapis-zero09
Last active October 29, 2017 10:59
Show Gist options
  • Save lapis-zero09/062dd16d8758c77359f21bb0d2470ee7 to your computer and use it in GitHub Desktop.
Save lapis-zero09/062dd16d8758c77359f21bb0d2470ee7 to your computer and use it in GitHub Desktop.
function ssh-fzf () {
local selected_host=$(grep "Host " ~/.ssh/config | grep -v '*' | cut -b 6- | fzf --query "$LBUFFER")
if [ -n "$selected_host" ]; then
BUFFER="ssh ${selected_host}"
zle accept-line
fi
zle reset-prompt
}
zle -N ssh-fzf
bindkey '^s' ssh-fzf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment