@@ -36,7 +36,7 @@ compress_zip() {
3636 return 1
3737 fi
3838 # https://stackoverflow.com/a/965072/
39- local FILENAME=$( basename -- " $1 " )
39+ local FILENAME=" $( basename -- " $1 " ) "
4040 local NAME=" ${FILENAME% .* } "
4141 # https://superuser.com/a/742034/
4242 7z a -mm=Deflate -mfb=258 -mpass=15 " ${NAME} .zip" " ${FILENAME} "
@@ -70,12 +70,13 @@ fix-kde-hard() {
7070pdfsearch () {
7171 # https://stackoverflow.com/questions/4643438/how-to-search-contents-of-multiple-pdf-files
7272 if [ $# -ne 2 ]; then
73- echo " pdfsearch: Search content from multiple pdfs recursively. For example, search some word from directory of books."
73+ echo " pdfsearch: Search content from multiple pdfs recursively. For example, search some word from a directory of books."
7474 echo " Usage: pdfsearch <path> <text snippet>"
7575 echo " Example: pdfsearch . 'citation'"
76- else
77- find " $1 " -name ' *.pdf' -exec sh -c " pdftotext \" {}\" - | grep -nH -B 1 -A 1 --label=\" {}\" --color \" $2 \" " \;
76+ return 1
7877 fi
78+ echo " Searching $1 for \" $2 \" "
79+ find " $1 /" -name ' *.pdf' -exec sh -c " pdftotext \" {}\" - 2> /dev/null | grep -nH -B 1 -A 1 --label=\" {}\" --color \" $2 \" " \;
7980}
8081
8182replacerec () {
@@ -85,12 +86,12 @@ replacerec() {
8586 echo " replacerec: Find and replace text recursively. Unlike 'sed' it does not try to match special symbols with regex."
8687 echo " Usage: replacerec <old-text> <new-text> <filter>"
8788 echo " Example: replacerec '(^_^)' ':D' '*.txt'"
88- else
89- export FINDTHIS=" $1 "
90- export REPLACE=" $2 "
91- find . \( -type d -name .git -prune \) -o -type f -name " $3 " -exec echo {} \; -exec \
92- ruby -p -i -e " gsub(ENV['FINDTHIS'], ENV['REPLACE'])" {} \;
89+ return 1
9390 fi
91+ export FINDTHIS=" $1 "
92+ export REPLACE=" $2 "
93+ find . \( -type d -name .git -prune \) -o -type f -name " $3 " -exec echo {} \; -exec \
94+ ruby -p -i -e " gsub(ENV['FINDTHIS'], ENV['REPLACE'])" {} \;
9495}
9596
9697# function nvidia-smi {
@@ -253,6 +254,16 @@ update() {
253254 fi
254255}
255256
257+ zotsearch () {
258+ if [ $# -ne 1 ]; then
259+ echo " zotsearch: Search content from Zotero PDFs."
260+ echo " Usage: zotsearch <text snippet>"
261+ echo " Example: zotsearch 'citation'"
262+ return 1
263+ fi
264+ pdfsearch " ${HOME} /Zotero/storage" " $1 "
265+ }
266+
256267# For those familiar with Vim
257268alias :q=" exit"
258269
0 commit comments