Skip to content
Myr

[completion] Handle all hostaliases in /etc/hosts (#3495)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Fix #3488 * Handle inline comments in hosts file

authored by akdevservices · committed by GitHub · parent 7701244 · Browse files · 2 files+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−4 removed

  • other:+4 added−4 removed

2 files+4 added−4 removed

modified:shell/completion.bash+2 added-2 removed
421 unmodified lines
422if ! declare -F __fzf_list_hosts > /dev/null; then423 __fzf_list_hosts() {424 command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | command awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') \425 <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts 2> /dev/null | command tr ',' '\n' | command tr -d '[' | command awk '{ print $1 " " $1 }') \426 <(command grep -v '^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv '0.0.0.0') |427 command awk '{if (length($2) > 0) {print $2}}' | command sort -u426 <(command grep -v '^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv '0.0.0.0' | command sed 's/#.*//') |427 command awk '{for (i = 2; i <= NF; i++) print $i}' | command sort -u428 }429fi430431_fzf_host_completion() {
113 unmodified lines
modified:shell/completion.zsh+2 added-2 removed
224 unmodified lines
225 __fzf_list_hosts() {226 setopt localoptions nonomatch227 command cat <(command tail -n +1 ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null | command grep -i '^\s*host\(name\)\? ' | awk '{for (i = 2; i <= NF; i++) print $1 " " $i}' | command grep -v '[*?%]') \228 <(command grep -oE '^[[a-z0-9.,:-]+' ~/.ssh/known_hosts 2> /dev/null | tr ',' '\n' | tr -d '[' | awk '{ print $1 " " $1 }') \229 <(command grep -v '^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv '0.0.0.0') |230 awk '{if (length($2) > 0) {print $2}}' | sort -u229 <(command grep -v '^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv '0.0.0.0' | command sed 's/#.*//') |230 awk '{for (i = 2; i <= NF; i++) print $i}' | sort -u231 }232fi233234_fzf_complete_telnet() {
113 unmodified lines