Open WP Admin From The Command Line

I use WP-CLI for pretty much everything these days. And since I am more and more working from a Linux system and thus practically living on the command line, I wanted to have a quick way to open WP Admin right there.

I added the following shell function to my bash config file, .bashrc in my case:

wpadmin() {
    local site="${1:-}"
    (open "$(wp $site option get siteurl --skip-plugins)/wp-admin" 2>/dev/null &)
}

It works with and without WP-CLI aliases, so I can use it both locally and for remote sites.

A couple of notes:

I hope you find this useful!


Comment via Email or Mastodon