{"id":119717,"date":"2024-03-13T09:05:55","date_gmt":"2024-03-13T00:05:55","guid":{"rendered":"https:\/\/softantenna.com\/blog\/?p=119717"},"modified":"2024-03-13T09:05:55","modified_gmt":"2024-03-13T00:05:55","slug":"12-lines-bash-focus","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/12-lines-bash-focus\/","title":{"rendered":"12\u884c\u306ebash\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u96c6\u4e2d\u529b\u3092\u53d6\u308a\u623b\u3059\u65b9\u6cd5"},"content":{"rendered":"<p><img decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto;\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2024\/03\/pexels-photo-1804035.jpg\" alt=\"Pexels photo 1804035\" title=\"pexels-photo-1804035.jpg\" border=\"0\" width=\"1125\" height=\"750\" \/><\/p>\n<p>\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc\u3067\u4f5c\u696d\u3092\u884c\u3063\u3066\u3044\u308b\u969b\u3001\u8a98\u60d1\u304c\u591a\u304f\u96c6\u4e2d\u3092\u7dad\u6301\u3067\u304d\u306a\u3044\u3068\u60a9\u3093\u3067\u3044\u308b\u65b9\u306f\u591a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u672c\u65e5\u7d39\u4ecb\u3059\u308b\u30d6\u30ed\u30b0\u8a18\u4e8b\u300c<a href=\"https:\/\/www.autodidacts.io\/coldturkey-selfcontrol-freedom-leechblock-alternative-in-bash\/\">Reclaim your focus with ~12 lines of bash<\/a>\u300d\u306f\u3001\u305d\u306e\u554f\u984c\u3092\u89e3\u6c7a\u3059\u308b\u3001\u308f\u305a\u304b12\u884c\u306ebash\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u7d39\u4ecb\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u306e\u306f<strong>hosts<\/strong>\u30d5\u30a1\u30a4\u30eb\u3092\u66f8\u304d\u63db\u3048\u3066\u7279\u5b9a\u306e\u30b5\u30a4\u30c8\u3092\u30d6\u30ed\u30c3\u30af\u3059\u308b\u30c6\u30af\u30cb\u30c3\u30af\u3067\u3001<a href=\"https:\/\/getcoldturkey.com\/?ref=autodidacts.io\">ColdTurkey<\/a>\u3001<a href=\"https:\/\/www.proginosko.com\/leechblock\/?ref=autodidacts.io\">LeechBlock NG<\/a>\u3001<a href=\"https:\/\/freedom.to\/?ref=autodidacts.io\">Freedom<\/a>\u3001<a href=\"\">Self Control<\/a>\u3068\u3044\u3063\u305f\u5c02\u7528\u30c4\u30fc\u30eb\u3068\u540c\u3058\u6a5f\u80fd\u3092\u30b7\u30f3\u30d7\u30eb\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u5b9f\u73fe\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u624b\u9806\u3092\u307e\u305a\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u65e2\u5b58\u306e<code>\/etc\/hosts<\/code>\u30d5\u30a1\u30a4\u30eb\u3092\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3059\u308b\u3002<\/li>\n<li>\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u3092<code>\/etc\/hosts-checking<\/code>\u306b\u30ea\u30cd\u30fc\u30e0\u3059\u308b\u3002<\/li>\n<li><code>\/etc\/hosts-doing<\/code>\u306b\u305d\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\u3057\u3001\u90aa\u9b54\u306aWeb\u30b5\u30a4\u30c8\u3092\u3059\u3079\u3066\u8ffd\u52a0\u3059\u308b(Gmail\u3084HackerNews\u3001Spotify\u306a\u3069\u81ea\u5206\u304c\u983b\u7e41\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u30b5\u30a4\u30c8)<\/li>\n<li>\u4ee5\u4e0b\u306echecking\u95a2\u6570\u3092<code>~\/.bashrc<\/code>\u306b\u8ffd\u52a0\u3059\u308b\u3002<\/li>\n<li>\u30aa\u30d7\u30b7\u30e7\u30f3: \u6bce\u56de\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u5165\u529b\u3059\u308b\u306e\u3092\u3055\u3051\u308b\u305f\u3081<code>\/etc\/sudoers<\/code>\u306b<code>yusername ALL= (root)NOPASSWD<\/code>\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/li>\n<\/ul>\n<p>\u6b21\u306b<code>~\/.bashrc<\/code>\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n<pre>\r\nfunction checking () {\r\n    set -x\r\n    set -o errexit\r\n    export DURATION=\"${1:-1m}\"\r\n    echo \"Starting a Checking session lasting ${DURATION}\"\r\n    sudo ln -sf \/etc\/hosts-checking \/etc\/hosts && resolvectl flush-caches\r\n    echo \"Distracting websites and comms unblocked!\"\r\n    sleep $DURATION\r\n    notify-send \"Checking session complete! Close your tabs.\"\r\n    sleep 1m\r\n    sudo ln -sf \/etc\/hosts-doing \/etc\/hosts && resolvectl flush-caches\r\n    echo \"Done\"\r\n    systemctl suspend\r\n}\r\n<\/pre>\n<p>\u3053\u306e\u5f8c<code>checking 15m<\/code>\u3084<code>checking 1hr<\/code>\u3068\u5b9f\u884c\u3059\u308b\u3068\u3001\u305d\u306e\u9593\u3060\u3051\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306b\u901a\u5e38\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u72b6\u614b\u3068\u306a\u308a(hosts-checking\u304c\u6709\u52b9\u306a\u72b6\u614b)\u3001\u305d\u308c\u4ee5\u5916\u306f\u90aa\u9b54\u306a\u3082\u306e\u304c\u30d6\u30ed\u30c3\u30af\u3055\u308c\u305f\u72b6\u614b(hosts-doing\u304c\u6709\u52b9\u306a\u72b6\u614b)\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u306a\u304a\u3001hosts-doing\u306e\u8a18\u8f09\u4f8b\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002\u90aa\u9b54\u306a\u30b5\u30a4\u30c8\u306bIP\u30a2\u30c9\u30ec\u30b9: 127.0.0.1\u3092\u5272\u308a\u5f53\u3066\u308b\u3053\u3068\u3067\u3001\u4f7f\u3048\u306a\u304f\u3059\u308b\u308f\u3051\u3067\u3059\u3002<\/p>\n<pre>\r\n127.0.0.1       news.ycombinator.com lobste.rs  \r\n127.0.0.1       plausible.io googleanalytics.com goatcounter.com umami.is usefathom.com artists.spotify.com  \r\n127.0.0.1       commafeed.com feedly.com inoreader.com\r\n127.0.0.1       reddit.com facebook.com x.com instagram.com bsky.social threads.net craigslist.org\r\n127.0.0.1       gmail.com slack.com discord.com\r\n<\/pre>\n<p>\u306a\u304a\u3001\u4eca\u56de\u7d39\u4ecb\u3057\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u306fnotify-send\u306a\u3069Linux\u306b\u7279\u6709\u306e\u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002macOS\u7528\u306b\u66f8\u304d\u63db\u3048\u308b\u65b9\u6cd5\u3084\u3001\u96c6\u4e2d\u529b\u3092\u9ad8\u3081\u308b\u65b9\u6cd5\u306b\u95a2\u3059\u308b\u8b70\u8ad6\u304c<a href=\"https:\/\/news.ycombinator.com\/item?id=39585648\">Hacker News<\/a>\u3067\u884c\u308f\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u30fc\u3067\u4f5c\u696d\u3092\u884c\u3063\u3066\u3044\u308b\u969b\u3001\u8a98\u60d1\u304c\u591a\u304f\u96c6\u4e2d\u3092\u7dad\u6301\u3067\u304d\u306a\u3044\u3068\u60a9\u3093\u3067\u3044\u308b\u65b9\u306f\u591a\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002 \u672c\u65e5\u7d39\u4ecb\u3059\u308b\u30d6\u30ed\u30b0\u8a18\u4e8b\u300cReclaim your focus with ~12 lines of bash\u300d\u306f\u3001\u305d\u306e\u554f [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":119728,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[2047],"tags":[1360],"class_list":["post-119717","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips","tag-bash"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/119717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=119717"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/119717\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/119728"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=119717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=119717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=119717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}