From 71c64d8e34a0603cf187ca6a250fb58bb775dbc1 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Tue, 31 Mar 2020 12:53:53 -0700 Subject: [PATCH] Capture from local machine --- .gitignore | 2 ++ README.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++- bin/vcd | 12 ++++++++++++ bin/wp | 12 ++++++++++++ bin/xdebug | 20 ++++++++++++++++++++ 5 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 bin/vcd create mode 100644 bin/wp create mode 100644 bin/xdebug diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c38fa4e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea +*.iml diff --git a/README.md b/README.md index 5a209b4..522e6d4 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,55 @@ # vvv-aliases -Host-machine aliases to simplify VVV interactions. \ No newline at end of file +Host-machine aliases to simplify VVV interactions. + +## Installation + +1. Add `export VVV_INSTANCE_DIR="[VVV_PATH]"` to your `.bashrc` or `.zshrc`, replacing `[VVV_PATH]` with the full path where VVV's Vagrantfile is found. For example, if your username is `bob` and you checked it out to `~/vvv`, then `[VVV_PATH]` would be replaced with `/Users/bob/vvv`. +1. Add this repository's `bin` directory to your `$PATH`. For example, if you checked this repo out to `~/vvv-aliases`, then you would add `$HOME/vvv-aliases/bin` to your `$PATH`. +1. Open a new terminal window and run the command `which xdebug`. A path should be returned; if `xdebug not found` is shown, verify the path added in the preceding step. + +## Commands + +### `xdebug` + +Toggle the Xdebug module on and off. Xdebug significantly slows down PHP requests, and should only be enabled when actively used. + +Usage: + +```bash +xdebug on + +xdebug off +``` + +### `wp` + +Run WP-CLI commands within Vagrant, returning the result before exiting the VM. + +Usage: + +```bash +user@MacBook:~/vvv/www/wordpress/public_html/wp-content$ wp option get home +cd /srv/www/wordpress/public_html/wp-content; wp option get home + +https://www.wordpress.test + +Connection to 127.0.0.1 closed. +user@MacBook:~/vvv/www/wordpress/public_html/wp-content$ +``` + +Note that if a command requires access to a file, the file must exist within the VM and the command must reference the file using its path within the VM. + +Additionally, commands that use quoted arguments cannot be run through this passthrough script. In those situations, use `vcd`. + +### `vcd` + +Switch to the current directory within the VM. + +Usage: + +```bash +user@MacBook:~/vvv/www/wordpress/public_html/wp-content$ vcd + +vagrant@vvv:/srv/www/wordpress/public_html/wp-content$ wp option set test --format=json '{"1":true,"2":false}' + +``` diff --git a/bin/vcd b/bin/vcd new file mode 100644 index 0000000..5238472 --- /dev/null +++ b/bin/vcd @@ -0,0 +1,12 @@ +#!/bin/bash + +REL_PATH=$(pwd) + +cd "${VVV_INSTANCE_DIR}" || exit 1 + +VAGRANT_PATH=${REL_PATH/$VVV_INSTANCE_DIR/\/srv} + +CMD="cd ${VAGRANT_PATH}; bash" +printf "%s\n\n" "$CMD" + +vagrant ssh -c "${CMD}; echo" diff --git a/bin/wp b/bin/wp new file mode 100644 index 0000000..964d668 --- /dev/null +++ b/bin/wp @@ -0,0 +1,12 @@ +#!/bin/bash + +REL_PATH=$(pwd) + +cd "${VVV_INSTANCE_DIR}" || exit 1 + +VAGRANT_PATH=${REL_PATH/$VVV_INSTANCE_DIR/\/srv} + +CMD="cd ${VAGRANT_PATH}; wp $*" +printf "%s\n\n" "$CMD" + +vagrant ssh -c "${CMD}; echo" diff --git a/bin/xdebug b/bin/xdebug new file mode 100644 index 0000000..a19fc06 --- /dev/null +++ b/bin/xdebug @@ -0,0 +1,20 @@ +#!/bin/bash + +cd "${VVV_INSTANCE_DIR}" || exit 1 + +case $1 in + on) + CMD="/srv/config/homebin/xdebug_on" + ;; + + off) + CMD="/srv/config/homebin/xdebug_off" + ;; + + *) + echo "Specify 'on' or 'off' as the first argument." + exit 1 + ;; +esac + +vagrant ssh -c "${CMD}" -- GitLab