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

[PATCH v2] bash: support pretty format aliases

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Oct 10, 2010, 22:06 UTC
Message-ID
<20101010220622.GC12529@neumann>
In-Reply-To
<20101010214410.GA16253@burratino>

Users can have their own pretty format aliases since 8028184 (pretty: add aliases for pretty formats, 2010-05-02), so let's offer those after '--pretty=' and '--format=' for 'log' and 'show', too.

Similar to the completion of aliases, this will invoke 'git config' each time pretty aliases needs to be completed, so changes in pretty.* configuration will be reflected immediately.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
On Sun, Oct 10, 2010 at 04:44:11PM -0500, Jonathan Nieder wrote:
Show 7 quoted lines
> Does this apply to
> 
> 	git log --format=
> 	git show --pretty=
> 	git show --format=
> 
> too?
Yes ;)
 contrib/completion/git-completion.bash |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 6756990..4d54c32 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -750,6 +750,19 @@ __git_compute_porcelain_commands ()
 	: ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
 }
 
+__git_pretty_aliases ()
+{
+	local i IFS=$'\n'
+	for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
+		case "$i" in
+		pretty.*)
+			i="${i#pretty.}"
+			echo "${i/ */}"
+			;;
+		esac
+	done
+}
+
 __git_aliases ()
 {
 	local i IFS=$'\n'
@@ -1368,12 +1381,12 @@ _git_log ()
 	fi
 	case "$cur" in
 	--pretty=*)
-		__gitcomp "$__git_log_pretty_formats
+		__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
 			" "" "${cur##--pretty=}"
 		return
 		;;
 	--format=*)
-		__gitcomp "$__git_log_pretty_formats
+		__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
 			" "" "${cur##--format=}"
 		return
 		;;
@@ -2100,12 +2113,12 @@ _git_show ()
 	local cur="${COMP_WORDS[COMP_CWORD]}"
 	case "$cur" in
 	--pretty=*)
-		__gitcomp "$__git_log_pretty_formats
+		__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
 			" "" "${cur##--pretty=}"
 		return
 		;;
 	--format=*)
-		__gitcomp "$__git_log_pretty_formats
+		__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
 			" "" "${cur##--format=}"
 		return
 		;;
-- 
1.7.3.1.148.g2fffa
Previous: Jonathan NiederNext: SZEDER Gábor
Message 3 of 8 in “bash: support pretty format aliases”
  1. bash: support pretty format aliasesSZEDER Gábor, Oct 10, 2010
  2. Jonathan NiederOct 10, 2010
  3. bash: support pretty format aliasesSZEDER Gábor, Oct 10, 2010
  4. SZEDER GáborOct 14, 2010
  5. 1/2 bash: add helper function to get config variables for completionSZEDER Gábor, Oct 14, 2010
  6. Jonathan NiederOct 14, 2010
  7. SZEDER GáborOct 20, 2010
  8. 2/2 bash: support pretty format aliasesSZEDER Gábor, Oct 14, 2010

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.