Giter VIP home page Giter VIP logo

hostshelper's Introduction

Tiny shell script for managing hosts

WARNING: This script will overwrite your /etc/hosts file. Use at your own risk. If you break your hosts file it ain't my fault. I suggest you read the source in addition to the documentation to get the full picture!

This script assumes you have 3 existing files.

  • /etc/hosts-dev - Any local domains you use for development
  • /etc/hosts-clean - A clean or vanilla hosts file copy from the OS
  • /etc/hosts-block - Any domains you want to deny

In both hosts-clean and hosts-block you will want to add this line somewhere --dont touch this line, ya dingus--. This line will be replaced by the contents of hosts-dev.

You will probably want aliases like this:

alias hostsblock="sudo /usr/local/bin/hosts-helper.sh block"
alias hostsreset="sudo /usr/local/bin/hosts-helper.sh default"

Now you can use hostsblock and hostsreset to toggle domain denial. For me this is very helpful because I have 60k~ domains in my blocklist. If someone sends me a silly thing on Twitter I can quickly and temporarily allow it.

Why not just use ublock origin or something then...??? Because that only blocks domains in the browser. Hosts files block all sorts of naughty stuff in native & electron apps as well :)

Thanks to Kyle Tucker for the help with sed!

hostshelper's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.