My collection of shell functions and configuration files for WordPress development.
dotfiles/
├── shell/
│ ├── cloudflare.sh # Cloudflare zone management (cf-opt, cf-check)
│ ├── config.sh # Global configuration management
│ ├── deployment.sh # Theme deployment (firstdeploy, depto)
│ ├── git.sh # Git utilities and branch management
│ ├── utils.sh # System utilities and common aliases
│ ├── wp-core.sh # WordPress WP-CLI shortcuts and aliases
│ ├── wp-db.sh # All database operations (pullprod, dmcweb, wp_db_optimise, etc.)
│ ├── wp-diagnostics.sh # Troubleshooting (wp_plugin_diags)
│ ├── wp-mcp.sh # AI integration via Model Context Protocol (wp_mcp_add_site, wp_mcp_add_remote_site, wp_mcp_install_remote_plugins, wp_mcp_remove_site, wp_mcp_list_sites)
│ ├── wp-fleet.sh # Fleet operations across registered MCP sites (wp_fleet_update, wp_fleet_db_optimise)
│ └── wp-uploads.sh # Upload/file sync operations (getups, pushups)
├── .gitignore
└── README.md
This dotfiles system uses a centralized configuration approach that keeps sensitive information secure while maintaining full functionality:
shell/config.sh- Central configuration manager with safe defaults.dotfiles-config- Your personal settings file (git-ignored for security)- Automatic loading - Functions load config when needed, no manual setup required
- All sensitive values (passwords, hostnames, API keys) are stored in
.dotfiles-config - This file is git-ignored so it never gets committed to the public repository
- Other users get safe defaults and can create their own personal configuration
- You keep full functionality with your actual credentials
Each function automatically loads configuration when called:
load_dotfiles_config 2>/dev/null || true # Safe loading pattern-
Clone this repository:
cd ~ git clone git@github.com:davemac/dotfiles.git
-
Create symbolic link to your home directory:
ln -s ~/dotfiles/shell ~/.shell-functions
-
Add loading code to your shell config (choose your shell):
For zsh (~/.zshrc):
# Load shell functions (interactive features) for file in ~/.shell-functions/*.sh; do source "$file" done
For bash (~/.bashrc):
# Load shell functions for file in ~/.shell-functions/*.sh; do source "$file" done
-
Reload your shell:
source ~/.zshrc # or ~/.bashrc
-
Create your personal configuration:
dotfiles_config --create # Creates .dotfiles-config in repo root dotfiles_config --edit # Edit your personal settings
-
Get started:
listcmds # View all available commands organised by category
After installation, you'll want to customise your .dotfiles-config file with your actual values:
DEV_WP_PASSWORD- Your preferred WordPress development passwordSSH_PROXY_HOST- Your SSH proxy server hostnameWC_HOSTS- Your WooCommerce production server aliasesDEV_PLUGINS_ACTIVATE- Plugins to activate locally after DB pullPROD_PLUGINS_DEACTIVATE- Production-only plugins to deactivate locallySTAGING_PLUGINS_DELETE- Dev plugins to remove on staging deploysSTAGING_DOMAIN- Staging domain suffix (default: dmctest.com.au)- And other personal settings...
Central configuration system that manages all dotfiles settings securely:
dotfiles_config --create: Create your personal configuration filedotfiles_config --show: Display current configuration settings and valuesdotfiles_config --edit: Edit configuration file with your default editordotfiles_config --help: Show detailed configuration helpload_dotfiles_config: Load configuration (used automatically by functions)
Tools for managing Cloudflare zone settings:
Optimisation:
cf-opt: Apply performance and security optimisations (interactive)cf-opt DOMAIN: Non-interactive batch modecf-opt DOMAIN SITE_PATH: Batch mode with logging
Verification:
cf-check: Check current Cloudflare settings and test cache headerscf-help: Show detailed help and usage examples
What cf-opt configures:
- Performance: HTTP/3, Early Hints, Tiered Cache, Auto Minify, 0-RTT
- Security: SSL Full (Strict), TLS 1.3, Min TLS 1.2, HTTPS Rewrites
- Cache Rules: Static assets, CSS/JS/fonts, images, WooCommerce bypass
Configuration:
- Requires
CF_API_TOKENin.dotfiles-config - Token needs: Zone Settings, Cache Rules, Cache Purge, Argo Smart Routing permissions
Essential WP-CLI aliases and shortcuts:
updatem: Update all plugins, themes, and WordPress coresiteurl: Display current site URL from databaseplugincheck: Check for plugin conflictsonetimeinstall: Install one-time login plugin on productiononetimeadmin: Generate one-time login link for admin
All database-related functions consolidated:
Database Sync Functions:
pullprod: Pull production database to local environment (full sync with--yes/-yflag)pullstage: Pull staging database to local environmentpushstage: Push local database to staging environmentpulldb: Export production database to timestamped local file
User Management:
dmcweb [user]: Update user password to configured dev password (defaults to first admin)
Multi-Host Operations:
update-wc-db: Update WooCommerce database on multiple configured hosts
Database Optimisation:
wp_db_optimise [options]/wpopt: Comprehensive database cleanup and optimisationwp_db_table_delete [options]/wpdel: Interactive database table cleanup
File sync operations between environments:
getups: Sync WordPress uploads directory from remote (l/s,-week/-latest)pushups: Push uploads to remote server (-auto,-target)
Tools for debugging WordPress issues:
wp_plugin_diags: Systematically test plugins to isolate fatal errors
Helpers for exposing WordPress sites to AI agents via the Model Context Protocol (MCP):
wp_mcp_add_site SITENAME [SUBSITE_URL] [SERVER_SUFFIX]: Install thewp-system-reportandmcp-adapterplugins on a local site (under~/Sites/SITENAME), activate them, and register the site as a STDIO MCP server in Claude Code aswordpress-SITENAME. Multisite-aware: detects networks viawp core is-installed --networkand uses--networkactivation. Pass an optionalSUBSITE_URLto register a per-subsite entry (registered aswordpress-SITENAME-<slug>, with--url=baked into the wp-cli args); pass an explicitSERVER_SUFFIXto override the auto-derived slug when subsite hosts collide (e.g. subdirectory installs). Idempotent — safe to re-run.wp_mcp_add_remote_site SITENAME URL USERNAME APP_PASSWORD: Register a remote (production or staging) WordPress site aswordpress-SITENAME, using the Automatticmcp-wordpress-remoteSTDIO proxy. Client-side only — the remote site must already havewp-system-reportandmcp-adapterinstalled and active. The URL may be a base URL (e.g.https://example.com.au) or a full MCP endpoint URL.wp_mcp_install_remote_plugins SITENAME [ALIAS]: Companion to the above. Reads~/Sites/SITENAME/wp-cli.yml, resolves the named alias (defaults to@prod), and uses itsssh:+path:values to SSH into the host, clone both plugins intowp-content/plugins, runcomposer installonmcp-adapter, and activate them. Activation is invoked aswp @prod plugin activate ...so wp-cli handles the SSH plumbing; multisite is detected viawp @prod core is-installed --networkand triggers--networkactivation. Pre-flight checks confirmgit,composer, andwpare on the remote PATH.wp_mcp_remove_site SITENAME: Unregister awordpress-SITENAMEentry from Claude Code. Idempotent — does not delete the WordPress plugins server-side.wp_mcp_list_sites: List everywordpress-*MCP server known to Claude Code (across user and project scopes), grouped by transport (stdio-localvshttp-proxy).
Requirements: wp-cli, composer, git, jq, npx, and the claude command on PATH. The local WordPress admin user must be named admin (otherwise edit the --user= flag in wp_mcp_add_site). For remote sites, use a WordPress application password (Users → Profile → Application Passwords), not the user's main login password.
Multi-site bulk operations that iterate every wordpress-* MCP server registered in Claude Code (read directly from ~/.claude.json, same source as wp_mcp_list_sites). Failures on individual sites are aggregated, never abort the run.
wp_fleet_update [options]: Runwp plugin update --all,wp theme update --all, andwp core updateagainst every local registered site, in that order. Equivalent toupdatemapplied across the fleet.wp_fleet_db_optimise [options]: Run a safe subset ofwp_db_optimiseacross every local registered site — delete expired transients, orphaned postmeta, stale auto-drafts, stale edit locks, and runwp db optimize. Deliberately does NOT rewrite wp-config constants or deactivate/activate plugins (those arewp_db_optimise's dev-focused steps and would be dangerous on production).
Shared flags:
--dry-run,-n— preview pending operations; execute nothing--yes,-y— skip the interactive confirmation prompt--json— emit machine-readable JSON (suppresses all decorative output; stable contract for a future web-app dashboard)--only=<pattern>— glob filter over server names (--only=colacnewor--only=wordpress-colac*)--exclude=<pattern>— inverse glob filter--help,-h— per-function help
Design decisions (documented in full in the wp-fleet.sh header):
- Remote (
http-proxy) sites are skipped in v1 — the MCP registry stores HTTP credentials for diagnostics but not the SSH details wp-cli needs. They are recorded in the JSON summary withstatus: "skipped". v2 plan: aWP_FLEET_SSH_MAPin.dotfiles-config. - JSON shape is a stable contract documented at the top of
wp-fleet.sh.
Deployment automation:
firstdeploy: Initial site deployment to stagingfirstdeploy-prod: Initial site deployment to productiondepto: Deploy theme files to staging or production
Version control workflow and convenient aliases:
new_branch: Create new branch from ticket ID and titlegs: Git status (alias)ga: Git add (alias)gca: Git commit all (alias)gc: Git commit (alias)gl: Formatted git log with graph, dates, and decoration
General system tools and productivity functions:
listcmds: Display all available commands and functions in a neat table
File System Utilities:
showsize: Display directory sizes (alias: du -sh ./*)dsclean: Delete all .DS_Store files recursivelyls: Enhanced ls with colours and details (alias)up [N]: Move up N directories in the filesystem
Network Utilities:
myip: Display your public IP addresssocksit: Create SSH SOCKS proxy (uses configured SSH_PROXY_HOST)chromeproxy: Launch Chrome with SSH SOCKS proxyflushdns: Flush DNS cache and announce completion
Development Tools:
zp: Edit ~/.zprofile in Cursor (alias)sshconfig: Edit ~/.ssh/config in Cursor (alias)code: Open files in VSCode with proper setuptb: Send text to termbin.com (alias)
Homebrew Utilities:
brewup: Update Homebrew packages (alias)brewupc: Update Homebrew packages and cleanup (alias)
Media Download Tools:
ytaudio [URL]: Download YouTube audio as MP3download_vimeo_hd/dlvimeo: Download all Vimeo videos from a page in HD with metadata
Sync uploads from live site:
cd ~/Sites/yoursite
getups l # Sync all uploads
getups l -latest # Sync only last 2 months
getups l -week # Sync only last 7 daysPush uploads to staging:
pushups -auto -target s # Auto-detect site and push to stagingPull production database:
cd ~/Sites/yoursite
pullprod # Interactive confirmation
pullprod --yes # Skip confirmationOptimise local database:
wp_db_optimise # Or use alias: wpoptClean up database tables:
wp_db_table_delete # Or use alias: wpdelDownload Vimeo videos from a lesson page (HD with source URL metadata):
dlvimeo https://example.com/lesson-page/Test for plugin conflicts:
cd ~/Sites/yoursite
wp_plugin_diags # Systematically test each pluginSet up a local WordPress site for AI-driven diagnostics via Claude Code:
wp_mcp_add_site colacnew # Installs plugins + registers wordpress-colacnew with Claude CodeMultisite — expose the network's main site, or one entry per subsite:
wp_mcp_add_site mynet # Network-activates, registers wordpress-mynet (main site)
wp_mcp_add_site mynet https://subsite-a.localhost # Registers wordpress-mynet-subsite-a
wp_mcp_add_site mynet https://mynet.localhost/subdir-b/ subdir-b # Subdirectory subsite, explicit suffix to avoid collisionInstall the MCP plugins on a remote site over SSH (resolves SSH alias + remote path from the site's wp-cli.yml):
wp_mcp_install_remote_plugins colacnew # uses @prod by default
wp_mcp_install_remote_plugins colacnew @staging # override with a different aliasRegister a remote (production or staging) site that already has the plugins deployed:
wp_mcp_add_remote_site myclient https://myclient.com.au admin xxxx-xxxx-xxxx-xxxxList every registered WordPress MCP server (grouped by transport):
wp_mcp_list_sitesUnregister a site (does not touch the WordPress plugins themselves):
wp_mcp_remove_site colacnewAfter adding or removing, restart Claude Code and ask: "health check on wordpress-colacnew".
Bulk-iterate every registered WordPress MCP site. Use --dry-run first; the real run will prompt unless --yes is given.
wp_fleet_update --dry-run # preview pending updates across all sites
wp_fleet_update --only=colacnew --dry-run # preview for a single site
wp_fleet_update --yes # apply updates across the fleet
wp_fleet_update --json --yes | jq . # machine-readable output for tooling
wp_fleet_db_optimise --dry-run # preview cleanup counts across all sites
wp_fleet_db_optimise --only=colacnew --yes
wp_fleet_db_optimise --json --yes | jq '.sites[] | {name, details}'Deploy theme to staging:
cd ~/Sites/yoursite/wp-content/themes/yoursite
depto -auto -target stagingOptimise a Cloudflare zone interactively:
cf-opt # Prompts for zone selection and confirmationsOptimise in batch mode (non-interactive):
cf-opt example.com.au # No logging
cf-opt example.com.au ~/Sites/example # With logging to site directoryCheck current settings:
cf-check # View settings and test cache headersCreate new feature branch:
new_branch IR-123 "add new feature" # Creates feature/IR-123-add-new-featureList all available commands:
listcmds # Display comprehensive list of all functions and aliases- macOS
- Homebrew
- WP-CLI
- Git
- SSH access to deployment servers
- jq (for Cloudflare and MCP functions:
brew install jq) - Composer, Node.js/npx, and Claude Code CLI (for
wp-mcp.shfunctions)
~/
├── .shell-functions -> ~/dotfiles/shell/ # Symlink to shell functions
└── dotfiles/
├── shell/
│ ├── cloudflare.sh # Cloudflare zone management
│ ├── config.sh # Central configuration system
│ ├── deployment.sh # Theme deployment functions
│ ├── git.sh # Git utilities
│ ├── utils.sh # System utilities
│ ├── wp-core.sh # WordPress shortcuts
│ ├── wp-db.sh # Database operations
│ ├── wp-diagnostics.sh # Troubleshooting
│ ├── wp-mcp.sh # AI integration (MCP)
│ ├── wp-fleet.sh # Fleet operations across MCP sites
│ └── wp-uploads.sh # File sync operations
├── .dotfiles-config # Your personal settings (git-ignored)
├── .gitignore # Includes .dotfiles-config
└── README.md
~/.shell-functions/- Symlink that makes all functions available in your shell.dotfiles-config- Contains your personal/sensitive configuration values.gitignore- Ensures.dotfiles-configis never committed to git
To update the functions:
cd ~/dotfiles
git pullNo additional steps needed! The symbolic link ensures you always use the latest files.
- Your
.dotfiles-configfile will never be overwritten during updates - New configuration options may be added - run
dotfiles_config --showto see available settings - Functions automatically load the latest configuration when called
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request