Various shell scripts that are useful enough to me to keep in my PATH
Find a file
2025-01-17 12:20:10 -08:00
.gitignore Update .gitignore 2025-01-17 00:31:41 +00:00
aax2mp3 Auto-update: Sun Nov 3 12:57:01 PST 2024 2024-11-03 12:57:01 -08:00
bates Auto-update: Sat Oct 26 13:45:39 PDT 2024 2024-10-26 13:45:39 -07:00
camel Auto-update: Sun Nov 3 12:57:01 PST 2024 2024-11-03 12:57:01 -08:00
cf Auto-update: Tue Jul 30 19:48:25 PDT 2024 2024-07-30 19:48:25 -07:00
checknode Auto-update: Tue Jul 30 19:30:24 PDT 2024 2024-07-30 19:30:24 -07:00
comfy Auto-update: Tue Jul 30 19:30:24 PDT 2024 2024-07-30 19:30:24 -07:00
ddns Auto-update: Tue Jul 30 19:48:25 PDT 2024 2024-07-30 19:48:25 -07:00
delpycache added delpycache for deleting all __pycache__ folders in current folder and its subfolders 2024-06-23 14:06:44 -07:00
emoji_flag Auto-update: Thu Oct 31 16:43:33 PDT 2024 2024-10-31 16:43:33 -07:00
get Auto-update: Tue Jul 9 16:15:05 PDT 2024 2024-07-09 16:15:05 -07:00
gitpurge Auto-update: Tue Jul 30 20:55:02 PDT 2024 2024-07-30 20:55:02 -07:00
gitscan routine update 2024-08-03 00:22:15 -07:00
import_finder Auto-update: Thu Oct 31 16:43:33 PDT 2024 2024-10-31 16:43:33 -07:00
ip Auto-update: Mon Nov 4 13:18:30 PST 2024 2024-11-04 13:18:30 -08:00
kip Auto-update: Mon Aug 5 19:11:27 PDT 2024 2024-08-05 19:11:27 -07:00
linecount Auto-update: Fri Jan 17 12:05:35 PST 2025 2025-01-17 12:05:35 -08:00
lsd Auto-update: Tue Jul 30 19:30:24 PDT 2024 2024-07-30 19:30:24 -07:00
mamba_exporter Auto-update: Thu Oct 31 16:43:33 PDT 2024 2024-10-31 16:43:33 -07:00
mamba_importer Auto-update: Thu Oct 31 16:43:33 PDT 2024 2024-10-31 16:43:33 -07:00
murder Auto-update: Tue Jul 30 19:30:24 PDT 2024 2024-07-30 19:30:24 -07:00
nocomment Auto-update: Thu Oct 31 16:43:33 PDT 2024 2024-10-31 16:43:33 -07:00
noon first commit 2024-06-23 13:47:43 -07:00
nv first commit 2024-06-23 13:47:43 -07:00
ocr Auto-update: Wed Nov 13 09:17:05 PST 2024 2024-11-13 09:17:05 -08:00
ollapull Auto-update: Fri Jan 17 11:58:23 PST 2025 2025-01-17 11:58:23 -08:00
pf Auto-update: Wed Jun 26 10:08:59 PDT 2024 2024-06-26 10:08:59 -07:00
pippin routine update 2024-08-03 00:22:15 -07:00
pull Auto-update: Sat Aug 3 12:14:26 PDT 2024 2024-08-03 12:14:26 -07:00
push Auto-update: Fri Jan 17 12:20:10 PST 2025 2025-01-17 12:20:10 -08:00
README.md Auto-update: Fri Jan 17 12:20:10 PST 2025 2025-01-17 12:20:10 -08:00
serv first commit 2024-06-23 13:47:43 -07:00
sij Auto-update: Thu Aug 8 15:55:31 PDT 2024 2024-08-08 15:55:31 -07:00
tablemd Auto-update: Thu Dec 19 17:52:33 PST 2024 2024-12-19 17:52:33 -08:00
tmux_merge Auto-update: Thu Oct 31 16:43:33 PDT 2024 2024-10-31 16:43:33 -07:00
txt_line_merge_abc Auto-update: Thu Oct 31 16:43:33 PDT 2024 2024-10-31 16:43:33 -07:00
txtsort Auto-update: Tue Jul 30 19:30:24 PDT 2024 2024-07-30 19:30:24 -07:00
uninstall Auto-update: Fri Jan 17 12:10:42 PST 2025 2025-01-17 12:10:42 -08:00
vitals Auto-update: Thu Nov 14 00:16:33 PST 2024 2024-11-14 00:16:33 -08:00
vpn Update vpn 2025-01-17 19:34:10 +00:00
z Auto-update: Wed Oct 30 19:21:37 PDT 2024 2024-10-30 19:21:37 -07:00

PATH-worthy Scripts 🛠️

A collection of various scripts I use frequently enough to justify keeping them in my system PATH.

I haven't written documentation for all of these scripts. I might in time. Find documentation for some of the highlights below.

Installation

  1. Clone and enter repository:
git clone https://sij.ai/sij/pathScripts.git
cd pathScripts
  1. Add to your system PATH:

macOS / ZSH:

echo "export PATH=\"\$PATH:$PWD\"" >> ~/.zshrc
source ~/.zshrc

Linux / Bash:

echo "export PATH=\"\$PATH:$PWD\"" >> ~/.bashrc
source ~/.bashrc
  1. Make scripts executable:
chmod +x *

📄 bates - PDF Bates Number Tool

Extracts and renames PDFs based on Bates numbers.

Setup

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

Usage

bates /path/to/folder --prefix "FWS-" --digits 6 --name-prefix "FWS "

Key Features

  • Extracts Bates numbers from text/scanned PDFs
  • Renames files with number ranges
  • Prepare files for use with my Bates Source Link DEVONthink script
  • Preserves original names in Finder comments
  • OCR support for scanned documents
  • Dry-run mode with --dry-run

Options

  • --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)

Examples

# Test without making changes
bates /path/to/pdfs --prefix "FWS-" --digits 6 --dry-run

# Rename files with OCR support
bates /path/to/pdfs --prefix "FWS-" --digits 6 --name-prefix "FWS " --ocr

Notes

  • Always test with --dry-run first
  • Original filenames are preserved in Finder comments (macOS only)
  • OCR is disabled by default to keep things fast

🐪 camel - File Renaming Utility

Renames files in the current directory by splitting camelCase, PascalCase, and other compound words into readable, spaced formats.

Features

  • Smart Splitting:
    • Handles camelCase, PascalCase, underscores (_), hyphens (-), and spaces.
    • Preserves file extensions.
    • Splits on capital letters and numbers intelligently.
  • Word Detection:
    • Uses NLTKs English word corpus and WordNet to identify valid words.
    • Common words like "and", "the", "of" are always treated as valid.
  • Automatic Renaming:
    • Processes all files in the current directory (ignores hidden files).
    • Renames files in-place with clear logging.

Setup

  1. Install dependencies:
    pip3 install nltk
    
  2. Download NLTK data:
    python3 -m nltk.downloader words wordnet
    

Usage

Run the script in the directory containing the files you want to rename:

./camel

Examples

Before running the script:

Anti-OedipusCapitalismandSchizophrenia_ep7.aax
TheDawnofEverythingANewHistoryofHumanity_ep7.aax
TheWeirdandtheEerie_ep7.aax

After running the script:

Anti Oedipus Capitalism and Schizophrenia ep 7.aax
The Dawn of Everything A New History of Humanity ep 7.aax
The Weird and the Eerie ep 7.aax

Notes

  • Hidden files (starting with .) are skipped.
  • If a word isnt found in the dictionary, its left unchanged.
  • File extensions are preserved during renaming.

📦 kip - Intelligent Python Package Installer

A smart package installer that automates Python dependency management, supporting both mamba and pip.

Setup

chmod +x kip

Usage

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

# 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:

  • yamlpyyaml
  • dateutilpython-dateutil
  • dotenvpython-dotenv
  • newspapernewspaper3k

Notes

  • Requires Python 3.x
  • Works with mamba or pip
  • Provides clear installation feedback
  • Ignores built-in modules and generic names

📏 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

linecount [<extension1> <extension2> ...]

Examples

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.

🔄 push & pull - Bulk Git Repository Management

Scripts to automate updates and management of multiple Git repositories.

Setup

  1. Create a Repository List
    Add repository paths to repos.txt in the same directory as the scripts, one per line:

    ~/workshop/sijapi
    ~/workshop/scripts/gitea/pathScripts
    ~/workshop/Nova/Themes/Neonva/neonva.novaextension
    ~/workshop/scripts/Swiftbar
    
  2. Make Scripts Executable

    chmod +x push pull
    
  3. Run the Scripts

    ./pull    # Pulls the latest changes from all repositories
    ./push    # Pulls, stages, commits, and pushes local changes
    

Features

pull

  • Recursively pulls the latest changes from all repositories listed in repos.txt.
  • Skips directories that are not Git repositories.
  • Forces pull to ensure synchronization.

push

  • Pulls the latest changes.
  • Stages and commits all local changes with an auto-generated message: Auto-update: <timestamp>.
  • Pushes updates to the current branch.
  • Configures the origin remote automatically if missing.

Notes

  • Both scripts skip empty lines and comments (#) in repos.txt.
  • Ensure repos.txt is in the same directory as the scripts.
  • Use absolute or relative paths for repository locations.
  • push will auto-configure origin based on directory name if missing.

🔒 vpn - Tailscale Exit Node Manager

Privacy-focused Tailscale exit node management with automated logging.

Setup

pip3 install requests

Usage

vpn <action> [<country>]  # Actions: start, stop, new, shh, to, status

Actions

  • 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:
    • --exit-node-allow-lan-access
    • --accept-dns
    • --accept-routes

Examples

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.

Notes

  • 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).

More scripts will be documented as they're updated. Most scripts include --help for basic usage information.