|
13 | 13 | # |
14 | 14 | # To use this completion script: |
15 | 15 | # |
| 16 | +# 0) You need tcsh 6.16.00 or newer. |
16 | 17 | # 1) Copy both this file and the bash completion script to ${HOME}. |
17 | 18 | # You _must_ use the name ${HOME}/.git-completion.bash for the |
18 | 19 | # bash script. |
|
24 | 25 | # set autolist=ambiguous |
25 | 26 | # It will tell tcsh to list the possible completion choices. |
26 | 27 |
|
| 28 | +set __git_tcsh_completion_version = `\echo ${tcsh} | \sed 's/\./ /g'` |
| 29 | +if ( ${__git_tcsh_completion_version[1]} < 6 || \ |
| 30 | + ( ${__git_tcsh_completion_version[1]} == 6 && \ |
| 31 | + ${__git_tcsh_completion_version[2]} < 16 ) ) then |
| 32 | + echo "git-completion.tcsh: Your version of tcsh is too old, you need version 6.16.00 or newer. Git completion will not work." |
| 33 | + exit |
| 34 | +endif |
| 35 | +unset __git_tcsh_completion_version |
| 36 | + |
27 | 37 | set __git_tcsh_completion_original_script = ${HOME}/.git-completion.bash |
28 | 38 | set __git_tcsh_completion_script = ${HOME}/.git-completion.tcsh.bash |
29 | 39 |
|
|
64 | 74 | _\${1} |
65 | 75 |
|
66 | 76 | IFS=\$'\n' |
67 | | -if [ \${#COMPREPLY[*]} -gt 0 ]; then |
68 | | - echo "\${COMPREPLY[*]}" | sort | uniq |
69 | | -else |
| 77 | +if [ \${#COMPREPLY[*]} -eq 0 ]; then |
70 | 78 | # No completions suggested. In this case, we want tcsh to perform |
71 | 79 | # standard file completion. However, there does not seem to be way |
72 | 80 | # to tell tcsh to do that. To help the user, we try to simulate |
|
85 | 93 | # We don't support ~ expansion: too tricky. |
86 | 94 | if [ "\${TO_COMPLETE:0:1}" != "~" ]; then |
87 | 95 | # Use ls so as to add the '/' at the end of directories. |
88 | | - RESULT=(\`ls -dp \${TO_COMPLETE}* 2> /dev/null\`) |
89 | | - echo \${RESULT[*]} |
90 | | -
|
91 | | - # If there is a single completion and it is a directory, |
92 | | - # we output it a second time to trick tcsh into not adding a space |
93 | | - # after it. |
94 | | - if [ \${#RESULT[*]} -eq 1 ] && [ "\${RESULT[0]: -1}" == "/" ]; then |
95 | | - echo \${RESULT[*]} |
96 | | - fi |
| 96 | + COMPREPLY=(\`ls -dp \${TO_COMPLETE}* 2> /dev/null\`) |
97 | 97 | fi |
98 | 98 | fi |
99 | 99 | fi |
100 | 100 |
|
| 101 | +# tcsh does not automatically remove duplicates, so we do it ourselves |
| 102 | +echo "\${COMPREPLY[*]}" | sort | uniq |
| 103 | +
|
| 104 | +# If there is a single completion and it is a directory, we output it |
| 105 | +# a second time to trick tcsh into not adding a space after it. |
| 106 | +if [ \${#COMPREPLY[*]} -eq 1 ] && [ "\${COMPREPLY[0]: -1}" == "/" ]; then |
| 107 | + echo "\${COMPREPLY[*]}" |
| 108 | +fi |
| 109 | +
|
101 | 110 | EOF |
102 | 111 |
|
103 | 112 | # Don't need this variable anymore, so don't pollute the users environment |
|
0 commit comments