diff --git a/Readme.md b/Readme.md index b76898f..4d6bbf3 100644 --- a/Readme.md +++ b/Readme.md @@ -7,7 +7,7 @@ A command line program with shortcuts for managing hosts file entries. Usage: hosts add hosts remove - hosts list [] + hosts list [enabled | disabled | ] hosts show ( | | ) hosts disable ( | | ) hosts enable ( | | ) diff --git a/hosts b/hosts index 7db328f..6540506 100755 --- a/hosts +++ b/hosts @@ -743,7 +743,7 @@ file() { desc list <] + $_me list [enabled | disabled | ] Description: List the existing IP / hostname pairs. When provided with a seach string, all @@ -751,7 +751,13 @@ Description: EOM list() { if [[ -n "$1" ]]; then - $_me show "$1" + if [[ "$1" == disabled ]]; then + sed -n "s/^\#disabled: \(.*\)$/\1/p" /etc/hosts + elif [[ "$1" == enabled ]]; then + grep -v -e '^$' -e '^\s*\#' /etc/hosts + else + $_me show "$1" + fi else # NOTE: use separate expressions since using a | for the or results in # inconsistent behavior.