From e0ae2e02573aef9eb87e557369415f9702833985 Mon Sep 17 00:00:00 2001 From: mitchell Date: Tue, 16 Feb 2021 09:46:24 -0500 Subject: [PATCH] Simplify and cleanup push functions --- .config/fish/functions/push.fish | 25 +++++++++++++++++++++++++ .config/fish/functions/send_push.fish | 19 ------------------- .config/fish/functions/tasko.fish | 6 ------ .config/fish/functions/tasktime.fish | 9 --------- .config/fish/functions/taskwiki.fish | 9 --------- 5 files changed, 25 insertions(+), 43 deletions(-) create mode 100644 .config/fish/functions/push.fish delete mode 100644 .config/fish/functions/send_push.fish delete mode 100644 .config/fish/functions/tasko.fish delete mode 100644 .config/fish/functions/tasktime.fish delete mode 100644 .config/fish/functions/taskwiki.fish diff --git a/.config/fish/functions/push.fish b/.config/fish/functions/push.fish new file mode 100644 index 0000000..4813caf --- /dev/null +++ b/.config/fish/functions/push.fish @@ -0,0 +1,25 @@ +function push -a message -d 'Send a push notification to your phone via pushover (optional delay as second arg)' + argparse 'u/url=' 'p/priority=' -- $argv + + set -l host (cat /etc/hostname) + + if test -z "$_flag_p" + set _flag_p '0' + end + + set payload \ + "{ + \"token\": \"$pushover_token\", + \"user\": \"$pushover_user\", + \"title\": \"Push from $host\", + \"url\": \"$_flag_u\", + \"priority\": $_flag_p, + \"message\": \"$message\" +}" + + curl \ + -X POST \ + -H 'Content-Type: application/json' \ + -d "$payload" \ + https://api.pushover.net/1/messages.json +end diff --git a/.config/fish/functions/send_push.fish b/.config/fish/functions/send_push.fish deleted file mode 100644 index 0eebba4..0000000 --- a/.config/fish/functions/send_push.fish +++ /dev/null @@ -1,19 +0,0 @@ -function send_push -a message -d 'Send a push notification to your phone via pushover (optional delay as second arg)' - if test -n "$argv[2]" - sleep $argv[2] - end - - set payload \ - "{ - \"token\": \"$pushover_token\", - \"user\": \"$pushover_user\", - \"title\": \"Tasks\", - \"message\": $message -}" - - curl \ - -X POST \ - -H 'Content-Type: application/json' \ - -d $payload \ - https://api.pushover.net/1/messages.json -end diff --git a/.config/fish/functions/tasko.fish b/.config/fish/functions/tasko.fish deleted file mode 100644 index 18ded27..0000000 --- a/.config/fish/functions/tasko.fish +++ /dev/null @@ -1,6 +0,0 @@ -function tasko -a id -d 'Open the link of a taskwarrior task by id' - set link (task _get $id.link) - if test -n $link - open $link - end -end diff --git a/.config/fish/functions/tasktime.fish b/.config/fish/functions/tasktime.fish deleted file mode 100644 index fe875c5..0000000 --- a/.config/fish/functions/tasktime.fish +++ /dev/null @@ -1,9 +0,0 @@ -function tasktime -a id time -d 'Set a time to check-in on task progress using pushover' - set half_time (math $time/2) - set desc (task _get $id.description) - - task $id start - - fish -c "send_push '\"Half-time: $desc\"' $half_time" >/dev/null & disown - fish -c "send_push '\"Timer over: $desc\"' $time" >/dev/null & disown -end diff --git a/.config/fish/functions/taskwiki.fish b/.config/fish/functions/taskwiki.fish deleted file mode 100644 index 30563d6..0000000 --- a/.config/fish/functions/taskwiki.fish +++ /dev/null @@ -1,9 +0,0 @@ -function taskwiki -a id - set page (task _get $id.wiki) - - if test -n $page - $EDITOR +VimwikiIndex "+VimwikiGoto $page" - else - echo 'no wiki file specified' - end -end