mhgbrg / blk Goto Github PK
View Code? Open in Web Editor NEWA simple bash scripts that makes it a breeze to block distracting websites.
License: MIT License
A simple bash scripts that makes it a breeze to block distracting websites.
License: MIT License
Homebrew?
I don't know anything about bash, so there are probably a whole lot of errors in the code. Using a linter would teach me more about bash and help me fix some of these errors.
'block' doesn't cut it anymore. The script needs a new, more personal name.
The functionality of blk
is beginning to get too big to manually test each time some change is made. I don't know if writing tests for bash scripts are considered good practice (or if it's just an indication of that your script is beginning to get too large...), but it is something that could be looked into.
block_for
and unblock_for
for example are nearly identical. Can they be made more general to reduce code duplication?
Right now when redirecting a site to another site served by HTTPS the certificate for the site redirected to is not valid, since the url in the browser doesn't match the url for the certificate. True redirects are not supported by the hosts file, so the easiest solution to this problem would probably be to redirect to a local web server that can redirect to the correct site.
This web server would have to run on the default port, since you can't specify which port to redirect to in the hosts file.
It is a drag to always have to use sudo for blocking or unblocking websites. Can sudo be incorporated in the script in some way?
Maybe it is as easy as adding a section in the readme about changing the permission of the hosts file.
Show a help message for how to use the script when an incorrect command is issued.
block
should be the default action of the script. Blocking a website should be as easy as typing blk news.ycombinator.com
.
For example block news.ycombinator.com until 13:37
.
Same functionality as with a regular unblock.
Right now the solution is kind of a mishmash of multiple solutions. Look through the script and rethink all design decisions.
Right now the script outputs one line for each website blocked or unblocked. It would probably be nicer to just output one line for all websites, or something similar.
The way the script is used has been changed and the examples in the readme needs to be updated.
Right now there is no indication whether a website is blocked for 2 seconds or eternally. This should be shown when using blk list.
To do this the information could be saved after '# blk' in the hosts file. For example '# blk until 17.30'.
Another interesting thing could be to also show sites that are unblocked for or until a certain time. Information about this is currently not saved in the hosts file, but it could be stored in commented out lines. Another solution is to save a file with state in the user's home folder with this information.
Blocking a website for 10 minutes could for example be done with the command block news.ycombinator.com for 10 minutes
.
MIT is probably the best.
For example, when redirecting news.ycombinator.com to www.facebook.com the browser gets pointed to news.facebook.com, which results in a 404.
How do I know which one to take?
Piping of websites was removed when the flags to the script were redone. This is a nice feature, so it should be put back in.
For example you could configure where sites should be redirected when blocked.
It is a hassle to have to supply the -s flag each time a site is blocked. Could this be make easier? Maybe the first argument always have to be the site that is blocked or unblocked.
at
can take arguments such as now + 2 minutes
. Right now the script only parses one parameter after the keyword until
. Maybe it could be worth it to parse any extra parameters to leverage the complete power of at
.
This will hopefully fix the issue when using timed blocks and the sudo session has timed out before the scheduled unblock is run.
When using until
for several websites at once, only one of the websites are blocked/unblocked at the specified time. This is because the at
-jobs both try to edit the hosts-file at the same time, which results in only one of the succeeding.
Maybe you could set up a "quick list" for easy blocking of all websites that distract you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.