You need OS X Yosemite 10.10.3 or above to do this.
You probably know that when you plug one of the new 12inch MacBooks into a power source it’ll make a chime noise (the same as iPhones and iPads). But did you know you can make your MacBook Pro or MacBook Air do the same thing? All you need is OS X Yosemite 10.10.3 or later and you can enable this cool little trick with 1 quick line in Terminal. It’s also extremely easy to turn it back off again if it gets on your nerves.
All you need to do is run the following command to turn the chime on:
defaults write com.apple.PowerChime ChimeOnAllHardware -bool true; open /System/Library/CoreServices/PowerChime.app &
…and this command to turn it back off again (notice how it’s almost the same command as above but the boolean is set to ‘false;’ instead of ‘true;’ and instead of opening the PowerChime app, it kills the process):
defaults write com.apple.PowerChime ChimeOnAllHardware -bool false; killall PowerChime