bash: Add space after unique command name is completed.
Because we use the nospace option for our completion function for the main 'git' wrapper bash won't automatically add a space after a unique completion has been made by the user. This has been pointed out in the past by Linus Torvalds as an undesired behavior. I agree. We have to use the nospace option to ensure path completion for a command such as `git show` works properly, but that breaks the common case of getting the space for a unique completion. So now we set IFS=$'\n' (linefeed) and add a trailing space to every possible completion option. This causes bash to insert the space when the completion is unique. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
8435b54848
commit
72e5e989b8
@ -61,6 +61,20 @@ __git_ps1 ()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__gitcomp ()
|
||||||
|
{
|
||||||
|
local all c s=$'\n' IFS=' '$'\t'$'\n'
|
||||||
|
for c in $1; do
|
||||||
|
case "$c" in
|
||||||
|
--*=*) all="$all$c$s" ;;
|
||||||
|
*) all="$all$c $s" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
IFS=$s
|
||||||
|
COMPREPLY=($(compgen -W "$all" -- "${COMP_WORDS[COMP_CWORD]}"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
__git_heads ()
|
__git_heads ()
|
||||||
{
|
{
|
||||||
local cmd i is_hash=y dir="$(__gitdir "$1")"
|
local cmd i is_hash=y dir="$(__gitdir "$1")"
|
||||||
@ -787,12 +801,12 @@ _git ()
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
|
if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
|
||||||
COMPREPLY=($(compgen -W "
|
case "${COMP_WORDS[COMP_CWORD]}" in
|
||||||
--git-dir= --version --exec-path
|
--*=*) COMPREPLY=() ;;
|
||||||
$(__git_commands)
|
--*) __gitcomp "--git-dir= --bare --version --exec-path" ;;
|
||||||
$(__git_aliases)
|
*) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
|
||||||
" -- "${COMP_WORDS[COMP_CWORD]}"))
|
esac
|
||||||
return;
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local expansion=$(__git_aliased_command "$command")
|
local expansion=$(__git_aliased_command "$command")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user