From af120ab348f2e1a5a39dec035ed9dcf84189a64e Mon Sep 17 00:00:00 2001 From: Biswakalyan Bhuyan Date: Mon, 3 Oct 2022 21:42:20 +0530 Subject: dotfiles --- zsh/oh-my-zsh/plugins/dnote/_dnote | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 zsh/oh-my-zsh/plugins/dnote/_dnote (limited to 'zsh/oh-my-zsh/plugins/dnote/_dnote') diff --git a/zsh/oh-my-zsh/plugins/dnote/_dnote b/zsh/oh-my-zsh/plugins/dnote/_dnote new file mode 100644 index 0000000..c8b3348 --- /dev/null +++ b/zsh/oh-my-zsh/plugins/dnote/_dnote @@ -0,0 +1,39 @@ +#compdef dnote + +local -a _1st_arguments + +_1st_arguments=( + 'add:add a new note' + 'view:list books, notes, or view a content' + 'edit:edit a note or a book' + 'remove:remove a note or a book' + 'find:find notes by keywords' + 'sync:sync data with the server' + 'login:login to the dnote server' + 'logout:logout from the dnote server' + 'version:print the current version' + 'help:get help about any command' +) + +get_booknames() { + local names=$(dnote view --name-only) + local -a ret + + while read -r line; do + ret+=("${line}") + done <<< "$names" + + echo "$ret" +} + +if (( CURRENT == 2 )); then + _describe -t commands "dnote subcommand" _1st_arguments + return +elif (( CURRENT == 3 )); then + case "$words[2]" in + v|view|a|add) + _alternative \ + "names:book names:($(get_booknames))" + esac +fi + -- cgit v1.2.3-59-g8ed1b