Update the list after editing or deleting a zet
This commit is contained in:
parent
2394b79904
commit
54f8ab8bdf
1 changed files with 11 additions and 2 deletions
13
zet
13
zet
|
@ -44,7 +44,7 @@ delete_zet() {
|
|||
if [[ -d "$dir" ]]; then
|
||||
mv -v "$dir" "/tmp/zet-${id}"
|
||||
|
||||
# TODO: Delete from $ZET_TMP.
|
||||
update_zet_list
|
||||
else
|
||||
echo "Note not found: $id" >&2
|
||||
exit 1
|
||||
|
@ -61,7 +61,7 @@ edit_zet() {
|
|||
|
||||
commit_changes "$file" "Edit $file"
|
||||
|
||||
# TODO: Update $ZET_TMP if the title is changed.
|
||||
update_zet_list
|
||||
else
|
||||
result="$(search_zets "$query")"
|
||||
result_count="$(echo "$result" | grep -c '^')"
|
||||
|
@ -148,4 +148,13 @@ show_zet() {
|
|||
exit 1
|
||||
}
|
||||
|
||||
update_zet_list() {
|
||||
find "$ZET_DIR" -type f -name 'index.adoc' | while read -r filename; do
|
||||
id=$(basename "$(dirname "$filename")")
|
||||
title=$(head -n 1 "$filename" | sed 's/^= //' | sed 's/^# //')
|
||||
|
||||
echo "$id $title"
|
||||
done | sort > "$ZET_TMP" &
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue