This will be useful for the developers who works with multiple maven local repositories.
Requirement: set M2_HOME environment variable, before you start.
Add following bash function to .bashrc in your home directory. Change M2_LOCATION if you need.
Then reload the .bashrc using command,
$ source ~/.bashrc
How to use:
Type changeM2 in the terminal and give the name of the m2 repo (folder) you wish to change.