7 files changed,
42 insertions(+),
15 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-06-09 12:58:44 +0300
Authored at:
2026-06-01 14:25:22 +0300
Parent:
bc8e747
M
bin/time.sh
··· 7 7 # sudo chmod 664 /etc/hosts 8 8 9 9 readonly TC="$HOME/org/time.timeclock" 10 -readonly CATS=("stop" "WORK" "WASTE") 10 +readonly CATS=("stop" "WORK" "SEMI-WASTE" "WASTE") 11 11 readonly BLOCKED=("news.ycombinator.com" "lobste.rs" "www.reddit.com" "www.chess.com" "www.lichess.org" 12 - "discord.com" "www.x.com" "www.bsky.app" "www.twitch.tv" "www.youtube.com" "youtube.com") 12 + "discord.com" "www.x.com" "bsky.app" "www.youtube.com" "youtube.com" "www.twitch.tv") 13 13 14 14 now() { date '+%Y-%m-%d %H:%M:%S'; } 15 15 current() { awk '/^[io]/ { last_type=$1; last_cat=$4 } END { if (last_type == "i") print last_cat }' "$TC"; } ··· 17 17 18 18 block_sites() { 19 19 for domain in "${BLOCKED[@]}"; do 20 - hostess "$1" "$domain" "::1" >/dev/null 2>&1 20 + grep -qF "::1 $domain" /etc/hosts 2>/dev/null || printf '%s\t%s\n' '::1' "$domain" >>/etc/hosts 21 21 done 22 22 } 23 23 24 +unblock_sites() { 25 + local pattern 26 + for domain in "${BLOCKED[@]}"; do 27 + pattern+="/^::1[[:space:]]\+$domain\([[:space:]]\|$\)/d;" 28 + done 29 + sed "$pattern" /etc/hosts >/tmp/hosts.tmp && cat /tmp/hosts.tmp >/etc/hosts 30 +} 31 + 24 32 update_tmux() { 25 33 [[ -z "${TMUX:-}" ]] && return 26 34 local curr=$(tmux show -gqv status-right 2>/dev/null || true) ··· 40 48 cat=$(printf '%s\n' "${CATS[@]}" | fzf --reverse --no-info) || exit 41 49 stop_tracking 42 50 43 - [[ -z "$cat" || "$cat" == stop ]] && { block_sites rm; update_tmux ""; exit; } 51 + [[ -z "$cat" || "$cat" == stop ]] && { unblock_sites; update_tmux ""; exit; } 44 52 45 53 printf 'i %s t:%s\n' "$(now)" "$cat" >> "$TC" 46 - [[ "$cat" == WASTE ]] && block_sites rm || block_sites add 54 + [[ "$cat" == WASTE ]] && unblock_sites || block_sites 47 55 update_tmux "$cat" 48 56 ;; 49 57 esac
M
bin/tmux-open-git.sh
··· 2 2 3 3 p="$(tmux run 'echo #{pane_current_path}')" 4 4 cd "$p" 5 -url=$(git remote get-url origin 2>/dev/null) || { echo "No remote 'origin' found in $p"; exit 1; } 5 +url=$(git remote get-url origin 2>/dev/null) \ 6 + || url=$(git remote get-url olexsmir 2>/dev/null) \ 7 + || url=$(git remote get-url upstream 2>/dev/null) \ 8 + || { echo "No remote 'origin', 'olexsmir', or 'upstream' found in $p"; exit 1; } 6 9 7 10 if [[ $url == git@* ]]; then 8 11 url="${url#git@}"