Skip to content

Commit 05ea76e

Browse files
committed
Merge branch 'mk/complete-tcsh'
Finishing touches for tcsh completion. * mk/complete-tcsh: Support for git aliasing for tcsh completion
2 parents 7472ad1 + ce45ea6 commit 05ea76e

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

contrib/completion/git-completion.tcsh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
set __git_tcsh_completion_original_script = ${HOME}/.git-completion.bash
2424
set __git_tcsh_completion_script = ${HOME}/.git-completion.tcsh.bash
2525

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+
2632
cat << EOF > ${__git_tcsh_completion_script}
2733
#!bash
2834
#
@@ -34,13 +40,13 @@ cat << EOF > ${__git_tcsh_completion_script}
3440
source ${__git_tcsh_completion_original_script}
3541
3642
# Set COMP_WORDS in a way that can be handled by the bash script.
37-
COMP_WORDS=(\$1)
43+
COMP_WORDS=(\$2)
3844
3945
# The cursor is at the end of parameter #1.
4046
# We must check for a space as the last character which will
4147
# tell us that the previous word is complete and the cursor
4248
# is on the next word.
43-
if [ "\${1: -1}" == " " ]; then
49+
if [ "\${2: -1}" == " " ]; then
4450
# The last character is a space, so our location is at the end
4551
# of the command-line array
4652
COMP_CWORD=\${#COMP_WORDS[@]}
@@ -51,13 +57,12 @@ else
5157
COMP_CWORD=\$((\${#COMP_WORDS[@]}-1))
5258
fi
5359
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}
5762
5863
IFS=\$'\n'
5964
echo "\${COMPREPLY[*]}" | sort | uniq
6065
EOF
6166

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

Comments
 (0)