Azure CLI 2, Bru!

The highly anticipated release of Azure CLI 2.0
I use a MacBook Pro as my primary workstation and so I rushed to install the CLI to check out the new options and pretty much used the default install options. (never a good idea, should have listened to my brain)

It left all sorts of junk in my home folder and with my OCD, I got rather upset at what my home directory looked like. The install also wanted to write a bunch of things into my bash profile which wrote to a file I do not normally use for terminal. (I use a .bashrc file)

So, I removed it and made it prettier and more logical for me to use on a daily basis. I thought I would share 🙂

First off, I use an amazing ports collection/installer called MacPorts. It makes awesome linux commands like “nmap”, “tcptraceroute” “wget” etc… available to the MacOS shell.

Head over to and get a copy and install it. It is a pre-req for this post.

Once you have installed MacPorts. You will notice that it creates some folders for us to use and place binaries we are going to run.


Now if you go into /opt/local/bin, that is where it stores our binaries will sit and hence be in our environment paths and be available with bash autocomplete. For example

wdt@Warrens-MacBook-Pro ~ $ which nmap
wdt@Warrens-MacBook-Pro ~ $ nmap
Nmap 7.40 ( )
Usage: nmap [Scan Type(s)] [Options] {target specification}

When installing the Azure CLI, use these locations as the locations for the installations.

wdt@Warrens-MacBook-Pro ~ $ which az
wdt@Warrens-MacBook-Pro ~ $

Then once the install is complete. Tell it not to write the auto complete into your bash profile and just add the following line to bashrc,

source ‘/opt/local/lib/azure-cli/az.completion’

It then allows auto complete for all the azure commands.

wdt@Warrens-MacBook-Pro ~ $ az
–debug –query -o ad cloud container feature group keyvault logout provider role storage vmss
–help –verbose account appservice component disk feedback image lock network redis snapshot tag
–output -h acs batch configure documentdb find iot login policy resource sql vm

Nice and clean and neat 🙂

Leave a Reply