From e0429c9081edc93d708c912f34e7c7bd858f2fd2 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt <pbsds@hotmail.com> Date: Sun, 16 Mar 2025 23:54:40 +0100 Subject: [PATCH] lkajsd --- .../pbsds/home/profiles/bashrc.d/zeditor-remote.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/users/pbsds/home/profiles/bashrc.d/zeditor-remote.sh b/users/pbsds/home/profiles/bashrc.d/zeditor-remote.sh index 3fc0548..e71fc1d 100644 --- a/users/pbsds/home/profiles/bashrc.d/zeditor-remote.sh +++ b/users/pbsds/home/profiles/bashrc.d/zeditor-remote.sh @@ -35,14 +35,17 @@ zeditor-remote() { if [[ -r /etc/resolv.conf && -r "$HOME"/.ssh/known_hosts ]]; then local -a hosts readarray -d $'\n' -t hosts < <( - cut <"$HOME"/.ssh/known_hosts -d' ' -f1 | sort -u \ - | grep -E "(\\.$(hostname --domain)|^[^.]*)$" + cut <"$HOME"/.ssh/known_hosts -d' ' -f1 | sort -u \ + | grep -Ev '^([0-9]{0,3}\.){3}[0-9]{0,3}$' \ + | grep -Ev '^([0-9a-fA-F]{0,4}:){0,7}:?([0-9a-fA-F]{0,4}:){0,6}[0-9a-fA-F]{0,4}$' ) local -a domains readarray -d ' ' -t domains < <( grep </etc/resolv.conf '^search ' | cut -d' ' -f2- ) - printf '%s\n' "${hosts[@]}" | sed -E "s/\\.($(IFS='|'; printf "%s" "${domains[*]}"))\$//g" + printf '%s\n' "${hosts[@]}" \ + | sed -E "s/\\.($(IFS='|'; printf "%s" "${domains[*]}"))\$//g" \ + | grep -v '\.' fi } | grep -v '^localhost$' | sort -u } | fzf --multi --reverse --bind 'ctrl-a:toggle-all' --height=25 --cycle \ @@ -63,11 +66,11 @@ zeditor-remote() { sshargs=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null) if [[ "$host" = localhost ]]; then cd "$HOME" - fd "^\.git$" repos/ "${fdargs[@]}" -x printf '~/%q\n' "{//}" + fd "^\.git$" repos/ "${fdargs[@]}" -L -x printf '~/%q\n' "{//}" else # TODO: report timeouts? timeout 5 ssh "${sshargs[@]}" 2>/dev/null "$host" \ - fd "^\.git$" repos/ "${fdargs[@]}" -x printf "'ssh://%s/~/%q\n'" "'$host'" "'{//}'" + fd "^\.git$" repos/ "${fdargs[@]}" -L -x printf "'ssh://%s/~/%q\n'" "'$host'" "'{//}'" fi } $spin xe <<<"$host" -j"$(wc -l <<<"$host")" -s "$(declare -f worker); worker \"\$@\"" 2>/dev/null ||: