guumaster / hostctl

Your dev tool to manage /etc/hosts like a pro!

Home Page:http://guumaster.github.io/hostctl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Profile Groups

smhmd opened this issue · comments

Is your feature request related to a problem? Please describe.
I use /etc/hosts to block websites during work. for example, I block youtube, twitter, ycombinator, etc. I would love to have profiles for individual websites (e.g., sudo hostctl enable -p youtube) but at the same time have a group of profiles that I can manipulate all at once (e.g., sudo hostctl disable -p socialmedia).

Describe the solution you'd like

$ hostctl group socialmedia -p youtube twitter linkedin
$ hostctl disable -p socialmedia # disable all social media
$ hostcl enable -p youtube          # except for youtube

Not sure if I understand the request correctly. Profiles are already groups of urls. You can add YouTube, twitter and such to a social media group:

hostctl add domain --ip 1.1.1.1 youtube.com -p socialmedia
hostctl add domain --ip 2.2.2.2 twitter.com -p socialmedia

And then enable/disable all together

As I've said, I'm not using hosts to manage a server or anything, I'm using hosts to block websites when I wanna focus on work or block NSFW material. My idea was to have a master profile for individual profiles. To block Twitter I have the following in hosts:

...15 lines blocking facebook 
127.0.0.1       www.twitter.com
127.0.0.1       twitter.com
127.0.0.1       www.mobile.twitter.com
127.0.0.1       mobile.twitter.com
127.0.0.1       api.twitter.com
...27 lines blocking some google stuff

And that's the same for most other websites. It only makes sense to have profiles for these websites as they aren't a single domain to be blocked.

But, comes 7 PM and I'm Ok with social media and news websites. A profile group for all of these profiles to enable them at mass.

I'm only asking for this feature thinking it could be useful to others. If it's not so, I could easily make a shell script for myself.

you can also add all your blocks into a file, for example $HOME/block-etchost, and block all once with a single command:

hostctl add -p superblock --from $HOME/block-etchost

And all would be added easily.

Also, if all have the same IP, you can do with a single command: hostctl add domain facebook.com twitter.com -p socialmedia (defaults to localhost ip), but it would be a long command if you have too many domains.