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

Directory to store the WP-CLI file cache.
Default: ~/.wp-cli/cache/
Path to the global config.yml file.
Default: ~/.wp-cli/config.yml
Allows the user to override the default /bin/bash shell used.
Disable WP-CLI automatic checks for updates.
Directory to store packages installed through WP-CLI’s package management.
Default: ~/.wp-cli/packages/
PHP binary path to use when overriding the system default (only works for non-Phar installation).
Arguments to pass to the PHP binary when invoking WP-CLI (only works for non-Phar installation).
When using --ssh=<ssh>, perform a command before WP-CLI calls WP-CLI on the remote server.
Avoid ambiguity by telling WP-CLI to treat any arguments before the command as global, and after the command as local.
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