WordPress at Your Fingertips

Environment variables

WP-CLI’s behavior can be changed at runtime through the use of environment variables.

To set an environment variable on demand, simply place the environment variable definition before the WP-CLI command you mean to run.

# Use vim to edit a post
$ EDITOR=vim wp post edit 1

To set the same environment variable value for every shell session, you’ll need to include the environment variable definition in your ~/.bashrc or ~/.zshrc file.

# Always use vim to edit a post
export EDITOR=vim

List of Environment variables

WP_CLI_CACHE_DIR
Directory to store the WP-CLI file cache.
Default: ~/.wp-cli/cache/
WP_CLI_CONFIG_PATH
Path to the global config.yml file.
Default: ~/.wp-cli/config.yml
WP_CLI_CUSTOM_SHELL
Allows the user to override the default /bin/bash shell used.
WP_CLI_DISABLE_AUTO_CHECK_UPDATE
Disable WP-CLI automatic checks for updates.
WP_CLI_PACKAGES_DIR
Directory to store packages installed through WP-CLI’s package management.
Default: ~/.wp-cli/packages/
WP_CLI_PHP
PHP binary path to use when overriding the system default (only works for non-Phar installation).
WP_CLI_PHP_ARGS
Arguments to pass to the PHP binary when invoking WP-CLI (only works for non-Phar installation).
WP_CLI_SSH_PRE_CMD
When using --ssh=<ssh>, perform a command before WP-CLI calls WP-CLI on the remote server.
WP_CLI_STRICT_ARGS_MODE
Avoid ambiguity by telling WP-CLI to treat any arguments before the command as global, and after the command as local.
WP_CLI_SUPPRESS_GLOBAL_PARAMS
Set to true to skip showing the global parameters at the end of the help screen. This saves screen estate for advanced users.
1 comment
    Log In