10
Sorry, I'm no bash expert. But I just tried to compile something like it for the csh family and this should be easy to transform into a bash completion script for those who know bash.
The command line I'm using to get useful, recent commit hashes is similar to:
(git branch | cut -c3-) ; (git branch | cut -c3- | xargs -ibranch git log -n 100 --pretty=format:%+H branch | sort -u)
This line works for both: bash and csh.
Basically it is the concatenation of the branch names:
git branch | cut -c3-
and the last (with n being 100) commit names (=full hash numbers)
git branch | cut -c3- | xargs -ibranch git log -n 100 --pretty=format:%+H branch | sort -u
The full autocompletion statement for csh is then like this
#
# tcsh completion for Git
#
# Taken from: https://gist.github.com/1663989
# and from: https://gtirtha.wordpress.com/2010/05/14/git-autocomplete/
# extended and merged them into what I (Ingo Schmiegel) like
set _git_commands = (add am cherry-pick commit branch format-patch ls-files help remote merge pull push amend grep rebase reset revert bisect diff difftool blame log checkout fetch stash status wdiff config)
set _git_aliase = `git config --get-regexp 'alias.*' | sed -e 's,alias.,,' | cut -d' ' -f1`
complete git "p/1/($_git_commands $_git_aliase)/" \
"n/help/($_git_commands $_git_aliase)/" \
'n/add/`git status --porcelain|cut -c4-|xargs echo`/' \
'n/br/`git branch|cut -c 3-`/' 'N/br/`git branch|cut -c 3-`/' \
'n/branch/`git branch|cut -c 3-`/' 'N/branch/`git branch|cut -c 3-`/' \
'n/cb/`git branch|cut -c 3-`/' \
'n/cherry-pick/`(git branch|cut -c3-);(git branch|cut -c3-|xargs -ibranch git log -n 100 --pretty=format:%+h branch|sort -u)`/' \
'n/co$/`git branch|cut -c 3-`/' \
'n/config/(--global --get-regexp --list)/' \
'n/diff/(--color-words --name-only)/' \
'n/difftool/(--no-prompt --prompt --tool)/' \
'