From 740d68473f6cefcf32a9eb93724463fc754deeca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A2=D0=BE=D1=82?= =?UTF-8?q?=D0=BC=D0=B8=D0=BD?= Date: Wed, 6 Mar 2024 11:13:06 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BB(=D0=B0)=20?= =?UTF-8?q?'completions/pass.zsh-completion'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- completions/pass.zsh-completion | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 completions/pass.zsh-completion diff --git a/completions/pass.zsh-completion b/completions/pass.zsh-completion new file mode 100644 index 0000000..cf99a4f --- /dev/null +++ b/completions/pass.zsh-completion @@ -0,0 +1,60 @@ +#compdef note +# +# Completion script for note +# + +_note () { + local cmd + if (( CURRENT > 2)); then + cmd=${words[2]} + curcontext="${curcontext%:*:*}:note-$cmd" + (( CURRENT-- )) + shift words + case "${cmd}" in + init) + ;; + find) + _note_complete_entries_with_subdirs + ;; + show|ls|list|edit) + _note_complete_entries_with_subdirs + ;; + cp|copy|mv|rename|rm) + _note_complete_entries_with_subdirs + ;; + esac + else + local -a subcommands + subcommands=( + "init:Initialize new note storage" + "ls:List note" + "find:Find note files or directories based on pattern" + "grep:Search note files for matching pattern" + "show:Print a note" + "edit:Edit a note with \$EDITOR" + "mv:Rename the note" + "cp:Copy the note" + "rm:Remove the note" + "version:Output version information" + "help:Output help message" + ) + _describe -t commands 'note' subcommands + fi +} + +_note_complete_entries_helper () { + local IFS=$'\n' + local notepath + zstyle -s ":completion:${curcontext}:" notepath notepath || notepath="${NOTE_STORE_DIR:-$HOME/.note-store}" + _values -C 'notes' ${$(find -L "$notepath" \( -name .git \) -prune -o $@ -print 2>/dev/null | sed -e "s#${notepath}/\{0,1\}##" -e 's#\.md##' -e 's#\\#\\\\#g' -e 's#:#\\:#g' | sort):-""} +} + +_note_complete_entries_with_subdirs () { + _note_complete_entries_helper +} + +_note_complete_entries () { + _note_complete_entries_helper -type f +} + +_note \ No newline at end of file