From 39b5759bb0506ba6eaedd9b85144633a392d6a4e Mon Sep 17 00:00:00 2001 From: EmilyGraceSeville7cf Date: Sun, 15 Sep 2024 23:54:30 +1000 Subject: [PATCH] feat(completion): move function to functions/* --- share/completions/termux-camera-photo.fish | 12 ------------ share/completions/termux-notification.fish | 16 ---------------- .../__fish_termux_api__complete_camera_ids.fish | 11 +++++++++++ .../__fish_termux_api__complete_group_ids.fish | 15 +++++++++++++++ 4 files changed, 26 insertions(+), 28 deletions(-) create mode 100644 share/functions/__fish_termux_api__complete_camera_ids.fish create mode 100644 share/functions/__fish_termux_api__complete_group_ids.fish diff --git a/share/completions/termux-camera-photo.fish b/share/completions/termux-camera-photo.fish index 954265d79..255028521 100644 --- a/share/completions/termux-camera-photo.fish +++ b/share/completions/termux-camera-photo.fish @@ -1,15 +1,3 @@ -function __fish_termux_api__complete_camera_ids - set -l command termux-camera-info - set ids ($command | jq --raw-output '.[].id') - set types ($command | jq --raw-output '.[].facing') - - printf "0\tdefault\n" - - for index in (seq (count $ids)) - printf "%s\t%s\n" $ids[$index] $types[$index] - end -end - set command termux-camera-photo complete -c $command -f diff --git a/share/completions/termux-notification.fish b/share/completions/termux-notification.fish index 8f1bc0980..a2e93ef52 100644 --- a/share/completions/termux-notification.fish +++ b/share/completions/termux-notification.fish @@ -1,19 +1,3 @@ -function __fish_termux_api__complete_group_ids - set -l command termux-notification-list - set ids ($command | jq --raw-output '.[].group') - set titles ($command | jq --raw-output '.[].title') - - for index in (seq (count $ids)) - set -l id $ids[$index] - set -l title $titles[$index] - - test -z "$id" && continue - test -z "$title" && set title "Unknown title" - - printf "%s\t%s\n" $id $title - end -end - set command termux-notification complete -c $command -f diff --git a/share/functions/__fish_termux_api__complete_camera_ids.fish b/share/functions/__fish_termux_api__complete_camera_ids.fish new file mode 100644 index 000000000..c80460a25 --- /dev/null +++ b/share/functions/__fish_termux_api__complete_camera_ids.fish @@ -0,0 +1,11 @@ +function __fish_termux_api__complete_camera_ids + set -l command termux-camera-info + set ids ($command | jq --raw-output '.[].id') + set types ($command | jq --raw-output '.[].facing') + + printf "0\tdefault\n" + + for index in (seq (count $ids)) + printf "%s\t%s\n" $ids[$index] $types[$index] + end +end diff --git a/share/functions/__fish_termux_api__complete_group_ids.fish b/share/functions/__fish_termux_api__complete_group_ids.fish new file mode 100644 index 000000000..b5b8c9406 --- /dev/null +++ b/share/functions/__fish_termux_api__complete_group_ids.fish @@ -0,0 +1,15 @@ +function __fish_termux_api__complete_group_ids + set -l command termux-notification-list + set ids ($command | jq --raw-output '.[].group') + set titles ($command | jq --raw-output '.[].title') + + for index in (seq (count $ids)) + set -l id $ids[$index] + set -l title $titles[$index] + + test -z "$id" && continue + test -z "$title" && set title "Unknown title" + + printf "%s\t%s\n" $id $title + end +end