Skip to content

Instantly share code, notes, and snippets.

@tjluoma
Created December 4, 2014 01:42
Show Gist options
  • Select an option

  • Save tjluoma/2b1f567dab610f8afbbf to your computer and use it in GitHub Desktop.

Select an option

Save tjluoma/2b1f567dab610f8afbbf to your computer and use it in GitHub Desktop.
If you use Back To My Mac on your Mac, then you are assigned a unique domain name such as "987654321.members.btmm.icloud.com." That domain is only usable on other Macs which are connected to the same iCloud account. In order to find your BTMM domain, you can use the following commands:
# On the command line (note the single \ before the $NF)
echo show Setup:/Network/BackToMyMac | scutil | awk -F' ' "/$UID/{print \$NF}"
alias btmm='echo show Setup:/Network/BackToMyMac | scutil | awk -F" " "/$UID/{print \$NF}"'
function btmm { echo show Setup:/Network/BackToMyMac | scutil | awk -F" " "/$UID/{print \$NF}" }
BTMM=$(echo show Setup:/Network/BackToMyMac | scutil | awk -F' ' "/$UID/{print \$NF}")
# However, if you want to assign it to a variable using FOO=`bar` syntax, then you must use two backslashes:
BTMM=`echo show Setup:/Network/BackToMyMac | scutil | awk -F' ' "/$UID/{print \\$NF}"`
@tjluoma
Copy link
Author

tjluoma commented Dec 4, 2014

Previously I had been using this to get my Back To My Mac domain:

echo show Setup:/Network/BackToMyMac | scutil | sed -n 's/.* : *\(.*\).$/\1/p'

however, that does not work if there is more than one user with an iCloud/BackToMyMac account on the same Mac.

(I did not come up with that original command, but unfortunately I cannot find the original source for it anymore.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment