changeset 14275:2a6ee654655e stable

hgrc.5: document shell aliases
author Martin Geisler <mg@aragost.com>
date Mon, 09 May 2011 10:46:54 +0200
parents 89e7d35e0ef0
children 7f16ff9e45b4 3c65cdcf3ba6
files doc/hgrc.5.txt
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hgrc.5.txt	Sun May 01 13:07:00 2011 +0200
+++ b/doc/hgrc.5.txt	Mon May 09 10:46:54 2011 +0200
@@ -200,6 +200,26 @@
    existing commands, which will then override the original
    definitions. This is almost always a bad idea!
 
+An alias can start with an exclamation point (``!``) to make it a
+shell alias. A shell alias is executed with the shell and will let you
+run arbitrary commands. As an example, ::
+
+   echo = !echo
+
+will let you do ``hg echo foo`` to have ``foo`` printed in your
+terminal. A better example might be::
+
+   purge = !$HG status --no-status --unknown -0 | xargs -0 rm
+
+which will make ``hg purge`` delete all unknown files in the
+repository in the same manner as the purge extension.
+
+Shell aliases are executed in an environment where ``$HG`` expand to
+the path of the Mercurial that was used to execute the alias. This is
+useful when you want to call further Mercurial commands in a shell
+alias, as was done above for the purge alias. In addition,
+``$HG_ARGS`` expand to the arguments given to Mercurial. In the ``hg
+echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``.
 
 ``auth``
 """"""""