function __fish_print_hostnames -d "Print a list of known hostnames" # Print all hosts from /etc/hosts. Use 'getent hosts' on OSes that support it # (OpenBSD and Cygwin do not). # # Test if 'getent hosts' works and redirect output so errors don't print. if type -q getent and getent hosts >/dev/null 2>&1 # Ignore zero IPs. getent hosts | string match -r -v '^0.0.0.0' | string replace -r '^\s*\S+\s+' '' | string split ' ' else if test -r /etc/hosts # Ignore commented lines and functionally empty lines. string match -r -v '^\s*0.0.0.0|^\s*#|^\s*$'