From 32fab516325478de630c257c47459f003359ae64 Mon Sep 17 00:00:00 2001 From: Bastien Jacquet Date: Tue, 16 Jan 2024 22:22:30 +0100 Subject: [PATCH 1/2] feat: handle "\s+Host=" and w/o preceding blank line --- zsh-ssh.zsh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zsh-ssh.zsh b/zsh-ssh.zsh index eae4618..c40fb0f 100644 --- a/zsh-ssh.zsh +++ b/zsh-ssh.zsh @@ -37,6 +37,8 @@ _ssh-host-list() { ssh_config=$(_parse_config_file $SSH_CONFIG_FILE) ssh_config=$(echo $ssh_config | command grep -v -E "^\s*#[^_]") + # Make sure each Host line is preceded by an empty line + ssh_config=$(echo $ssh_config | command sed 's/[[:space:]]*Host\b/\nHost /g') host_list=$(echo $ssh_config | command awk ' function join(array, start, end, sep, result, i) { @@ -52,10 +54,12 @@ _ssh-host-list() { } function parse_line(line) { - n = split(line, line_array, " ") + # Manualy remove leading spaces for split with regex + line = gensub(/^\s+/, "", "g", line) + n = split(line, line_array, " +|=") key = line_array[1] - value = join(line_array, 2, n) + value = join(line_array, 2, n, " ") return key "#-#" value } From da60e97ec86c1a4fc5f32088880017ae44c89f4d Mon Sep 17 00:00:00 2001 From: Bastien Jacquet Date: Tue, 16 Jan 2024 23:38:05 +0100 Subject: [PATCH 2/2] fix: remove missing fzf --no-separator option --- zsh-ssh.zsh | 1 - 1 file changed, 1 deletion(-) diff --git a/zsh-ssh.zsh b/zsh-ssh.zsh index c40fb0f..40e7457 100644 --- a/zsh-ssh.zsh +++ b/zsh-ssh.zsh @@ -205,7 +205,6 @@ fzf-complete-ssh() { --header-lines=2 \ --reverse \ --prompt='SSH Remote > ' \ - --no-separator \ --bind 'shift-tab:up,tab:down,bspace:backward-delete-char/eof' \ --preview 'ssh -T -G $(cut -f 1 -d " " <<< {}) | grep -i -E "^User |^HostName |^Port |^ControlMaster |^ForwardAgent |^LocalForward |^IdentityFile |^RemoteForward |^ProxyCommand |^ProxyJump " | column -t' \ --preview-window=right:40%