Thursday, March 13, 2014

Mercurial on OS X, tips

Extremely small post on something useful.

The ns-3 source control management of choice is Mercurial.
Installing Mercurial on OS X is not an issue, just download the package and install it. Simple as that.
Once installed, you can use a terminal to give all the commands you want, or even use a GUI (see Mercurial Mac native GUIs).

What I missed the most, however, is the ability to auto-complete commands from the terminal.
In Linux you can write "hg p" and hit tab. The result is:
tommaso:ns-3-dev pecos$ hg p
parents  patch    paths    phase    pull     push     

or even... "hg push --move" + tab:
tommaso:ns-3-dev pecos$ hg qpush --move 
Ndisc.diff               TagFragmentation.diff    issue6821106_36001.diff

Handy... but it's not working on OS X. However there is a way to enable it. And it's easy too.
  1. Download the mercurial source tarball (http://mercurial.selenic.com/downloads) and choose "Mercurial xxxx source release" where xxxx is the latest version;
  2. Unpack the file, and open the folder. Open the folder named "contrib";
  3. Copy the file named bash_completion somewhere (e.g., $HOME/bin);
  4. Modify the bash profile to source it;
  5. Reopen your terminals and enjoy.
Let's do a practical example. Let's assume the latest Mercurial version is 2.9.1, and let's assume my bash profile is named ~/.profile
The commands to give are:
tommaso:~ pecos$ cd ~
tommaso:~ pecos$ cp Downloads/mercurial-2.9.1/contrib/bash_completion ~/bin
tommaso:~ pecos$ nano ~/.profile
and add the following line to .profile:
source $HOME/bin/bash_completion

Note that in some systems ".profile" could be named ".bash_profile". It's the same stuff.

If you're a terminal guy (like me) you'll really enjoy it.

No comments:

Post a Comment