[PATCH 2 of 5] bash_completion: better handling of aliases

Alexis S. L. Carvalho alexis at cecm.usp.br
Sun Aug 28 20:43:14 CDT 2005


# HG changeset patch
# User Alexis S. L. Carvalho <alexis at cecm.usp.br>
# Node ID 93b323240bafe204769a7ae6f8b02ca86fd06009
# Parent  383b1cafbc1dfeea248bbd095a283c39329b6858
bash_completion: better handling of aliases

Instead of listing every alias in the big case..esac, use hg help
to get the canonical name of the command.

diff -r 383b1cafbc1d -r 93b323240baf contrib/bash_completion
--- a/contrib/bash_completion	Mon Aug 29 01:12:05 2005
+++ b/contrib/bash_completion	Mon Aug 29 01:12:06 2005
@@ -90,6 +90,9 @@
 	return
     fi
 
+    # canonicalize command name
+    cmd=$(hg -q help "$cmd" | sed -e 's/^hg //; s/ .*//; 1q')
+
     if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" = --rev ]; then
 	_hg_tags
 	return
@@ -99,10 +102,10 @@
 	help)
 	    _hg_commands
 	;;
-	export|manifest|update|checkout|up|co)
+	export|manifest|update)
 	    _hg_tags
 	;;
-	pull|push|outgoing|incoming|out|in)
+	pull|push|outgoing|incoming)
 	    _hg_paths
 	    COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- "$cur" ))
 	;;
@@ -112,7 +115,7 @@
 	add)
 	    _hg_status "u"
 	;;
-	commit|ci)
+	commit)
 	    _hg_status "mra"
 	;;
 	remove)


More information about the Mercurial mailing list