diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2022-08-28 14:22:59 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2022-08-28 14:28:09 +0200 |
| commit | b09ba6f1ccd1110515a8ac4c99d12487113c87dd (patch) | |
| tree | b89faa8275dd14fbb2d4748a3a0b31c2171f5b66 /functions | |
| parent | 42f1d9af0b67e47414172b51a6a10177027a6572 (diff) | |
| download | mark-b09ba6f1ccd1110515a8ac4c99d12487113c87dd.tar.gz mark-b09ba6f1ccd1110515a8ac4c99d12487113c87dd.zip | |
add count command
mark count <mark> counts all occurrences of <mark> in the mark store.
Diffstat (limited to 'functions')
| -rw-r--r-- | functions/mark.fish | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/functions/mark.fish b/functions/mark.fish index 80e373b..3afc12f 100644 --- a/functions/mark.fish +++ b/functions/mark.fish @@ -112,11 +112,22 @@ function __mark_append_mark --argument mark date end end +function __mark_count --argument mark + if test -z "$mark" + echo "No mark to count" >&2 + return 1 + end + + grep -v '[1-9][0-9][0-9][0-9]:' (__mark_find_store) | sed -r 's/^.{3}//' | grep -o $mark | wc -l + return 0 +end + function __mark_print_usage echo "Usage: mark [cmd | <mark>] date [cmd args]" echo "Cmds:" echo " print [before] [after]: print marks in range [date-before, date-after]" echo " edit: open the mark store file in an editor or using xdg-open" + echo " count <mark>: count the occurrences of <mark> in the mark store" end function mark --argument cmd date @@ -140,6 +151,8 @@ function mark --argument cmd date __mark_print_dates $date $argv[3] $argv[4] case "--help" "-h" __mark_print_usage + case "count" + __mark_count $argv[2] case "edit" "e" set store (__mark_find_store) if test ! -z "$VISUAL" @@ -161,4 +174,5 @@ function mark --argument cmd date mv $store.new $store end + return $status end |
