* [PATCH] Support for git aliasing for tcsh completion
[not found] <1353989472-4142-1-git-send-email-marc.khouzam@gmail.com>
@ 2012-11-27 4:13 ` Marc Khouzam
2012-11-27 17:16 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Marc Khouzam @ 2012-11-27 4:13 UTC (permalink / raw)
To: git, Felipe Contreras, SZEDER Gábor; +Cc: Tuncer Ayaz
tcsh users sometimes alias the 'git' command to another name. In
this case, the user expects to only have to issue a new 'complete'
command using the alias name.
However, the tcsh script currently uses the command typed by the
user to call the appropriate function in git-completion.bash, either
_git() or _gitk(). When using an alias, this technique no longer
works.
This change specifies the real name of the command (either 'git' or
'gitk') as a parameter to the script handling tcsh completion. This
allows the user to use any alias for the 'git' or 'gitk' commands,
while still getting completion to work.
A check for the presence of ${HOME}/.git-completion.bash is also
added to help the user make use of the script properly.
Signed-off-by: Marc Khouzam <marc.khouzam@gmail.com>
---
This issue was reported by someone already making use of the tcsh
completion script.
Thanks for considering this fix.
Marc
contrib/completion/git-completion.tcsh | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/contrib/completion/git-completion.tcsh
b/contrib/completion/git-completion.tcsh
index dc5678c..44bd544 100644
--- a/contrib/completion/git-completion.tcsh
+++ b/contrib/completion/git-completion.tcsh
@@ -23,6 +23,12 @@
set __git_tcsh_completion_original_script = ${HOME}/.git-completion.bash
set __git_tcsh_completion_script = ${HOME}/.git-completion.tcsh.bash
+# Check that the user put the script in the right place
+if ( ! -e ${__git_tcsh_completion_original_script} ) then
+ echo "git-completion.tcsh: Cannot find:
${__git_tcsh_completion_original_script}. Git completion will not work."
+ exit
+endif
+
cat << EOF > ${__git_tcsh_completion_script}
#!bash
#
@@ -34,13 +40,13 @@ cat << EOF > ${__git_tcsh_completion_script}
source ${__git_tcsh_completion_original_script}
# Set COMP_WORDS in a way that can be handled by the bash script.
-COMP_WORDS=(\$1)
+COMP_WORDS=(\$2)
# The cursor is at the end of parameter #1.
# We must check for a space as the last character which will
# tell us that the previous word is complete and the cursor
# is on the next word.
-if [ "\${1: -1}" == " " ]; then
+if [ "\${2: -1}" == " " ]; then
# The last character is a space, so our location is at the end
# of the command-line array
COMP_CWORD=\${#COMP_WORDS[@]}
@@ -51,13 +57,12 @@ else
COMP_CWORD=\$((\${#COMP_WORDS[@]}-1))
fi
-# Call _git() or _gitk() of the bash script, based on the first
-# element of the command-line
-_\${COMP_WORDS[0]}
+# Call _git() or _gitk() of the bash script, based on the first argument
+_\${1}
IFS=\$'\n'
echo "\${COMPREPLY[*]}" | sort | uniq
EOF
-complete git 'p/*/`bash ${__git_tcsh_completion_script}
"${COMMAND_LINE}"`/'
-complete gitk 'p/*/`bash ${__git_tcsh_completion_script}
"${COMMAND_LINE}"`/'
+complete git 'p/*/`bash ${__git_tcsh_completion_script} git
"${COMMAND_LINE}"`/'
+complete gitk 'p/*/`bash ${__git_tcsh_completion_script} gitk
"${COMMAND_LINE}"`/'
--
1.8.0.1.g9fe2839
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Support for git aliasing for tcsh completion
2012-11-27 4:13 ` [PATCH] Support for git aliasing for tcsh completion Marc Khouzam
@ 2012-11-27 17:16 ` Junio C Hamano
2012-11-28 1:39 ` Marc Khouzam
0 siblings, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2012-11-27 17:16 UTC (permalink / raw)
To: Marc Khouzam; +Cc: git, Felipe Contreras, SZEDER Gábor, Tuncer Ayaz
The patch was linewrapped so I had to fix it up; please double check
what will be queued on 'pu' to make sure that I did not miss
necessary whitespaces or added unnecessary ones when I rejoined long
lines.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Support for git aliasing for tcsh completion
2012-11-27 17:16 ` Junio C Hamano
@ 2012-11-28 1:39 ` Marc Khouzam
2012-11-28 1:56 ` Felipe Contreras
0 siblings, 1 reply; 4+ messages in thread
From: Marc Khouzam @ 2012-11-28 1:39 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Felipe Contreras, SZEDER Gábor, Tuncer Ayaz
On Tue, Nov 27, 2012 at 12:16 PM, Junio C Hamano <gitster@pobox.com> wrote:
> The patch was linewrapped so I had to fix it up;
Sorry about that. I don't know if it is gmail, or the fact that I use
its web interface
that causes these problems.
> please double check
> what will be queued on 'pu' to make sure that I did not miss
> necessary whitespaces or added unnecessary ones when I rejoined long
> lines.
I just checked it and it looks great.
I'm working on another improvement to the script but I don't have it working
yet. But I should not bother you much after that.
Thanks again!
Marc
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Support for git aliasing for tcsh completion
2012-11-28 1:39 ` Marc Khouzam
@ 2012-11-28 1:56 ` Felipe Contreras
0 siblings, 0 replies; 4+ messages in thread
From: Felipe Contreras @ 2012-11-28 1:56 UTC (permalink / raw)
To: Marc Khouzam; +Cc: Junio C Hamano, git, SZEDER Gábor, Tuncer Ayaz
On Wed, Nov 28, 2012 at 2:39 AM, Marc Khouzam <marc.khouzam@gmail.com> wrote:
> On Tue, Nov 27, 2012 at 12:16 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> The patch was linewrapped so I had to fix it up;
>
> Sorry about that. I don't know if it is gmail, or the fact that I use
> its web interface
> that causes these problems.
>
>> please double check
>> what will be queued on 'pu' to make sure that I did not miss
>> necessary whitespaces or added unnecessary ones when I rejoined long
>> lines.
>
> I just checked it and it looks great.
>
> I'm working on another improvement to the script but I don't have it working
> yet. But I should not bother you much after that.
You might want to use msmtp to send mails with Gmail, that's what I do:
https://git.wiki.kernel.org/index.php/GitTips#Using_msmtp_to_send_your_patches
--
Felipe Contreras
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-28 1:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1353989472-4142-1-git-send-email-marc.khouzam@gmail.com>
2012-11-27 4:13 ` [PATCH] Support for git aliasing for tcsh completion Marc Khouzam
2012-11-27 17:16 ` Junio C Hamano
2012-11-28 1:39 ` Marc Khouzam
2012-11-28 1:56 ` Felipe Contreras
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).