git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] bash completion: Append space after file names have been completed

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 14, 2008, 00:22 UTC
Message-ID
<20080714002203.GA13749@spearce.org>

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.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 contrib/completion/git-completion.bash |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9a1c66a..790d1c6 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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,$,/,
-- 
1.5.6.2.393.g45096
Message 1 of 1 in “bash completion: Append space after file names have been completed”
  1. bash completion: Append space after file names have been completedShawn O. Pearce, Jul 14, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.