summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-04-21 23:29:37 +0300
committerPaul Buetow <paul@buetow.org>2025-04-21 23:29:37 +0300
commit1c6b45b20c69a4edc212b58304a81c69f04ec6ee (patch)
tree968dc03c9d08ae6ccca888e5226025bd16aa6dcb
parent1b6bcde0fadbcf97df67e17997c55d291e3facb6 (diff)
add topen
-rw-r--r--dotfiles/fish/conf.d/taskwarrior.fish29
1 files changed, 24 insertions, 5 deletions
diff --git a/dotfiles/fish/conf.d/taskwarrior.fish b/dotfiles/fish/conf.d/taskwarrior.fish
index 0e7aef1..3b0c1a3 100644
--- a/dotfiles/fish/conf.d/taskwarrior.fish
+++ b/dotfiles/fish/conf.d/taskwarrior.fish
@@ -1,3 +1,21 @@
+function taskwarrior::fuzzy::_select
+ sed -n '/^[0-9]/p' | sort -rn | fzf | cut -d' ' -f1
+end
+
+function taskwarrior::fuzzy::find
+ set -g TASK_ID (task ready | taskwarrior::fuzzy::_select)
+end
+
+function taskwarrior::select
+ set -l task_id "$argv[1]"
+ if test -n "$task_id"
+ set -g TASK_ID "$task_id"
+ end
+ if test "$TASK_ID" = - -o -z "$TASK_ID"
+ taskwarrior::fuzzy::find
+ end
+end
+
function taskwarrior::due::count
set -l due_count (task status:pending due.before:now count)
@@ -9,8 +27,8 @@ end
function taskwarrior::url::open
taskwarrior::select $argv[1]
- set -l desc (task +track status:pending export | jq -r '.[].description')
- set -l url (extractUrlFromString "$desc")
+ set -l desc (task $TASK_ID export | jq -r '.[].description')
+ set -l url (taskwarrior::url::extract "$desc")
if test (uname) = Darwin
open -a "Google Chrome" "$url"
@@ -19,10 +37,9 @@ function taskwarrior::url::open
end
end
-function extractUrlFromString
+function taskwarrior::url::extract
set -l str "$argv[1]"
- set -l regex "(https?://[a-zA-Z0-9.-]+(/[a-zA-Z0-9._%+-/?&=]*))"
- echo $str | string match -r $regex
+ echo $str | sed -E 's|.*(https?://.+) .*|\1|'
end
function taskwarrior::add::track
@@ -91,6 +108,8 @@ abbr -a tdue 'vit status:pending due.before:now'
abbr -a thome 'vit +home'
abbr -a tasks 'vit -track'
abbr -a track 'taskwarrior::add::track'
+abbr -a tfind 'taskwarrior::fuzzy::find'
+abbr -a topen 'taskwarrior::url::open'
# Virtual standup abbrs
abbr -a V 'taskwarrior::add::standup'