Handy script: lbf

Local (by Flywheel) is great, but for a terminal type of person as I am, I find it way more convenient to SSH into a VM and use the WP-CLI to perform WordPress tasks. With a platform like Vagrant, one has the

vagrant ssh
command to shell into the virtual environment.

With Local, you can do this with the push of a button in Local, but as said, I like the terminal better.

lbf ssh
is waaaaay faster than going to the Local app, find the site, click the SSH button.

But wait, there is much more ;)

The lbf command can do the following, from within a directory controlled by Local (for instance ~/Local Sites/mywebsite/app/public)

lbf list List all sites
lbf raw View all info Local has on this site
lbf open Open the site in your default browser
lbf mailhog Open the mailhog software for this site in your default browser
lbf db Open Sequel Pro with the database of this site
lbf ssh [optional: command line] Open the docker shell of this site, or execute the command line inside the docker shell
lbf wp commands Perform WP-CLI operation on site
lbf wpdr Perform wp search-replace <current domain> <local domain>

You can use --site, --project or -p to specify a site, either by Name, ID or Path to operate on
You can use --browser or -b to specify a WebBrowser either by AppName or AppPath to use for ‘open’ and ‘mailhog’
You can use --ssl to use https with operation ‘open’ and ‘wpdr’
You can use browser shortcuts;

-ff
--firefox
Firefox
-fd
--firefox-dev
--firefox-developer-edition
Firefox Developer Edition
-c
--chrome
Chrome
-cd
--chrome-dev
--chromium
Chromium
-o
--opera
Opera
-s
--safari
Safari

Of course, the browser of choice must be installed… Duh…

So, now you can do this: (while inside the app folder)

lbf db
and import a database
lbf wpdr
to make sure the site runs on the local domain
lbf wp plugin install --activate wordpress-seo classic-editor duplicate-post what-the-file wp-smushit
ah, well, you get the idea :)

I would hope to one day add the following commands:

lbf start|stop|restart Start, Stop or Restart the site
lbf vm start|stop|restart Start, Stop or Restart the Local VM
lbf app start|stop|restart Start, Stop or Restart the entire Local ecosystem

The last one, while technically already possible, is not yet useful until the site and vm start/stop/restart options are functional.

Enjoy, but as always; at your own risk :)

Author: Remon Pel

WebDeveloper though not WebDesigner

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.