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

[PATCH] bash completion: add git-difftool

From
David Aguilar <davvid@gmail.com>
Date
Apr 2, 2009, 11:30 UTC
Message-ID
<1238671857-8811-1-git-send-email-davvid@gmail.com>

This adds completion for difftool's --tool flag. The known diff tool names were also consolidated into a single variable.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
 contrib/completion/git-completion.bash |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 4fcd77a..33a8ec7 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -909,6 +909,26 @@ _git_diff ()
 	__git_complete_file
 }
 
+__git_mergetools_common="diffuse ecmerge emerge kdiff3 meld opendiff
+			tkdiff vimdiff gvimdiff xxdiff
+"
+
+_git_difftool ()
+{
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	case "$cur" in
+	--tool=*)
+		__gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
+		return
+		;;
+	--*)
+		__gitcomp "--tool="
+		return
+		;;
+	esac
+	COMPREPLY=()
+}
+
 __git_fetch_options="
 	--quiet --verbose --append --upload-pack --force --keep --depth=
 	--tags --no-tags
@@ -1171,11 +1191,7 @@ _git_mergetool ()
 	local cur="${COMP_WORDS[COMP_CWORD]}"
 	case "$cur" in
 	--tool=*)
-		__gitcomp "
-			kdiff3 tkdiff meld xxdiff emerge
-			vimdiff gvimdiff ecmerge diffuse
-			opendiff
-			" "" "${cur##--tool=}"
+		__gitcomp "$__git_mergetools_common" "" "${cur##--tool=}"
 		return
 		;;
 	--*)
@@ -1900,6 +1916,7 @@ _git ()
 	config)      _git_config ;;
 	describe)    _git_describe ;;
 	diff)        _git_diff ;;
+	difftool)    _git_difftool;;
 	fetch)       _git_fetch ;;
 	format-patch) _git_format_patch ;;
 	fsck)        _git_fsck ;;
-- 
1.6.2.1.469.gdffc1
Next: Shawn O. Pearce
Message 1 of 2 in “bash completion: add git-difftool”
  1. bash completion: add git-difftoolDavid Aguilar, Apr 2, 2009
  2. Shawn O. PearceApr 5, 2009

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.