23
23
set __git_tcsh_completion_original_script = ${HOME} /.git-completion.bash
24
24
set __git_tcsh_completion_script = ${HOME} /.git-completion.tcsh.bash
25
25
26
+ # Check that the user put the script in the right place
27
+ if ( ! -e ${__git_tcsh_completion_original_script} ) then
28
+ echo " git-completion.tcsh: Cannot find: ${__git_tcsh_completion_original_script} . Git completion will not work."
29
+ exit
30
+ endif
31
+
26
32
cat << EOF > ${__git_tcsh_completion_script}
27
33
#!bash
28
34
#
@@ -34,13 +40,13 @@ cat << EOF > ${__git_tcsh_completion_script}
34
40
source ${__git_tcsh_completion_original_script}
35
41
36
42
# Set COMP_WORDS in a way that can be handled by the bash script.
37
- COMP_WORDS=(\$ 1 )
43
+ COMP_WORDS=(\$ 2 )
38
44
39
45
# The cursor is at the end of parameter #1.
40
46
# We must check for a space as the last character which will
41
47
# tell us that the previous word is complete and the cursor
42
48
# is on the next word.
43
- if [ "\$ {1 : -1}" == " " ]; then
49
+ if [ "\$ {2 : -1}" == " " ]; then
44
50
# The last character is a space, so our location is at the end
45
51
# of the command-line array
46
52
COMP_CWORD=\$ {#COMP_WORDS[@]}
51
57
COMP_CWORD=\$ ((\$ {#COMP_WORDS[@]}-1))
52
58
fi
53
59
54
- # Call _git() or _gitk() of the bash script, based on the first
55
- # element of the command-line
56
- _\$ {COMP_WORDS[0]}
60
+ # Call _git() or _gitk() of the bash script, based on the first argument
61
+ _\$ {1}
57
62
58
63
IFS=\$ '\n'
59
64
echo "\$ {COMPREPLY[*]}" | sort | uniq
60
65
EOF
61
66
62
- complete git ' p/*/`bash ${__git_tcsh_completion_script} "${COMMAND_LINE}"`/'
63
- complete gitk ' p/*/`bash ${__git_tcsh_completion_script} "${COMMAND_LINE}"`/'
67
+ complete git ' p/*/`bash ${__git_tcsh_completion_script} git "${COMMAND_LINE}"`/'
68
+ complete gitk ' p/*/`bash ${__git_tcsh_completion_script} gitk "${COMMAND_LINE}"`/'
0 commit comments