How I force myself to work

No one seems to be immune to procrastinating, myself included. Some people get drawn into social media, for others it's YouTube or ProductHunt. I, however, tend to lose whole days on Wikipedia and development communities. Everyone has their poison. If you really are one of these odd people who don't know what procrastination is, check out this video.

Got distracted again while you should have finished that project? You are in the right place. Keep on reading! After trying numerous ways to keep myself coding or writing, I've finally found something that works for me.

Hard cut: "/etc/hosts" and "127.0.0.1" #

For a while I've used custom entries in my hosts file /etc/hosts redirecting some DNS requests to my local machine to die there. It's hard 404 to remind myself that I got distracted again and broke the flow. This worked well, but occasionally I had to find a solution to a coding issue and had to switch particular sites off. It became a habit of switching off the whole list as it was easier. And that is where old habits got the best of me.

Breaking Procrastination using a browser extension #

There are numerous browser extensions aiming to help victims of their habits like myself with their problem. Most of these didn't win me over as they either limited my browser too much or were simply not thought through enough.

The deprocrastination.co extension did a much better job here. I loved the ability to control access to certain sites and have dedicated blocks of effort. It worked well until the point I simply had to use one of the sites that were included in my block list. I had to break the timer or exclude the site manually.

Another little annoyance was that YouTube, my source of background music, was usually running. It wasn't affected by the extension as long as I didn't switch to the tab by accident. My habit of jumping around my browser tabs using keyboard shortcuts got me into trouble regularly.

Managing "/etc/hosts" version 2 #

As a regular reader of Mattias Geniar's Newsletter cron.weekly, I've recently discovered a neat command-line tool to manage your "/etc/hosts"-file better: hostctl! It allows you to predefine sets of host entries and to switch them on and off using commands:

# This will enable the blocks for mails by redirecting each domain to localhost.
hostctl enable nomail;

# This will disable the block and allow me to connect again.
hostctl disable nomail;

# Alternatively, you can use the toggle command:
hostctl toggle nomail;

# Note: I've actually got aliases for both. Simply add it to your ~/.bash_aliases

I've added some five sets to my hosts file. The sets are grouped by topics, for example:

In addition, I've added another bash alias called "work". It enables all block profiles at once and makes sure I keep working.

If I really need to access a site, I switch off the block for the set using an alias (for example "mail") and run a "sleep 120; work" to keep myself from going down some rabbit hole.

Too technical for you? #

If this approach is too technical for you, you might want to check out the extension mentioned above. It's a great solution if hostctl is too technical and kept me on track for a long time.

If this post or the video on top helped you to procrastinate it might be time to try either the extension or hostctl. Give it a try!

🙏🙏🙏

Since you've made it this far, sharing this article on your favorite social media network would be highly appreciated 💖! For feedback, please ping me on Twitter.

Published