Skip to content

Instantly share code, notes, and snippets.

@siriusjack
Created December 31, 2017 18:55
Show Gist options
  • Save siriusjack/2722570eb5de7fee2f7a7d6f5f6c9f7b to your computer and use it in GitHub Desktop.
Save siriusjack/2722570eb5de7fee2f7a7d6f5f6c9f7b to your computer and use it in GitHub Desktop.
fzf-ssh integration for zsh
function ssh-fzf () {
local selected_host=$(grep "Host " ~/.ssh/config | 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 '^\' ssh-fzf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment