[zsh] Fixup the Alt-v vm starter command

This commit is contained in:
Sebastian Schulze 2020-01-03 22:02:21 +01:00
parent 095b2a56c2
commit a0ce3c5e30
Signed by: bascht
GPG Key ID: 5BCB1D3B4D38A35A
1 changed files with 7 additions and 3 deletions

View File

@ -86,10 +86,14 @@ zle -N fzf-ssh
bindkey '\es' fzf-ssh
function fzf-vm () {
local selected_vm=$(grep "Host " ~/.ssh/config | grep -oP "vm-(\w+)" | sort -u | cut -b 4-)
vm $selected_vm
local selected_vm=$(grep "Host " ~/.ssh/config | grep -oP "vm-(\w+)" | sort -u | cut -b 4- | fzf --reverse --height=20 --query "$LBUFFER")
if [ -n "$selected_vm" ]; then
BUFFER="vm ${selected_vm} ''"
zle accept-line
fi
zle reset-prompt
}
zle -N fzf-ssh
zle -N fzf-vm
bindkey '\ev' fzf-vm
# Via @leahneukirchen