Merge pull request #64 from jweslley/feature/bash_completion

bash completion support
This commit is contained in:
TJ Holowaychuk 2012-01-15 13:19:29 -08:00
commit 8ff4ec94e7
3 changed files with 51 additions and 3 deletions

3
.gitmodules vendored
View file

@ -1,3 +0,0 @@
[submodule "etc/gitignore"]
path = etc/gitignore
url = git://github.com/github/gitignore.git

View file

@ -16,6 +16,7 @@ install:
cp -f $(BIN) $(PREFIX)/$(BIN); \
)
cp -f man/git-*.1 $(MANPREFIX)
cp -f etc/bash_completion.sh /etc/bash_completion.d/git-extras
docs: $(MAN_HTML) $(MAN_PAGES)
@ -41,6 +42,7 @@ uninstall:
echo "... uninstalling $(MANPREFIX)/$(MAN)"; \
rm -f $(MANPREFIX)/$(MAN); \
)
rm -f /etc/bash_completion.d/git-extras
clean: docclean

49
etc/bash_completion.sh Normal file
View file

@ -0,0 +1,49 @@
# bash completion support for git-extras.
_git_changelog(){
__gitcomp "--list"
}
_git_contrib(){
__gitcomp "$(git shortlog -s | cut -f2)" # TODO buggy if author's name contains whitespaces :(
}
_git_count(){
__gitcomp "--all"
}
_git_delete_branch(){
__gitcomp "$(__git_heads)"
}
_git_delete_submodule(){
__gitcomp "$(git submodule status | awk '{print $2}')"
}
_git_delete_tag(){
__gitcomp "$(__git_tags)"
}
_git_extras(){
__gitcomp "--version update"
}
_git_graft(){
__gitcomp "$(__git_heads)"
}
__git_extras_workflow(){
__gitcomp "$(__git_heads | grep ^$1/ | sed s/^$1\\///g) finish"
}
_git_feature(){
__git_extras_workflow "feature"
}
_git_refactor(){
__git_extras_workflow "refactor"
}
_git_bug(){
__git_extras_workflow "bug"
}