Thursday, 13 December 2012

Adding Mercurial (hg) completion to OS X

Being new to Mercurial, I really wanted to have bash completion for it. But figuring out the paths is really difficult for OS X with not many people writing about it.

To add hg-completion to your terminal:
  1. Download bash code from http://selenic.com/hg/raw-file/25e4d2f35965/contrib/bash_completion
  2. Save the downloaded file as hg-completion.bash to your /opt/local/etc/profile.d directory
  3. Run the script whenever you open a new terminal by adding following line to your ~/.profile
  4. Open a new Tab and enjoy!
Similar code for hg completion can be found at http://fts.ifac.cnr.it/cgi-bin/dwww/usr/share/doc/bash/completion-contrib/hg, but the things are working quite good for me already. Try it if you'd like.