# Installation Guide
This guide covers various installation methods for trimdown.
## Quick Install (Recommended)
### Using the Installation Script
```bash
# Clone and install
git clone https://github.com/yingkitw/trimdown-rs.git
cd trimdown-rs
./scripts/install.sh
```
The script will:
- Build the release binary
- Install it to `~/.local/bin`
- Show you how to add it to your PATH if needed
### Using Make
```bash
git clone https://github.com/yingkitw/trimdown-rs.git
cd trimdown-rs
make install
```
## Installation Methods
### Method 1: Homebrew (macOS/Linux)
```bash
# Install from tap
brew tap yingkitw/tap
brew install trimdown
# Install with all recommended dependencies
brew install trimdown ffmpeg qpdf ghostscript
```
**Pros**: Easy updates, dependency management
**Cons**: Requires Homebrew, larger install size
### Method 2: Cargo Install
```bash
cargo install trimdown
```
**Pros**: Direct from crates.io, automatic updates
**Cons**: Longer compile time, no external dependencies
### Method 3: Build from Source
```bash
git clone https://github.com/yingkitw/trimdown-rs.git
cd trimdown-rs
cargo build --release
# The binary will be at target/release/trimdown
sudo cp target/release/trimdown /usr/local/bin/
# Or copy to ~/.local/bin/ for user-only installation
```
**Pros**: Full control, latest features
**Cons**: Manual updates, requires Rust toolchain
### Method 4: Pre-built Binary
Download from [GitHub Releases](https://github.com/yingkitw/trimdown-rs/releases):
```bash
# Download latest release (example for macOS ARM64)
curl -L -o trimdown "https://github.com/yingkitw/trimdown-rs/releases/latest/download/trimdown-aarch64-apple-darwin"
chmod +x trimdown
sudo cp trimdown /usr/local/bin/
```
**Pros**: Fastest installation, no compilation
**Cons**: May not be available for all platforms
## Post-Installation Setup
### Verify Installation
```bash
trimdown --version
trimdown --help
```
### Install External Dependencies
For full functionality, install these optional tools:
**macOS**:
```bash
brew install ffmpeg qpdf ghostscript
```
**Ubuntu/Debian**:
```bash
sudo apt-get install ffmpeg qpdf ghostscript
```
**Fedora/RHEL**:
```bash
sudo dnf install ffmpeg qpdf ghostscript
```
### Add to PATH
If you installed to `~/.local/bin`, add this to your shell profile:
**Bash** (`~/.bashrc`):
```bash
export PATH="$PATH:$HOME/.local/bin"
```
**Zsh** (`~/.zshrc`):
```bash
export PATH="$PATH:$HOME/.local/bin"
```
**Fish** (`~/.config/fish/config.fish`):
```bash
set -gx PATH $PATH $HOME/.local/bin
```
Then reload your shell:
```bash
source ~/.bashrc # or ~/.zshrc
```
## Configuration (Optional)
Create a configuration file at `~/.trimdownrc.json`:
```json
{
"quality": 85,
"max_width": 1920,
"video_crf": 28,
"pdf_quality": "ebook",
"pdf_method": "auto",
"force": false,
"verbose": false
}
```
See [Configuration Options](README.md#configuration-file) for details.
## Upgrading
### Homebrew
```bash
brew upgrade trimdown
```
### Cargo
```bash
cargo install trimdown --force
```
### Source
```bash
git pull
cargo build --release
cp target/release/trimdown ~/.local/bin/
```
## Uninstallation
### Homebrew
```bash
brew uninstall trimdown
```
### Manual Installation
```bash
# Remove binary
rm /usr/local/bin/trimdown
# or
rm ~/.local/bin/trimdown
# Remove config
rm ~/.trimdownrc.json
```
## Troubleshooting
### Command Not Found
If you get `trimdown: command not found`:
1. Verify installation:
```bash
which trimdown
ls -l ~/.local/bin/trimdown
```
2. Check PATH:
```bash
echo $PATH
```
3. Add to PATH (see above)
### Permission Denied
If you get permission errors:
```bash
chmod +x ~/.local/bin/trimdown
# or
chmod +x /usr/local/bin/trimdown
```
### External Tools Not Found
If video or PDF compression doesn't work:
```bash
# Check if ffmpeg is installed
ffmpeg -version
# Check if qpdf is installed
qpdf --version
# Install missing tools
brew install ffmpeg qpdf # macOS
sudo apt-get install ffmpeg qpdf # Ubuntu
```
## Platform-Specific Notes
### macOS (Apple Silicon)
- Homebrew installs to `/opt/homebrew/bin`
- Make sure this is in your PATH
- Rosetta 2 is not required (native ARM64 support)
### Linux
- Most distributions package ffmpeg and qpdf separately
- You may need to install development headers for compilation
### Windows
Use WSL (Windows Subsystem for Linux) or install via Cargo:
```bash
cargo install trimdown
```
## Next Steps
- Read the [Usage Guide](README.md#usage)
- Check [Troubleshooting](docs/TROUBLESHOOTING.md) for common issues
- Explore [Configuration Options](README.md#configuration-file)