Today -after a very frustrating hour- I found out git checks for
.gitignore inside folders.
Folder tree example
.git (the root)
.gitignore (git also checks this one)
For the last month and a half I’ve started using vvv, and it works like a charm.
As I’m setting up a lot of sites I have to run provision a lot.
And that is quite a heavy operation in vvv because it pretty much checks every thing.
Luckily there is also a way to provision a single site.
vagrant provision --provision-with=site-example
site-example is the same as the site key in
wp db export
Will output something like
Succes: Exported to 'dbname-2018-09-16-2790c11.sql'
Often you need the filename.
--porcelain flag to the rescue!
wp db export --porcelain
This will work on a lot of commands that have one item output.
wp post create ....
Here is a complete list of commands that have the –porcelain flag
Commands that output more items usually have a
--format flag to handle output.
In the past I’ve did a post about checking if a bash argument is set.
This is different, This way you can pass through a named variable.
TEST='pass it on' ./testscript.sh
If you do this
$TEST will be set inside the
./testscript.sh bash script.
Like the normal arguments you probably would like to validate them inside the bash script.
The main plus side is that you can put arguments in any order and exclude arguments.
It might also be easier to read as you can see the arguments name.
A bit more advanced. You can override global variables for that script run.
$PATH, be careful.
if [ ! -z $TEST ]; then
echo "var is set to '$TEST'";
echo "var is unset";
A new laptop a new change to optimize stuff. And this is one I should have done years ago.
There are files you always want to avoid. The infamous
.DS_Store file comes to mind.
On ubuntu just add whatever you want to exclude to
Sometimes you just want to copy files from a remote server, and you want it often and quick. Stuff like a DB dump.
You could startup your (s)ftp client and browse to it. Or you could just grap it with ssh.
Download one file
scp -firstname.lastname@example.org:/full/path/to/dump.xml /local/path/to/Downloads
Download a whole folder
scp -r email@example.com:/full/path/to/folder /local/path/to/Downloads
I wanted to include one directory form an svn repo.
With help of stackoverflow I found the solution.
There is a downside, it won’t update. Unless you up the version inside the repositories block.
I like doing a lot in one command. Downside it that stuff can get messy. One big line. you can’t easily edit it.
A shortcut to make it easier is
ctrl-x e That will open the current command in an editor.
Few thinks to keep in mind.
- Multiple lines will work, but it will execute it as separate commands.
&& at the end of lines will fix that.
- Which of course means you get it in the history at full.
My main use to chain commands.
The site had 20K plus posts/pages/ect, freshly put live.
The hoster called. It had slow queries, 9 seconds on average. A lot, multiple per minute. The same query over and over again.
It was a pretty normal post table query. It had one part extra.
A meta query was to exclude all
spot_closed posts. When I removed that it was quick. It didn’t show anything special.
The meta query was added as such:
$meta_query_spots = [
'relation' => 'OR',
'key' => 'spot_closed',
'value' => 1,
'compare' => '!=',
'key' => 'spot_closed',
'compare' => 'NOT EXISTS',
Check if the spot is closed, and if it a spot does not have a close status.
The fix, flip the checks. And bam query less then half a second.
wp-cli can be used to execute a php file with the eval-file command.
Biggest plus; WordPress is loaded when you execute that file.
The point it will call this file is after the init action and after the later wp_loaded action.