2024-10-26 14:09:48 -07:00
|
|
|
|
# PATH-worthy Scripts 🛠️
|
2024-10-26 22:57:27 +02:00
|
|
|
|
|
2024-10-26 23:54:52 +02:00
|
|
|
|
A collection of various scripts I use frequently enough to justify keeping them in my system PATH.
|
|
|
|
|
|
2024-10-27 01:41:59 +02:00
|
|
|
|
I haven't written documentation for all of these scripts. I might in time. Find documentation for some of the highlights below.
|
2024-10-26 22:57:27 +02:00
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
## Installation
|
2024-10-26 22:57:27 +02:00
|
|
|
|
|
2024-10-27 01:41:59 +02:00
|
|
|
|
1. Clone and enter repository:
|
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
```bash
|
|
|
|
|
git clone https://sij.ai/sij/pathScripts.git
|
2024-10-27 01:41:59 +02:00
|
|
|
|
cd pathScripts
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. Add to your system PATH:
|
2024-10-26 22:57:27 +02:00
|
|
|
|
|
2024-10-27 01:41:59 +02:00
|
|
|
|
macOS / ZSH:
|
|
|
|
|
```bash
|
|
|
|
|
echo "export PATH=\"\$PATH:$PWD\"" >> ~/.zshrc
|
2024-10-26 14:09:48 -07:00
|
|
|
|
source ~/.zshrc
|
2024-10-27 01:41:59 +02:00
|
|
|
|
```
|
2024-10-26 22:57:27 +02:00
|
|
|
|
|
2024-10-27 01:41:59 +02:00
|
|
|
|
Linux / Bash:
|
|
|
|
|
```bash
|
|
|
|
|
echo "export PATH=\"\$PATH:$PWD\"" >> ~/.bashrc
|
2024-10-26 14:09:48 -07:00
|
|
|
|
source ~/.bashrc
|
2024-10-26 22:57:27 +02:00
|
|
|
|
```
|
|
|
|
|
|
2024-10-27 01:41:59 +02:00
|
|
|
|
3. Make scripts executable:
|
|
|
|
|
|
2024-10-26 22:57:27 +02:00
|
|
|
|
```bash
|
2024-10-26 14:09:48 -07:00
|
|
|
|
chmod +x *
|
2024-10-26 22:57:27 +02:00
|
|
|
|
```
|
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
---
|
2024-10-26 22:57:27 +02:00
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
## 📄 bates - PDF Bates Number Tool
|
2024-10-26 22:57:27 +02:00
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
Extracts and renames PDFs based on Bates numbers.
|
2024-10-26 22:57:27 +02:00
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
### Setup
|
2024-10-26 22:57:27 +02:00
|
|
|
|
```bash
|
2024-10-26 14:09:48 -07:00
|
|
|
|
pip3 install pdfplumber
|
|
|
|
|
# For OCR support:
|
|
|
|
|
pip3 install pytesseract pdf2image
|
|
|
|
|
brew install tesseract poppler # macOS
|
|
|
|
|
# or
|
|
|
|
|
sudo apt-get install tesseract-ocr poppler-utils # Debian
|
2024-10-26 22:57:27 +02:00
|
|
|
|
```
|
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
### Usage
|
2024-10-26 22:57:27 +02:00
|
|
|
|
```bash
|
2024-10-26 14:09:48 -07:00
|
|
|
|
bates /path/to/folder --prefix "FWS-" --digits 6 --name-prefix "FWS "
|
2024-10-26 22:57:27 +02:00
|
|
|
|
```
|
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
### Key Features
|
|
|
|
|
- Extracts Bates numbers from text/scanned PDFs
|
|
|
|
|
- Renames files with number ranges
|
2024-10-26 14:37:21 -07:00
|
|
|
|
- Prepare files for use with my [Bates Source Link](https://sij.ai/sij/DEVONthink/src/branch/main/Bates%20Source%20Link.scpt#) DEVONthink script
|
2024-10-26 14:09:48 -07:00
|
|
|
|
- Preserves original names in Finder comments
|
|
|
|
|
- OCR support for scanned documents
|
|
|
|
|
- Dry-run mode with `--dry-run`
|
2024-10-26 22:57:27 +02:00
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
### Options
|
2024-10-26 22:57:27 +02:00
|
|
|
|
- `--prefix`: The Bates number prefix to search for (default: "FWS-")
|
|
|
|
|
- `--digits`: Number of digits after the prefix (default: 6)
|
|
|
|
|
- `--ocr`: Enable OCR for scanned documents
|
|
|
|
|
- `--dry-run`: Test extraction without renaming files
|
|
|
|
|
- `--name-prefix`: Prefix to use when renaming files
|
|
|
|
|
- `--log`: Set logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
|
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
### Examples
|
|
|
|
|
```bash
|
|
|
|
|
# Test without making changes
|
|
|
|
|
bates /path/to/pdfs --prefix "FWS-" --digits 6 --dry-run
|
2024-10-26 22:57:27 +02:00
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
# Rename files with OCR support
|
|
|
|
|
bates /path/to/pdfs --prefix "FWS-" --digits 6 --name-prefix "FWS " --ocr
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Notes
|
2024-10-26 22:57:27 +02:00
|
|
|
|
- Always test with `--dry-run` first
|
|
|
|
|
- Original filenames are preserved in Finder comments (macOS only)
|
|
|
|
|
- OCR is disabled by default to keep things fast
|
2024-10-26 14:04:02 -07:00
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
---
|
2024-10-26 14:04:02 -07:00
|
|
|
|
|
2024-10-26 14:35:55 -07:00
|
|
|
|
|
2024-10-26 23:57:14 +02:00
|
|
|
|
## 📦 kip - Intelligent Python Package Installer
|
2024-10-26 14:35:55 -07:00
|
|
|
|
|
|
|
|
|
A smart package installer that automates Python dependency management, supporting both mamba and pip.
|
|
|
|
|
|
|
|
|
|
### Setup
|
|
|
|
|
```bash
|
|
|
|
|
chmod +x kip
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
```bash
|
|
|
|
|
kip <package1> [<package2> ...] # Install specific packages
|
|
|
|
|
kip <script.py> # Install from Python file
|
|
|
|
|
kip -r <requirements.txt> # Install from requirements file
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Key Features
|
|
|
|
|
- Smart import detection in Python files
|
|
|
|
|
- Handles package name corrections automatically
|
|
|
|
|
- Uses mamba first, falls back to pip
|
|
|
|
|
- Supports multiple installation methods
|
|
|
|
|
- Filters out built-in modules
|
|
|
|
|
|
|
|
|
|
### Examples
|
|
|
|
|
```bash
|
|
|
|
|
# Install single package
|
|
|
|
|
kip requests
|
|
|
|
|
|
|
|
|
|
# Analyze script and install dependencies
|
|
|
|
|
kip analysis.py
|
|
|
|
|
|
|
|
|
|
# Install from requirements
|
|
|
|
|
kip -r requirements.txt
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Package Corrections
|
|
|
|
|
Automatically corrects common package names:
|
|
|
|
|
- `yaml` → `pyyaml`
|
|
|
|
|
- `dateutil` → `python-dateutil`
|
|
|
|
|
- `dotenv` → `python-dotenv`
|
|
|
|
|
- `newspaper` → `newspaper3k`
|
|
|
|
|
|
|
|
|
|
### Notes
|
|
|
|
|
- Requires Python 3.x
|
|
|
|
|
- Works with mamba or pip
|
|
|
|
|
- Provides clear installation feedback
|
|
|
|
|
- Ignores built-in modules and generic names
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-01-17 12:05:35 -08:00
|
|
|
|
## 📏 linecount - Line Counting Tool for Text Files
|
|
|
|
|
|
|
|
|
|
Recursively counts the total lines in all text files within the current directory, with optional filtering by file extensions.
|
|
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
```bash
|
|
|
|
|
linecount [<extension1> <extension2> ...]
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Examples
|
|
|
|
|
```bash
|
|
|
|
|
linecount # Count lines in all non-binary files
|
|
|
|
|
linecount .py .sh # Count lines only in .py and .sh files
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Key Features
|
|
|
|
|
- **Recursive Search**: Processes files in the current directory and all subdirectories.
|
|
|
|
|
- **Binary File Detection**: Automatically skips binary files.
|
|
|
|
|
- **File Extension Filtering**: Optionally count lines in specific file types (case-insensitive).
|
|
|
|
|
- **Quick Stats**: Displays the number of files scanned and total lines.
|
|
|
|
|
|
|
|
|
|
### Notes
|
|
|
|
|
- If no extensions are provided, all non-binary files are counted.
|
|
|
|
|
- Use absolute or relative paths when running the script in custom environments.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2025-01-17 12:08:10 -08:00
|
|
|
|
## 🔄 up - Bulk Repository Updater
|
|
|
|
|
|
|
|
|
|
Automatically pulls, stages, commits, and pushes changes for multiple Git repositories.
|
|
|
|
|
|
|
|
|
|
### Setup
|
|
|
|
|
|
|
|
|
|
1. **Create a Repository List**
|
|
|
|
|
Add repository paths to `~/myrepos.txt`, one per line:
|
|
|
|
|
```plaintext
|
|
|
|
|
~/workshop/sijapi
|
|
|
|
|
~/workshop/scripts/gitea/pathScripts
|
|
|
|
|
~/workshop/Nova/Themes/Neonva/neonva.novaextension
|
|
|
|
|
~/workshop/scripts/Swiftbar
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
2. **Run the Script**
|
|
|
|
|
```bash
|
|
|
|
|
./up
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Features
|
|
|
|
|
|
|
|
|
|
- Pulls the latest changes from each repository.
|
|
|
|
|
- Stages and commits local changes.
|
|
|
|
|
- Pushes updates to the current branch.
|
|
|
|
|
- Automatically configures the `origin` remote if missing.
|
|
|
|
|
|
|
|
|
|
### Notes
|
|
|
|
|
- Skips directories that aren’t Git repositories.
|
|
|
|
|
- Commit messages are auto-generated as `Auto-update: <timestamp>`.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
## 🔒 vpn - Tailscale Exit Node Manager
|
2024-10-26 14:04:02 -07:00
|
|
|
|
|
2025-01-17 19:43:05 +00:00
|
|
|
|
Privacy-focused Tailscale exit node management with automated logging.
|
2024-10-26 14:04:02 -07:00
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
### Setup
|
2024-10-26 14:04:02 -07:00
|
|
|
|
```bash
|
|
|
|
|
pip3 install requests
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Usage
|
|
|
|
|
```bash
|
2025-01-17 19:43:05 +00:00
|
|
|
|
vpn <action> [<country>] # Actions: start, stop, new, shh, to, status
|
2024-10-26 14:04:02 -07:00
|
|
|
|
```
|
|
|
|
|
|
2024-10-26 14:09:48 -07:00
|
|
|
|
### Actions
|
2025-01-17 19:43:05 +00:00
|
|
|
|
- **`start`**: Connect to a suggested exit node if not already connected.
|
|
|
|
|
- **`stop`**: Disconnect from the current exit node.
|
|
|
|
|
- **`new`**: Switch to a new suggested exit node.
|
|
|
|
|
- **`shh`**: Connect to a random exit node in a privacy-friendly country.
|
|
|
|
|
- **`to <country>`**: Connect to a random exit node in a specific country.
|
|
|
|
|
- **`status`**: Display the current exit node, external IP, and connection duration.
|
|
|
|
|
|
|
|
|
|
### Features
|
|
|
|
|
- **Privacy-Friendly Quick Selection**: Supports random exit nodes from:
|
|
|
|
|
`Finland`, `Germany`, `Iceland`, `Netherlands`, `Norway`, `Sweden`, `Switzerland`.
|
|
|
|
|
- **Connection Verification**: Ensures exit node and IP via Mullvad API.
|
|
|
|
|
- **Automated Logging**: Tracks all connections, disconnections, and IP changes in `/var/log/vpn_rotation.txt`.
|
|
|
|
|
- **Default Tailscale arguments**:
|
2024-10-26 14:09:48 -07:00
|
|
|
|
- `--exit-node-allow-lan-access`
|
|
|
|
|
- `--accept-dns`
|
|
|
|
|
- `--accept-routes`
|
2024-10-26 14:04:02 -07:00
|
|
|
|
|
|
|
|
|
### Examples
|
|
|
|
|
```bash
|
2025-01-17 19:43:05 +00:00
|
|
|
|
vpn start # Connect to a suggested node.
|
|
|
|
|
vpn shh # Connect to a random privacy-friendly node.
|
|
|
|
|
vpn to Germany # Connect to a random exit node in Germany.
|
|
|
|
|
vpn status # Show current connection details.
|
|
|
|
|
vpn stop # Disconnect from the exit node.
|
2024-10-26 14:04:02 -07:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Notes
|
2025-01-17 19:43:05 +00:00
|
|
|
|
- Requires active Tailscale configuration and internet access.
|
|
|
|
|
- Logging is handled automatically in `/var/log/vpn_rotation.txt`.
|
|
|
|
|
- Use `sudo` for actions requiring elevated permissions (e.g., `crontab`).
|
2024-10-26 14:09:48 -07:00
|
|
|
|
|
|
|
|
|
---
|
2024-10-26 14:04:02 -07:00
|
|
|
|
|
2024-10-27 01:43:23 +02:00
|
|
|
|
_More scripts will be documented as they're updated. Most scripts include `--help` for basic usage information._
|