Implement "search" command

This commit is contained in:
The Magician 2023-12-08 17:51:15 +00:00
parent 542095a49b
commit c0bd1e11fc
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,26 @@
#!/bin/bash
setup() {
source ../zk
}
test__zk_search_calls__zk_list() {
expected="_zk_list"
fake _zk_list echo "$expected"
fake fzf cat
result="$(_zk_search)"
assert_equals "$expected" "$result"
}
test__zk_search_extracts_id_from_chosen_zettel() {
expected="1111111111111"
# shellcheck disable=SC2016
fake _zk_list 'echo "$expected | Zettel Title"'
fake fzf cat
result="$(_zk_search)"
assert_equals "$expected" "$result"
}

4
zk
View File

@ -24,6 +24,10 @@ _zk_list() {
done
}
_zk_search() {
_zk_list | fzf --prompt "ZK: " | cut -d ' ' -f 1
}
_zk_new() {
filename="$(_zk_isosec)"
touch "$ZKDIR/$filename"