TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Reclaim your focus with ~12 lines of bash

59 pointsby Curiositryabout 1 year ago

9 comments

geor9eabout 1 year ago
Ah the old hosts file blocklist trick. I tried that 20 years ago, but my dopamine craving brain wasn&#x27;t fooled. Paul Graham tried owning two computers, one without internet <a href="https:&#x2F;&#x2F;paulgraham.com&#x2F;distraction.html" rel="nofollow">https:&#x2F;&#x2F;paulgraham.com&#x2F;distraction.html</a> . That too didn&#x27;t work for him. My current strategy is to only use an RSS reader in my browser. HN posts with x upvotes, a few twitter accounts, a few facebook accounts, a few youtube channels, and a few substacks are all I see. No ads, no infinite feed. Every hour or so I can go to the feed trough and consume a few posts. Feels healthier. The distractions are there but the faucet is limited to a drip.
评论 #39585988 未加载
评论 #39586402 未加载
mattrighettiabout 1 year ago
For those that would try to talk themselves out of it and ^C the process, it could be useful to make things a <i>little bit</i> harder by putting the process in the background :)<p>There are multiple ways to achieve this:<p><pre><code> nohup focus.sh &amp; </code></pre> nohup stands for &quot;no hang up&quot;. It will run a command&#x2F;script in such a way that it ignores the SIGHUP signal. The SIGHUP signal is typically sent to a process when the terminal is closed or the session is terminated [0].<p>Another way could be to put the process in the background and then use `disown`, which removes the job from the shell&#x27;s job table [1], effectively disassociating it from the shell session. This prevents the job from receiving SIGHUP signals just as before.<p><pre><code> .&#x2F;focus.sh &amp; disown </code></pre> Finally<p><pre><code> setsid focus.sh </code></pre> This will launch the script in a new session [2], so that when you close your terminal it won&#x27;t receive your current session&#x27;s SIGHUP signal.<p>A very good StackOverflow explanation [3].<p>EDIT: actually, ^C the process already is a bit of a PITA since you would then need to manually put back the original &#x2F;etc&#x2F;hosts file :D<p>- [0]: <a href="https:&#x2F;&#x2F;www.man7.org&#x2F;linux&#x2F;man-pages&#x2F;man1&#x2F;nohup.1.html" rel="nofollow">https:&#x2F;&#x2F;www.man7.org&#x2F;linux&#x2F;man-pages&#x2F;man1&#x2F;nohup.1.html</a><p>- [1]: <a href="https:&#x2F;&#x2F;linuxcommand.org&#x2F;lc3_man_pages&#x2F;disownh.html" rel="nofollow">https:&#x2F;&#x2F;linuxcommand.org&#x2F;lc3_man_pages&#x2F;disownh.html</a><p>- [2]: <a href="https:&#x2F;&#x2F;www.man7.org&#x2F;linux&#x2F;man-pages&#x2F;man2&#x2F;setsid.2.html" rel="nofollow">https:&#x2F;&#x2F;www.man7.org&#x2F;linux&#x2F;man-pages&#x2F;man2&#x2F;setsid.2.html</a><p>- [3]: <a href="https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;a&#x2F;148698" rel="nofollow">https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;a&#x2F;148698</a>
lexandstuffabout 1 year ago
One thing I&#x27;d add to this is to schedule it in the future. Sometimes, you can&#x27;t bring yourself to block all websites right now, but you can happily make it a problem for your future self. I&#x27;ve written a similar script to do this and had success with it.<p>Something like:<p>checking 60m --start-in 30m
评论 #39586174 未加载
评论 #39586121 未加载
coolspotabout 1 year ago
You don’t need export here:<p>export DURATION=&quot;${1:-1m}&quot;<p>it should be just<p>DURATION=&quot;${1:-1m}&quot;<p>“export” is a keyword that makes a variable available to subprocesses.
评论 #39587768 未加载
mathgladiatorabout 1 year ago
So, honest question, is it just a super power to stay on task?
评论 #39585949 未加载
评论 #39586150 未加载
评论 #39585893 未加载
评论 #39586159 未加载
评论 #39586194 未加载
BWStearnsabout 1 year ago
Mildly related, is there a stable version of `notify-send` for mac? I use this for the moment but it seems janky.<p>```<p>function growl() { echo $&quot;\e]9;\&quot;$1\&quot;\007&quot; }<p>```
评论 #39586048 未加载
评论 #39586301 未加载
评论 #39586200 未加载
ashildrabout 1 year ago
Ah, the hosts file. Let’s research which ways of name resolution use it and which don’t. [A few hours later] …
notkaihoabout 1 year ago
Now to have the presence of mind to not reach for the phone when this is on
评论 #39585870 未加载
评论 #39586186 未加载
mateo1about 1 year ago
sudo hyperfocus-like-I&#x27;m-a-sophomore-again Sorry but 10 years of effort and no software trick helped me stop procrastinating, except pulling the cables off the router or going to a library.