File: ping-complete.bash.txt

package info (click to toggle)
lg-issue82 2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,100 kB
  • ctags: 93
  • sloc: sh: 38; makefile: 33; python: 28
file content (16 lines) | stat: -rw-r--r-- 365 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# ping/fping completion by Ben Okopnik <ben@callahans.org>

_ping() {
	local HOST_LIST

	COMPREPLY=()
	cur=${COMP_WORDS[COMP_CWORD]}

	# I'm going to ignore IPv6 hosts for now, hence the '::'
	HOST_LIST="$( echo $( grep -Ev '^$|^#|::' /etc/hosts ) )"

	COMPREPLY=( $( compgen -W "$HOST_LIST" -- "$cur" ) )
	return 0
}
complete -F _ping ping
complete -F _ping fping