From 965dbc37dbb218f1fdc95b35798a6e8b04cd5c45 Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 25 Oct 2023 13:42:14 +0200 Subject: Track recent books for neovim --- track-books.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 track-books.sh (limited to 'track-books.sh') diff --git a/track-books.sh b/track-books.sh new file mode 100755 index 0000000..4a828e0 --- /dev/null +++ b/track-books.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +books_directory="$HOME/documents/books" +recent_books_file="$HOME/.config/nvim/tmp/recent_books.txt" + +inotifywait -m -e CREATE -e OPEN -r "$books_directory" | +while read -r path action file; do + if [[ $file == *.pdf ]]; then + echo "$path/$file" >>"$recent_books_file" + # Remove duplicates and overwrite the recent_books_file + sort -u -o "$recent_books_file" "$recent_books_file" + fi +done -- cgit v1.2.3