tcsh completion

TK Soh teekaysoh at yahoo.com
Wed Aug 24 01:42:03 CDT 2005


The following patch adds a shell script to generate the tcsh source file to
support completion of Hg command. I originally wanted to mimic bash_completion,
but couldn't get though tcsh's quoting mess (I finally come to understand why
Tom Christiansen considered C shell program harmful)

# HG changeset patch
# User TK Soh <teekaysoh at yahoo.com>
# Node ID 7b353e1edf10ca88b918fe725d304d83041f618a
# Parent  2e8b8da9a86e6b0268921b147e3d2375b782a8a2
Added shell script for generating tcsh completion source.

Run tcsh_completion.sh to generate tcsh_completion, then
source tcsh_completion in tcsh to add completion support
for hg. The source filename may be optionally specified 
by passing as first argument to tcsh_completion.sh

Note: command specific options are not [yet] supported.

diff -r 2e8b8da9a86e -r 7b353e1edf10 contrib/tcsh_completion.sh
--- /dev/null	Tue Aug 23 23:19:14 2005
+++ b/contrib/tcsh_completion.sh	Wed Aug 24 01:22:18 2005
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+#
+# this script generates a tcsh source file to support 
+# completion of Mercurial commands.
+#
+
+tcsh_file=${1-tcsh_completion}
+
+hg_commands=`hg -v help | \
+        sed -e '1,/^list of commands:/d' \
+            -e '/^global options:/,$d' \
+            -e '/^ [^ ]/!d; s/[,:]//g;' \
+            -e 's/$/ \\\\/g; s/^ \{1,\}/    /g'`
+
+hg_global_options=`hg -v help | \
+        sed -e '1,/^global options/d; /^ -/!d;' \
+            -e 's/$/ \\\\/g; s/^ \{1,\}/    /g'`
+
+hg_version=`hg version | sed -e '1q'`
+
+script_name=`basename $0`
+
+cat > $tcsh_file <<END
+#
+# tcsh's completion for $hg_version 
+#
+# WARNING: This file was generated by $script_name. Do NOT edit!
+#
+
+if (\$?tcsh) then
+  complete hg \\
+  'C/-/( $hg_global_options
+  )/' \\
+  'p/1/( $hg_commands
+  )/'
+endif
+
+END


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Mercurial mailing list