Skip to content

Commit 6e7c317

Browse files
Port over aliases and SSH
1 parent cd187f2 commit 6e7c317

File tree

1 file changed

+46
-19
lines changed

1 file changed

+46
-19
lines changed

_posts/2016-07-29-version-0.24.0.md

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,53 @@ Use `wp cli update` to install v0.24.0, representing [NNN resolved issues and pu
2929

3030
### Aliases and SSH support
3131

32+
#### Effortlessly use WP-CLI against any WordPress install
3233

33-
[#2755](https://github.com/wp-cli/wp-cli/pull/2755)
34-
35-
[#2974](https://github.com/wp-cli/wp-cli/pull/2974)
36-
37-
https://github.com/wp-cli/wp-cli/pull/3012
38-
https://github.com/wp-cli/wp-cli/pull/3013
39-
https://github.com/wp-cli/wp-cli/pull/3014
40-
https://github.com/wp-cli/wp-cli/pull/3016
41-
https://github.com/wp-cli/wp-cli/pull/3026
42-
https://github.com/wp-cli/wp-cli/pull/3040
43-
https://github.com/wp-cli/wp-cli/pull/3070
44-
https://github.com/wp-cli/wp-cli/pull/3093
45-
https://github.com/wp-cli/wp-cli/pull/3100
46-
https://github.com/wp-cli/wp-cli/pull/3117
47-
https://github.com/wp-cli/wp-cli/pull/3134
48-
https://github.com/wp-cli/wp-cli/pull/3135
49-
https://github.com/wp-cli/wp-cli/pull/3145
50-
https://github.com/wp-cli/wp-cli/pull/3161
51-
https://github.com/wp-cli/wp-cli/pull/3180
34+
WP-CLI aliases are shortcuts you register in your `wp-cli.yml` or `config.yml` to effortlessly run commands against any WordPress install.
35+
36+
For instance, if I'm working locally on the runcommand theme, have registered a new rewrite rule, and need to flush rewrites inside my Vagrant-based virtual machine, I can run:
37+
38+
$ wp @dev rewrite flush
39+
Success: Rewrite rules flushed.
40+
41+
Then, once the code goes to production, I can run:
42+
43+
$ wp @prod rewrite flush
44+
Success: Rewrite rules flushed.
45+
46+
Look ma! No more SSH'ing into machines, changing directories, and generally spending a full minute to get to a given WordPress install.
47+
48+
Additionally, alias groups let you register groups of aliases. If I want to run a command against both runcommand WordPress instances, I can use `@both`:
49+
50+
$ wp @both core check-update
51+
Success: WordPress is at the latest version.
52+
Success: WordPress is at the latest version.
53+
54+
Aliases can be registered in your project's `wp-cli.yml` file, or your user's global `~/.wp-cli/config.yml` file:
55+
56+
@prod:
57+
ssh: runcommand@runcommand.io~/webapps/production
58+
@dev:
59+
ssh: vagrant@192.168.50.10/srv/www/runcommand.dev
60+
@both:
61+
- @prod
62+
- @dev
63+
64+
#### But wait, what's the 'ssh' in there?
65+
66+
WP-CLI now natively supports a `--ssh=<host>` global parameter for running a command against a remote WordPress install. Many thanks to XWP and their community for paving the way with [WP-CLI SSH](https://github.com/xwp/wp-cli-ssh).
67+
68+
Under the hood, WP-CLI proxies commands to the `ssh` executable, which then passes them to WP-CLI installed on the remote machine. Your syntax for `-ssh=<host>` can be any of the following:
69+
70+
* Just the host (e.g. `wp --ssh=runcommand.io`), which means the user will be inferred from your current system user, and the path will be the SSH user's home directory.
71+
* The user and the host (e.g. `wp --ssh=runcommand@runcommand.io`).
72+
* The user, the host, and the path to the WordPress install (e.g. `wp --ssh=runcommand@runcommand.io~/webapps/production`). The path comes immediately after the TLD of the host.
73+
74+
Or, if you use a `~/.ssh/config`, `<host>` can be any host alias stored in the SSH config (e.g. `wp --ssh=rc` for me).
75+
76+
Note you do need a copy of WP-CLI on the remote server, accessible as `wp`. Futhermore, `--ssh=<host>` won't load your `.bash_profile` if you have a shell alias defined, or are extending the `$PATH` environment variable. If this affects you, [here's a more thorough explanation](https://runcommand.io/to/wp-ssh-custom-path/) of how you can make `wp` accessible.
77+
78+
Relevant pull requests include: [#2755](https://github.com/wp-cli/wp-cli/pull/2755), [#2974](https://github.com/wp-cli/wp-cli/pull/2974), [#3012](https://github.com/wp-cli/wp-cli/pull/3012), [#3013](https://github.com/wp-cli/wp-cli/pull/3013), [#3014](https://github.com/wp-cli/wp-cli/pull/3014), [#3016](https://github.com/wp-cli/wp-cli/pull/3016), [#3026](https://github.com/wp-cli/wp-cli/pull/3026), [#3040](https://github.com/wp-cli/wp-cli/pull/3040), [#3070](https://github.com/wp-cli/wp-cli/pull/3070), [#3093](https://github.com/wp-cli/wp-cli/pull/3093), [#3100](https://github.com/wp-cli/wp-cli/pull/3100), [#3117](https://github.com/wp-cli/wp-cli/pull/3117), [#3134](https://github.com/wp-cli/wp-cli/pull/3134), [#3135](https://github.com/wp-cli/wp-cli/pull/3135), [#3145](https://github.com/wp-cli/wp-cli/pull/3145), [#3161](https://github.com/wp-cli/wp-cli/pull/3161), [#3180](https://github.com/wp-cli/wp-cli/pull/3180).
5279

5380
### Future of WP-CLI
5481

0 commit comments

Comments
 (0)