Compare commits

..

1 Commits

Author SHA1 Message Date
Shohei YOSHIDA 1c3a5cd238
Merge f240565bf4 into 8a994c20d7 2026-01-22 19:43:28 +00:00
1 changed files with 22 additions and 70 deletions

View File

@ -28,7 +28,7 @@
# Description # Description
# ----------- # -----------
# #
# Completion script for jrnl v4.2.1 (https://github.com/jrnl-org/jrnl). # Completion script for jrnl a simple journal application for your command line. (https://maebert.github.io/jrnl/).
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Authors # Authors
@ -38,77 +38,29 @@
# #
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
_jrnl() { _jrnl() {
typeset -A opt_args
local context state line
local curcontext="$curcontext"
local ret=1
_arguments -C \ _arguments -C \
'--debug[Print information useful for troubleshooting]' \ '(- 1 *)'-h"[Show help and exit]" \
'(- *)--help[Show help message]' \ '(- 1 *)'-v"[Prints version information and exits]" \
'(- *)--version[print version information]' \ '(- 1 *)'-ls"[Displays accessible journals]" \
'--list[List all configured journals]' \ '(- 1 *)'-d"[Execute in debug mode]" \
'--encrypt[Encrypt selected journal with a password]' \ '(- 1 *)'--tags"[Returns a list of all tags and number of occurrences]" \
'--decrypt[Decrypt selected journal and store it in plain text]' \ "--short[Show only titles or line containing the search]" \
'--import[Import entries from another journal]' \ "-from[View entries after this date]:date:" \
'-on[Show entries on this date]:date' \ "-until[View entries before this date]:date:" \
'-today-in-history[Show entries of today over the years]' \ "-to[View entries before this date]:date:" \
'-month[Show entries on this month of any year]:date' \ "-on[View entries on this date]:date:" \
'-day[Show entries on this day of any month]:date' \ "-and[Filter by tags using AND (default: OR)]" \
'-year[Show entries of a specific year]:date' \ "-starred[Show only starred entries]" \
'-from[Show entries after, or on, this date]:date' \ "-n[Shows the last n entries matching the filter. And '-3' have the same effect.]":number: \
'(-to -until)'{-to,-until}'[Show entries before, or on, this date]' \ "--export[Export your journal. TYPE can be json, markdown text.]:format:(json markdown text)" \
'-contains[Show entries containing specific text]:text' \ "-o[Optionally specifies output file when using --export If OUTPUT is a directory, exports each entry in individual file instead.]:output file:" \
'-and[Show only entries that match all conditions(default: OR)]' \ "--encrypt[Encrypts your existing journal with a new pass]" \
'-starred[Show only starred entries (marked with *)]' \ "--decrypt[Decrypts your journal and stores it in plain text]" \
'-tagged[Show only entries that have at least one tag]' \ "--edit[Opens your editor to edit the selected entries.]" \
'-n[Show a maximum of NUMBER entries. And "-3" has the same effect]:number' \
'-not[exclude entries with that tag]:tag_or_flag' \
'--edit[Opens the selected entries in your configured editor]' \
'--delete[Interactively deletes selected entries]' \
'--change-time[Change timestamp for selected entries(default: now)]:date' \
'--format[Display selected entries in an alternate format]:format:_jrnl_formats' \
'--tags[Alias for "--format tags"]' \
'--short[Show only titles or line containing the search tags]' \
'--config-override[Override configured key-value pair]:key_value' \
'--config-file[Override default config file]:path:_files' \
'*:: :->args' \
&& ret=0
case $state in
(args)
if [[ $PREFIX = @* ]]; then
local -a tags=($(jrnl --tags 2>/dev/null | command grep -oE '@\S+'))
_describe -t tags 'tags' tags && ret=0
fi
;;
esac
return ret
} }
(( $+functions[_jrnl_formats] )) || _jrnl
_jrnl_formats() {
local -a formats
if (( $+opt_args[--list] )); then
formats=(json yaml)
elif (( $+opt_args[--import] )); then
formats=(jrnl)
else
formats=(boxed calendar dates fancy heatmap json markdown md pretty short tags text txt xml yaml)
fi
_values 'format' $formats
}
_jrnl "$@"
# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
# indent-tabs-mode: nil
# sh-basic-offset: 2
# End:
# vim: ft=zsh sw=2 ts=2 et