all repos

dotfiles @ de6a1005d51efa8403ce4b0946d29d7fc5665169

i use rach linux btw
3 files changed, 34 insertions(+), 7 deletions(-)
tmux: add script for opening current git repo on the web
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2026-04-17 20:22:28 +0300
Authored at: 2026-04-17 16:49:51 +0300
Parent: 4603c36
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\nWORK\nVIM\nWASTE'

      
        11
        
        -readonly BLOCKED=("news.ycombinator.com" "www.lobste.rs" "www.twitch.tv" "www.reddit.com" "www.chess.com" "www.lichess.org") # "www.youtube.com" "youtube.com"

      
        
        10
        +readonly CATS=("stop" "WORK" "WASTE")

      
        
        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
        13
         

      
        13
        14
         now() { date '+%Y-%m-%d %H:%M:%S'; }

      
        14
        15
         current() { awk '/^[io]/ { last_type=$1; last_cat=$4 } END { if (last_type == "i") print last_cat }' "$TC"; }

      ···
        35
        36
             open=$(current)

      
        36
        37
             [[ -n "$open" ]] && printf '%s\n' "${open#t:}"

      
        37
        38
           ;;

      
        38
        
        -  ""|s)

      
        39
        
        -    cat=$(printf '%s\n' "$CATS" | fzf) || exit

      
        40
        
        -    [[ -z "$cat" || "$cat" == stop ]] && { stop_tracking; block_sites rm; update_tmux ""; exit; }

      
        
        39
        +  "")

      
        
        40
        +    cat=$(printf '%s\n' "${CATS[@]}" | fzf) || exit

      
        
        41
        +    stop_tracking

      
        
        42
        +

      
        
        43
        +    [[ -z "$cat" || "$cat" == stop ]] && { block_sites rm; update_tmux ""; exit; }

      
        41
        44
         

      
        42
        
        -    stop_tracking

      
        43
        45
             printf 'i %s t:%s\n' "$(now)" "$cat" >> "$TC"

      
        44
        46
             [[ "$cat" == WASTE ]] && block_sites rm || block_sites add

      
        45
        47
             update_tmux "$cat"

      
A bin/tmux-open-git.sh
···
        
        1
        +#!/usr/bin/env bash

      
        
        2
        +

      
        
        3
        +p="$(tmux run 'echo #{pane_current_path}')"

      
        
        4
        +cd "$p"

      
        
        5
        +url=$(git remote get-url origin 2>/dev/null) || { echo "No remote 'origin' found in $p"; exit 1; }

      
        
        6
        +

      
        
        7
        +if [[ $url == git@* ]]; then

      
        
        8
        +  url="${url#git@}"

      
        
        9
        +  url="${url/://}"

      
        
        10
        +  url="https://$url"

      
        
        11
        +fi

      
        
        12
        +

      
        
        13
        +url="${url%.git}"

      
        
        14
        +if [[ $url == https://* || $url == http://* ]]; then open "$url"

      
        
        15
        +else echo "Cannot open: unrecognized remote format: $url: in $p"

      
        
        16
        +     exit 1

      
        
        17
        +fi

      
        
        18
        +

      
        
        19
        +if command -v xdg-open &>/dev/null; then xdg-open "$url" >/dev/null

      
        
        20
        +elif command -v open &>/dev/null;   then open "$url" >/dev/null

      
        
        21
        +else tmux display-message "no opener found: $url" ; exit 1

      
        
        22
        +fi

      
        
        23
        +

      
        
        24
        +tmux display-message "opened: $url"

      
M config/tmux/tmux.conf
···
        35
        35
         bind-key -T copy-mode-vi 'y' send -X copy-selection

      
        36
        36
         unbind -T copy-mode-vi MouseDragEnd1Pane

      
        37
        37
         

      
        
        38
        +bind e run "tmux neww ~/bin/time.sh"

      
        
        39
        +bind g run "~/bin/tmux-open-git.sh"

      
        38
        40
         bind R source-file ~/.config/tmux/tmux.conf \; display 'Reloaded tmux config'

      
        39
        
        -bind e run "tmux neww ~/bin/time.sh"

      
        40
        41
         unbind c; bind t new-window -c "#{pane_current_path}";

      
        41
        42
         unbind <; bind < swap-window -t -1;

      
        42
        43
         unbind >; bind > swap-window -t +1;