using variables on the command line

Following on from my last example of copying a SSH public key to a remote computer, this is something I need to do when setting up a new computer. Setting up private/public keys for SSH just make logging in that little bit smoother.

When you need to rerun the command, you need to load it up, edit it and resubmit it. Unfortunately (although it’s probably possible) I don’t know an easy way to bring up a previous command and edit it in-line so that I can send it again without actually sending the command again before doing so.

Instead, Load a variable into the command line and change it next time.

-- 11:03:01 -- MBP:~ madivad$ ssh minixbmc
Last login: Mon Apr 25 18:23:18 2016
minixbmc:~ madivad$ exit
Connection to minixbmc closed.
-- 11:03:17 -- MBP:~ madivad$ remote=minixbmc
-- 11:03:26 -- MBP:~ madivad$  history | grep remote
  439  remote=he1000
  440  cat ~/.ssh/ | ssh madivad@$remote "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
  502  remote=minixbmc
-- 11:03:34 -- MBP:~ madivad$ !440
cat ~/.ssh/ | ssh madivad@$remote "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
-- 11:03:40 -- MBP:~ madivad$ ssh minixbmc
Last login: Tue Apr 26 11:03:12 2016 from
minixbmc:~ madivad$

For example, in the above session, for simple commands, I would being the history file up, reissue line 440, then edit, then issue it again. In this situation, it would have the effect of loading the key again, and that’s not what I want to do.

  • Breaking it down, I logged into the remote machine and realised a password was needed,
  • I logged out,
  • I set the “remote” variable,
  • looked for the relevant history command (I knew it had the word “remote” on it),
  • I re-issued that line, and
  • then tested the login.
  • No password was needed, the command was a success.

This could be done with other things as well where you’re always changing one element on the line (or multiple elements, and use multiple variables).

For a more simple and silly example, let’s create a quick update and install script for ubuntu:

upstall=’htop multiwatch’
sudo apt update && sudo apt install $upstall

Instead of typing the whole line next time, I can just type the new apps to install in the “upstall” variable and reissue the command (in this case, using arrow up a couple of times, or grabbing the index from the history file).

$ sudo apt update && sudo apt install $upstall
[sudo] password for madivad:
Hit:1 xenial InRelease
Get:2 xenial-updates InRelease [92.2 kB]
Hit:3 xenial-backports InRelease
Get:4 xenial-security InRelease [92.2 kB]
Fetched 184 kB in 1s (101 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
byobu is already the newest version (5.106-0ubuntu1).
htop is already the newest version (2.0.1-1).
multiwatch is already the newest version (1.0.0-rc1+really1.0.0-1).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.

If I then later want do another update and install something else, I can re-set the “upstall” variable and arrow up or grab it out of history.

11:53:44 madivad@he1000:~$ upstall=jq
12:03:44 madivad@he1000:~$ sudo apt update && sudo apt install $upstall
Hit:1 xenial InRelease
Get:2 xenial-updates InRelease [92.2 kB]
Hit:3 xenial-backports InRelease
Get:4 xenial-security InRelease [92.2 kB]
Fetched 184 kB in 2s (91.0 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree
Reading state information... Done
jq is already the newest version (1.5+dfsg-1).
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
I'm a simple man, I like simplicity. And although there are probably better ways to do this, for the time being, this is how I'm getting the job done. It works well for me, but I'm open to any suggestions and/or improvements.

As I said, not the best example, but hopefully you get the idea.

sudo please

I stumbled across this alias quite a few months ago, but it was under a different name then.

I wanted to find it today and Google searches brought up a whole heap of malicious finds on it, aimed at targeting the unsuspecting newbie to linux. Obviously there are some very dangerous linux commands and so I’m not going to repost them here. Or maybe.

In linux, when you need special permissions to run a command, you’ll get a “permission denied” error. The standard response to that is to “sudo !!” (pron: sudo bang bang) which runs the last command again. Everyone who’s ever used linux will know this can get frustrating.

The I found “fuckit” (or it could have been just “fuck”, I can’t remember which).

When you forget to type sudo, and you’re prompted your permission has been denied, you can issue the expletive whereby the command runs as expected. The funny thing about this, is that when this does happen, it is the sort of thing you are probably thinking, and the expletive does it’s job.

In looking for it today, I found that someone else uses the “please” alias instead. There’s no difference, they both do the same job. It’s just how you feel you want to talk (type) to your computer at the time.

To achieve this, you need to create an alias:

alias please='sudo $(fc -ln -1)'
alias fuck=please

Only include the second line if you feel so inclined. I did because initially you can be all like “please?? Oh thank you understanding computer.” but after a day of permission denied errors, you might be more inclined to just yell at the screen, in which case, the second line is more appropriate.

Creating the alias alone won’t make it persistent. To do that, add the alias to the end of your ~/.bashrc file, or in my case, I’m running ubuntu and you can add it to ~/.bash_aliases instead.

Youtube embedded videos in WordPress not working

You’ll notice above that there is a youtube URL on the first line… it hasn’t embedded within the post.

UPDATE 2015-12-10: it’s working now, is it a WordPress 4.4 thing? I have disabled a LOT of plugins for the moment, I’ll come back and revisit this in the next couple of days. I have spent many hours working on this problem over the last few months and having just found I’ve had other issues, I’ll revisit this again

Embed the URL without embed tags
Embed the URL without embed tags

Also, I have just learned today that the youtube style of embedding without embed tags have been extended in WordPress 4.4 to include URLs to your own WordPress site (and possibly others).

Are you finding your{videocode} youtube links not embedding correctly or working in WordPress?

The correct format for the link is any one of the following:{videocode}{videocode}
[ embed]{videocode}[/embed ]

(there is a space before the embed in the above one to have it display correctly)

There are three things to watch out for to ensure this works. And if you do each of these, then you don’t need to use the [ embed ] code you see in the third example above. They are:

  1. Ensure the URL is on it’s own line
  2. Ensure you use HTTP in lieu of HTTPS (*1)
  3. Ensure the link does NOT appear on the first DISPLAYED line of the content

*1 : this is not a big one, since it seems most of the time it works, but for some reason it didn’t when I used it on this particular occasion.

I say DISPLAYED because in an effort to fix this, I tried putting a blank line for the first line. The problem persisted. It also didn’t help to include just a full-stop (period) there either.

I do believe it could also be theme related as this theme does not use the different post type options that is present in the newer themes. And from what I did find elsewhere, selecting different options in that meta-box can alter this behaviour. I will probably be changing themes in the coming months as I work further on my own custom theme, but for the time being if I want it to appear on the first line, I will use the appropriate [ embed ] code above (with the space removed!). This was not a problem I found documented anywhere else, so hopefully you have found this useful!

WordPress media library limited to 10MB

Screenshot 2015-09-14 11.23.102
I think I’m a little over my quota!

Have you ever noticed this in your blog? It’s never been there before, but it appeared in the last day or two. At the time I wasn’t sure how or why. It’s my blog hosted on one of my web hosting accounts, and I have no shortage of space. So why was I getting this warning?

Screenshot 2015-09-14 11.35.24Worse yet, I went to add a photo, and this happened. That’s when I realised the quota was real!

My first question is, what dickhead gave me such a quota!

My first action was to work out where it was imposed.

Then I found who the right royal dick was. It was yours truly!

I’ve been doing too much playing in the back end and I at some point, and for some unknown reason, have turned it on.

I’m running WordPress Multisite and it’s a setting hidden in the Network Settings.

To navigate to it, click on My Sites in the top left corner, and select Network Admin. Then from the next menu select Settings.

secret hiding place for the 10MB upload quota
this little setting on the right… Make sure you turn it off! :)

And that’s it! Once, you clear that little baby, you’ll be able to upload to your little hearts content.

UPDATE: It looks like I wasn’t the only one who’s ever done this! 

WordPress MultiSite & sunrise.php

Are you getting the above error message as well?

After doing a fresh install and enabling multi-sites I couldn’t see the Domain Mapping and Domains sub-menu options under Network Admin / Settings.

I loaded up my trusty editor and confirmed

define('SUNRISE', 'on' );

was in fact in the file. It was slightly higher than where it said, it’s not important, but I moved it anyway, and I still got the error.

I checked and sunrise.php was in fact in the correct location under /home/public_html/wp-content/sunrise.php

So how did I fix it?

The problem was, it was the incorrect (read:old??) sunrise.php file!

Copy the correct one from:


and replace the previous one, and reload your admin page. You will now see the welcoming domains page :D

If you want to find out more as to why it happened, and how it is that my sunrise.php got “moved” or “re-moved”, it was due to a conflict by domain mapping plugins. I’ll be blogged about it in the near future and it will appear here (currently in draft and not published).

Chrome 45 attacks WordPress admin menu

wordpress-chrome-broken-mergedChrome has taken a turn towards the dark side and has attacked the WordPress admin menu. Luckily there’s a simple workaround and a bug report has been filed which will hopefully lead to a fix soon!

The bug is specifically Chrome related (you can read more here) and they are currently working on a fix that should see it’s way into version 46 stable.

There are several fixes for this bug, rated in (my) order of best solutions:

  1. visit: chrome://flags/#disable-slimming-paint (<< unclickable, you’ll have to enter it yourself :) ) in your browser and select ENABLE (from comment #42). The quickest and easiest solution.
    Screenshot 2015-09-10 08.09.28
  2. Add the following action to the WordPress’ functions.php file (from comment #37):
    function admin_menu_fix() {
      echo '<style>
        #adminmenu { transform: translateZ(0); }
    add_action('admin_head', 'admin_menu_fix');
  3. Collapse and re-Expand the Admin menu is a temporary fix, as is refreshing the screen, but that’s a PITA.
  4. There is also a chrome extension that also deals with this issue: more can be found out here
  5. There is also WordPress plugin, and it will ALSO do the trick. I don’t mean to detract from the developer, but I am very anti installing unnecessary plugins if you really don’t need to. But the fact I haven’t provided you a link only means you’ll spend longer looking for it than you would have spent if you just go and change the option in Chrome settings.
  6. Wait for a fix, which SHOULD be in appearing in an update near you soon :)

#3, and #6 really aren’t options. #4 and #5 are workarounds that will only help users who experience the problem with WordPress and no other sites that are also affected (although this does appear to be somewhat limited), leaving #2 (which is also only a WordPress fix) and is way too much overkill.

And the winner is?

The best solution is #1 and this will take you all of about 5 seconds. It is the BEST solution because this fixes other areas the bug affects (which for me) is my gMail menu where things haven’t been right for a while but a refresh fixed it. In fact, refreshing the page in WordPress also fixes it, as does collapsing and expanding the admin menu.

Anyway, you AND I have spent far too long on this post! So go ahead, open the above in your browser and fix the menu :)


Bluetooth connecting to Phone Audio only, not Media Audio

beats-studio-wireless-headphones-xlHas this ever happened to you??

It was annoying me today. I was going for a long walk and I wanted to enjoy my favourite game (Ingress—come join the resistance!), but the audio wouldn’t come to my headphones. I had to sit down and work this out.

I’d realised recently that my car was only playing Phone Audio through the bluetooth which left the phone’s media on the phone. I remember thinking at the time, “I don’t remember doing that”, but since it suited me (I don’t play phone media through my car stereo), I didn’t pursue it. In fact, I’d seen the setting before and just assumed that at one time, I must have actually changed it.

But when I check the Beats headset, it was also set to Phone Audio only.

No problem, I tapped the Media Audio checkbox and waited… and waited… and it times out, unchecking the box.

Strange, I “forgot” the headset and repaired the two.

Still no media audio.

I then turned off the headphones and turned them back on, reconnected them and STILL no media audio.

I had initially thought it was a problem with the headset, so I’m googling Beats Wireless problems, then I thought about the phone, Samsung S5, but I was drawing a blank. Then just googling bluetooth problems generally with phone and media audio I find that I am certainly not alone!


Fix: Reboot the phone! 

Sure enough, I reboot the phone, reconnect the headphones and Media Audio has returned.

I then went about fixing the amount of green that had begun to pollute my area. :D

How to STOP the Incessantly Annoying Picasa Web Album Notifications!

GalleryIf you’ve wound up here, then I gather you too can’t stand the annoying Picasa Web Albums notifications on your Android device.

I thought I’d tried EVERYTHING but inevitably they return, and I have several Google accounts and as such, I get one notification for each of them. I have long since turned off all syncing options for photos, and numerous done a FORCE STOPs, yet these notifications persist, time after time after time.

If you’re anything like me, you’ve searched high and low on the Interwebs and tried everything you’ve ever read in every forum post, blog and comments… But theykeep coming back :(

Short of rooting your device and removing the Gallery app, or in some other way mod them from not appearing, here’s how I got rid of them. Continue reading “How to STOP the Incessantly Annoying Picasa Web Album Notifications!”

Change iTunes Language and Store Location

I had the need to setup my sister-in-law’s phone today from an iPhone 4 to an iPhone 6. In the process we needed to change her iTunes AppStore language from her default to English, and also change her store location. Even though her language settings had already been changed to English in the usual settings location, iTunes still had her in a foreign store with her home language.
Continue reading “Change iTunes Language and Store Location”


I can’t sum it up any better than the author already has:

I wrote a little tool for OS X to alleviate a constant pain point for me, the lack of click through on multi-monitor setups. You know how when you have an application in the background on OS X, you have to click the application once (to give focus), then click again to do something? This annoys me to no end on my multi-monitor setup, because I can see the thing I want to click on, but I have to click it twice to make it register.

XClickThrough solves this problem by capturing your click, figuring out what you were clicking on, setting that application front most, then clicking on the target element for you.

Just a couple of points to note:

  1. depending on your security settings, if the application doesn’t load up because it comes from an untrusted source, simply bring up the context menu (right click or two-finger click) and hold down Option as you click the menu option: Open, and
  2. as mentioned on the author’s page, on Mavericks, you’ll have to enable the app in Accessibility Security & Privacy Settings.