CNode

开发了一个切换 hosts 的命令行,有需要的自取

分享
DDuanPengfei发布于7 年前最后回复7 年前2 回复4779 浏览0 收藏

因为升级 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)

L
luanxuechao#1·7 年前

mac 请问app store ihosts 了解下

D
DuanPengfei#2·7 年前
引用 luanxuechaomac 请问app store ihosts 了解下

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

参与回复
登录后即可参与回复。登录