From 9fb7a26d27a8a82bee445a3915589d0174316f8a Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Fri, 10 Oct 2008 13:43:16 +0200 Subject: [PATCH] Add bash completion for the blame subcommand --- NEWS | 1 + contrib/tig-completion.bash | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 0b891f9..7b9c0fe 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ Improvements: - Display repository references in the sorted order: tags, heads, tracked remotes, remotes. + - Add bash completion for blame. tig-0.12.1 ---------- diff --git a/contrib/tig-completion.bash b/contrib/tig-completion.bash index 79b414b..40bfcfa 100755 --- a/contrib/tig-completion.bash +++ b/contrib/tig-completion.bash @@ -182,6 +182,26 @@ _tig_options () __tig_complete_revlist } +_tig_blame () +{ + local reply="" ref=HEAD cur="${COMP_WORDS[COMP_CWORD]}" + + if test "$COMP_CWORD" -lt 3; then + reply="$(__tig_refs)" + else + ref="${COMP_WORDS[2]}" + fi + + reply="$reply $(git --git-dir="$(__tigdir)" ls-tree "$ref" \ + | sed '/^100... blob /s,^.* ,, + /^040000 tree /{ + s,^.* ,, + s,$,/, + } + s/^.* //')" + _tigcomp "$reply" +} + _tig_show () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -218,12 +238,13 @@ _tig () case "${COMP_WORDS[COMP_CWORD]}" in --*=*) COMPREPLY=() ;; -*) _tig_options ;; - *) _tigcomp "status show $(__tig_refs)" ;; + *) _tigcomp "blame status show $(__tig_refs)" ;; esac return fi case "$command" in + blame) _tig_blame ;; show) _tig_show ;; status) ;; *) _tigcomp " -- 2.32.0.93.g670b81a890