all repos

dotfiles @ 4fe83e6

i use rach linux btw
2 files changed, 39 insertions(+), 0 deletions(-)
todo: add action for opening urls in todos
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2025-06-22 18:48:00 +0300
Parent: e5f2273
M config/todo/actions/@
···
                1
                1
                 #!/usr/bin/env bash

              
                
                2
                +export TODOTXT_VERBOSE=0

              
                
                3
                +

              
                2
                4
                 action=$1

              
                3
                5
                 shift

              
                
                6
                +

              
                
                7
                +if [[ $action == "usage" ]]; then

              
                
                8
                +  echo "@ [context]"

              
                
                9
                +  echo "  Lists all tasks with the given context."

              
                
                10
                +  echo "  If no context is given, lists all tasks categorized by their context."

              
                
                11
                +  echo "  If task has @someday, it won't be listed."

              
                
                12
                +  exit 0

              
                
                13
                +fi

              
                4
                14
                 

              
                5
                15
                 CONTEXTS=$(grep -o '[^ ]*@[^ ]\+' "$TODO_FILE" | grep '^@' | sort -u | sed 's/^@//g' )

              
                6
                16
                 for context in $CONTEXTS ; do

              
A config/todo/actions/url
···
                
                1
                +#!/usr/bin/env bash

              
                
                2
                +action=$1

              
                
                3
                +shift

              
                
                4
                +

              
                
                5
                +if [[ $action == "usage" ]]; then

              
                
                6
                +  echo "url [task_number] - opens link in the task"

              
                
                7
                +  exit 0

              
                
                8
                +fi

              
                
                9
                +

              
                
                10
                +item=$1

              
                
                11
                +if [[ ! "$item" =~ ^[0-9]+$ ]]; then

              
                
                12
                +  echo "$item: invalid item number"

              
                
                13
                +  exit 1

              
                
                14
                +fi

              
                
                15
                +

              
                
                16
                +URL_REGEX="\b(?:https?:\/\/)?(?:[\w-]+\.)+[a-z]{2,}(?:\/[\w\-./?%&=:#@+]*)?"

              
                
                17
                +URL=$(sed "$item!d" "$TODO_FILE" | grep -Po "$URL_REGEX")

              
                
                18
                +

              
                
                19
                +if [[ -z "$URL" ]]; then

              
                
                20
                +  echo "No URL found in task $item"

              
                
                21
                +  exit 1

              
                
                22
                +fi

              
                
                23
                +

              
                
                24
                +if [[ ! "#URL" =~ ^(?!https?:\/\/) ]]; then

              
                
                25
                +  URL="https://$URL"

              
                
                26
                +fi

              
                
                27
                +

              
                
                28
                +echo "$URL"

              
                
                29
                +xdg-open "$URL" &>/dev/null