Add `edit` command

`edit` open the hosts file in the editor specified in the $EDITOR
environment variable.
This commit is contained in:
William Melody 2015-03-16 17:38:06 -07:00
parent fc60f3a0d7
commit 7607dfd262
2 changed files with 14 additions and 0 deletions

View File

@ -8,6 +8,7 @@ A program for managing host file entries.
hosts add <ip> <hostname>
hosts remove <hostname>
hosts list [127.]
hosts edit
## Acknowledgements

13
hosts
View File

@ -666,6 +666,19 @@ list() {
fi
}
# ------------------------------------------------------------------------ edit
desc edit <<EOM
Usage: $_me edit
EOM
edit() {
if [[ -z "$EDITOR" ]]; then
_die printf "\$EDITOR not set.\n"
else
"$EDITOR" /etc/hosts
fi
}
# ---------------------------------------------------------------------- remove
desc remove <<EOM