Skip to content

Commit c389811

Browse files
szedergitster
authored andcommitted
bash: support pretty format aliases
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2a5da75 commit c389811

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

contrib/completion/git-completion.bash

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,19 @@ __git_compute_porcelain_commands ()
750750
: ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
751751
}
752752

753+
__git_pretty_aliases ()
754+
{
755+
local i IFS=$'\n'
756+
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
757+
case "$i" in
758+
pretty.*)
759+
i="${i#pretty.}"
760+
echo "${i/ */}"
761+
;;
762+
esac
763+
done
764+
}
765+
753766
__git_aliases ()
754767
{
755768
local i IFS=$'\n'
@@ -1372,12 +1385,12 @@ _git_log ()
13721385
fi
13731386
case "$cur" in
13741387
--pretty=*)
1375-
__gitcomp "$__git_log_pretty_formats
1388+
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
13761389
" "" "${cur##--pretty=}"
13771390
return
13781391
;;
13791392
--format=*)
1380-
__gitcomp "$__git_log_pretty_formats
1393+
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
13811394
" "" "${cur##--format=}"
13821395
return
13831396
;;
@@ -2136,12 +2149,12 @@ _git_show ()
21362149
local cur="${COMP_WORDS[COMP_CWORD]}"
21372150
case "$cur" in
21382151
--pretty=*)
2139-
__gitcomp "$__git_log_pretty_formats
2152+
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
21402153
" "" "${cur##--pretty=}"
21412154
return
21422155
;;
21432156
--format=*)
2144-
__gitcomp "$__git_log_pretty_formats
2157+
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
21452158
" "" "${cur##--format=}"
21462159
return
21472160
;;

0 commit comments

Comments
 (0)