Skip to content

Instantly share code, notes, and snippets.

@LaptopDev
Created September 2, 2025 21:51
Show Gist options
  • Select an option

  • Save LaptopDev/2754e68b0d8866faa30d762a0a9d0137 to your computer and use it in GitHub Desktop.

Select an option

Save LaptopDev/2754e68b0d8866faa30d762a0a9d0137 to your computer and use it in GitHub Desktop.
Lists ebook matches in user's default calibre library by title and (with arg) path.
calibfind ()
{
local cmd;
local title;
while [[ $# -gt 0 ]]; do
case "$1" in
-h | --h | -help | --help)
echo "Usage:";
echo " calibfind <title> # list ebook info by title";
echo " calibfind -path <title> # return space-delimited quoted file paths";
return 0
;;
-path | --path)
cmd="paths";
shift;
title="$1"
;;
*)
cmd="find";
title="$1"
;;
esac;
shift;
done;
if [[ -z "$title" ]]; then
echo "Usage: calibfind [-path] <title>";
return 1;
fi;
case "$cmd" in
find)
( stty cols 500;
calibredb list --search "title:$title" -f title )
;;
paths)
( stty cols 500;
calibredb list --search "title:$title" -f formats ) | perl -ne 'print "\"$1\" " if /\[(.*?)\]/'
;;
esac
}
@LaptopDev
Copy link
Author

Usage

> calibfind trinity
id title                                          
17 Holy Trinity Monastary Jordanville Prayer Book


> calibfind -path trinity
"/home/user/Calibre Library/Unknown/Holy Trinity Monastary Jordanville Prayer Book (17)/Holy Trinity Monastary Jordanville Prayer - Unknown.epub" laptop:/usr/share/cosmic$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment