- Open Terminal (
Cmd + Spaceand typeTerminal) - Copy this script and paste into the Terminal:
sudo tee /usr/local/bin/sendkindle >/dev/null <<'EOF' #!/bin/zsh # Set USER_HOME correctly for sudo context USER_HOME="$HOME" CONFIG_FILE="$USER_HOME/.kindle_sender_config" # --- One-time setup --- if [[ ! -f "$CONFIG_FILE" ]]; then echo "This is a one-time setup. Enter your Kindle email (example@kindle.com):" read -r KINDLE_EMAIL if [[ ! "$KINDLE_EMAIL" =~ ^[a-zA-Z0-9._%+-]+@kindle.com$ ]]; then echo "Invalid Kindle email format." exit 1 fi echo "KINDLE_EMAIL=$KINDLE_EMAIL" > "$CONFIG_FILE" fi source "$CONFIG_FILE" # --- Check URL argument --- if [[ -z "$1" ]]; then echo "Usage: sendkindle <url>" exit 1 fi URL="$1" DESKTOP="$USER_HOME/Desktop" # --- Sanitize filename completely --- FINAL_PDF_NAME="webpage_$(date +%Y%m%d%H%M%S)" FINAL_PDF_PATH="$DESKTOP/$FINAL_PDF_NAME.pdf" echo "Processing URL: $URL" echo "Saving PDF to: $FINAL_PDF_PATH" # --- Detect Chrome or Brave on macOS --- CHROME_BIN="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" BRAVE_BIN="/Applications/Brave Browser.app/Contents/MacOS/Brave Browser" if [[ -f "$CHROME_BIN" ]]; then BROWSER_CMD="$CHROME_BIN" elif [[ -f "$BRAVE_BIN" ]]; then BROWSER_CMD="$BRAVE_BIN" else echo "Error: Chrome or Brave not found in /Applications." exit 1 fi # --- Create PDF headless --- "$BROWSER_CMD" --headless --disable-gpu --print-to-pdf="$FINAL_PDF_PATH" "$URL" # --- Check PDF creation --- if [[ ! -f "$FINAL_PDF_PATH" ]]; then echo "Error: PDF file could not be created." exit 1 fi echo "PDF created successfully." # --- Send email using mail command --- (uuencode "$FINAL_PDF_PATH" "$FINAL_PDF_NAME.pdf") | mail -s "convert" "$KINDLE_EMAIL" echo "Email sent! PDF is on your Desktop." EOF sudo chmod +x /usr/local/bin/sendkindle hash -r echo "The command 'sendkindle' is now ready to use." echo "Usage: sendkindle <url>"
- Enter your @kindle.com email when prompte
- To send a website to Kindle, run:
sendkindle <paste-website-url-here.example.com> - If successful, it saves the website as PDF to your Desktop and sends a copy to your Kindle email:
... PDF created successfully. Email sent! PDF is on your Desktop.
=========== If fail, send me feedback at tomtran310251@proton.me