File tree 2 files changed +21
-13
lines changed
2 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -280,12 +280,16 @@ _fzf_proc_completion_post() {
280
280
awk ' {print $2}'
281
281
}
282
282
283
- __fzf_list_hosts () {
284
- 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 ' [*?%]' ) \
285
- <( command grep -oE ' ^[[a-z0-9.,:-]+' ~ /.ssh/known_hosts 2> /dev/null | tr ' ,' ' \n' | tr -d ' [' | awk ' { print $1 " " $1 }' ) \
286
- <( command grep -v ' ^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv ' 0.0.0.0' ) |
287
- awk ' {if (length($2) > 0) {print $2}}' | sort -u
288
- }
283
+ # To use custom hostname lising, override __fzf_list_hosts.
284
+ # The function is expected to print hostnames, one per line, to standard output.
285
+ if ! declare -F __fzf_list_hosts > /dev/null; then
286
+ __fzf_list_hosts () {
287
+ 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 ' [*?%]' ) \
288
+ <( command grep -oE ' ^[[a-z0-9.,:-]+' ~ /.ssh/known_hosts 2> /dev/null | tr ' ,' ' \n' | tr -d ' [' | awk ' { print $1 " " $1 }' ) \
289
+ <( command grep -v ' ^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv ' 0.0.0.0' ) |
290
+ awk ' {if (length($2) > 0) {print $2}}' | sort -u
291
+ }
292
+ fi
289
293
290
294
_fzf_host_completion () {
291
295
_fzf_complete +m -- " $@ " < <( __fzf_list_hosts)
Original file line number Diff line number Diff line change @@ -215,13 +215,17 @@ _fzf_complete() {
215
215
command rm -f " $fifo "
216
216
}
217
217
218
- __fzf_list_hosts () {
219
- setopt localoptions nonomatch
220
- 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 ' [*?%]' ) \
221
- <( command grep -oE ' ^[[a-z0-9.,:-]+' ~ /.ssh/known_hosts 2> /dev/null | tr ' ,' ' \n' | tr -d ' [' | awk ' { print $1 " " $1 }' ) \
222
- <( command grep -v ' ^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv ' 0.0.0.0' ) |
223
- awk ' {if (length($2) > 0) {print $2}}' | sort -u
224
- }
218
+ # To use custom hostname lising, override __fzf_list_hosts.
219
+ # The function is expected to print hostnames, one per line, to standard output.
220
+ if ! declare -F __fzf_list_hosts > /dev/null; then
221
+ __fzf_list_hosts () {
222
+ setopt localoptions nonomatch
223
+ 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 ' [*?%]' ) \
224
+ <( command grep -oE ' ^[[a-z0-9.,:-]+' ~ /.ssh/known_hosts 2> /dev/null | tr ' ,' ' \n' | tr -d ' [' | awk ' { print $1 " " $1 }' ) \
225
+ <( command grep -v ' ^\s*\(#\|$\)' /etc/hosts 2> /dev/null | command grep -Fv ' 0.0.0.0' ) |
226
+ awk ' {if (length($2) > 0) {print $2}}' | sort -u
227
+ }
228
+ fi
225
229
226
230
_fzf_complete_telnet () {
227
231
_fzf_complete +m -- " $@ " < <( __fzf_list_hosts)
You can’t perform that action at this time.
0 commit comments