##// END OF EJS Templates
Add contrib script for generating tcsh completion source
TK Soh -
r1155:92697ad2 default
parent child Browse files
Show More
@@ -0,0 +1,74 b''
1 #!/bin/sh
2
3 #
4 # tcsh_completion_build.sh - script to generate tcsh completion
5 #
6 #
7 # Copyright (C) 2005 TK Soh.
8 #
9 # This is free software; you can redistribute it and/or modify it under
10 # the terms of the GNU General Public License as published by the Free
11 # Software Foundation; either version 2 of the License, or (at your
12 # option) any later version.
13 #
14 #
15 # Description
16 # -----------
17 # This script generates a tcsh source file to support completion
18 # of Mercurial commands and options.
19 #
20 # Instruction:
21 # -----------
22 # Run this script to generate the tcsh source file, and source
23 # the file to add command completion support for Mercurial.
24 #
25 # tcsh% tcsh_completion.sh FILE
26 # tcsh% source FILE
27 #
28 # If FILE is not specified, tcsh_completion will be generated.
29 #
30 # Bugs:
31 # ----
32 # 1. command specific options are not supported
33 # 2. hg commands must be specified immediately after 'hg'.
34 #
35
36 tcsh_file=${1-tcsh_completion}
37
38 hg_commands=`hg --debug help | \
39 sed -e '1,/^list of commands:/d' \
40 -e '/^global options:/,$d' \
41 -e '/^ [^ ]/!d; s/[,:]//g;' |
42 xargs -n5 | \
43 sed -e '$!s/$/ \\\\/g; 2,$s/^ \{0,\}/ /g'`
44
45 hg_global_options=`hg -v help | \
46 sed -e '1,/global/d;/^ *-/!d; s/ [^- ].*//' | \
47 xargs -n5 | \
48 sed -e '$!s/$/ \\\\/g; 2,$s/^ \{0,\}/ /g'`
49
50 hg_version=`hg version | sed -e '1q'`
51
52 script_name=`basename $0`
53
54 cat > $tcsh_file <<END
55 #
56 # tcsh completion for Mercurial
57 #
58 # This file has been auto-generated by $script_name for
59 # $hg_version
60 #
61 # Copyright (C) 2005 TK Soh.
62 #
63 # This is free software; you can redistribute it and/or modify it under
64 # the terms of the GNU General Public License as published by the Free
65 # Software Foundation; either version 2 of the License, or (at your
66 # option) any later version.
67 #
68
69 complete hg \\
70 'n/--cwd/d/' 'n/-R/d/' 'n/--repository/d/' \\
71 'C/-/($hg_global_options)/' \\
72 'p/1/($hg_commands)/'
73
74 END
General Comments 0
You need to be logged in to leave comments. Login now