memo/completion/zsh/_memo

53 lines
1008 B
Plaintext
Raw Normal View History

2018-07-27 00:34:07 +02:00
#compdef memo
#autoload
function _memo {
local line
_arguments \
"1:action:((
add\:'add a text to a topic'
2018-08-09 23:32:34 +02:00
rm\:'delete a topic folder with all its content'
2018-07-27 00:34:07 +02:00
copy\:'copy a file to a topic'
search\:'search for text in all topics'
show\:'show a topic'
edit\:'edit a topic'
list\:'print a list of all topics'
2018-08-09 04:35:55 +02:00
git\:'run git command'
2018-07-27 00:34:07 +02:00
))" \
"*::arg:->args"
case $line[1] in
2018-08-09 23:32:34 +02:00
add|rm|copy|show|edit)
2018-07-27 00:34:07 +02:00
_memo_topics
;;
2018-08-09 04:35:55 +02:00
git)
_git
;;
2018-07-27 00:34:07 +02:00
*)
;;
esac
}
function _memo_topics {
MEMO_FOLDER="${MEMO_DIR:-$HOME/memo}"
topics=($(ls ${MEMO_FOLDER}))
compadd -X "A vailable Topics" $topics
}
2018-08-09 04:35:55 +02:00
function _git {
local -a subcommands
subcommands=(
"init:Initialize git repository"
"status:Status of git repository"
"push:Push to remote repository"
"pull:Pull from remote repository"
"config:Show git config"
"log:Show git log"
"reflog:Show git reflog"
)
_describe -t commands 'git' subcommands
}