开发了一个切换 hosts 的命令行,有需要的自取
发布于 1 天前 作者 DuanPengfei 240 次浏览 来自 分享

因为升级 macOS 到 beta 版系统,公司提供的快速切换 hosts 的工具不兼容无法使用,就自己撸了一个简单的命令行,有需要的同学自取,欢迎提意见和建议。

GitHub 地址:https://github.com/DuanPengfei/chhosts

Install

npm install -g chhosts

Usage

mkdir ~/chhosts
# put preset hosts file in ~/chhosts

└── chhosts
   ├── some_other
   └── default
sudo chhosts

Preview

➜  chhosts ll
total 16
-rw-r--r--  1 huaiyu  staff   365B  8 27 10:14 default
-rw-r--r--  1 huaiyu  staff   850B  8 27 10:28 some_other
➜  chhosts cat default
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost

# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of sectio
➜  chhosts sudo chhosts
Password:
? please select hosts file (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◉ default
 ◯ some_other
2 回复

mac 请问app store ihosts 了解下

@luanxuechao ihosts 还没有支持 beta 版系统,也可能是我这个系统的问题,ihosts 暂时用不了,就随手写了一个。

回到顶部