Skip to contentSkip to conversation

bash completion: Append space after file names have been completed

PATCH New Shawn O. Pearce 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bash completion: Append space after file names have been completed

When completing git show origin/maint:Makef<tab> we should add a space after the filename has been completed, so that the user can immediately begin the next argument.

I also added a special case for the symlink variant so we treat it just like a normal blob, as there are no items below it in the Git tree structure.

---
 contrib/completion/git-completion.bash |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
contrib/completion/git-completion.bash +9 -1
index 9a1c66a..790d1c6 100755
@@ -294,9 +294,17 @@ __git_complete_file ()
 			ls="$ref"
 			;;
 	    esac
+		local IFS=$'\n'
 		COMPREPLY=($(compgen -P "$pfx" \
 			-W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
-				| sed '/^100... blob /s,^.*	,,
+				| sed '/^100... blob /{
+				           s,^.*	,,
+				           s,$, ,
+				       }
+				       /^120000 blob /{
+				           s,^.*	,,
+				           s,$, ,
+				       }
 				       /^040000 tree /{
 				           s,^.*	,,
 				           s,$,/,
Signature · 1 line
1.5.6.2.393.g45096