summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry <uok@gmx.net>2010-03-17 21:43:05 +0200
committerLeonid Volnitsky <Leonid@Volnitsky.com>2010-03-17 21:43:05 +0200
commit1a8d33b8b968068240aeccf4b3415192e1b45502 (patch)
tree186624ffa5d6206a2ea181f84b59893239b024f0
parentfixed: for case when there is no VCS modules (diff)
downloadgit-prompt-1a8d33b8b968068240aeccf4b3415192e1b45502.tar.gz
git-prompt-1a8d33b8b968068240aeccf4b3415192e1b45502.tar.bz2
git-prompt-1a8d33b8b968068240aeccf4b3415192e1b45502.zip
git autocompletion
The patch of (git-prompt.sh) provided an autocomplexional git commands entering You can check an action provided by patch: $ cat parse_git_complete.patch | patch -d /path/to/git-prompt $ cd /path/to/any/repository/of/git/ $ git checkout -b some_new_development_branch_v.0.0.1 Switched to a new branch 'some_new_development_branch_v.0.0.1' Press <Tab> after console entering like: $ git ch<Tab>so<Tab> or: $ g ch<Tab>so<Tab> So: you can see the new branch 'some_new_development_branch_v.0.0.1' listed
-rwxr-xr-xgit-prompt.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/git-prompt.sh b/git-prompt.sh
index 3c444f6..83c2d76 100755
--- a/git-prompt.sh
+++ b/git-prompt.sh
@@ -379,6 +379,28 @@ parse_hg_status() {
vcs_info=${branch/default/D}
}
+alias g='git'
+
+# parse git complete
+parse_git_complete()
+{
+ if [ "${BASH_VERSION%.*}" \< "3.0" ]; then
+ # echo "You will need to upgrade 'bash' to version 3.0 \
+ # for full programmable completion features (bash complete) \
+ # Please install bash-completion packet like: $ yum -y install bash-completion"
+ return
+ fi
+
+ complete -f -W "$(echo `git branch -a | sed -e s/[\ \*]//g | cut -f 1 -d ' ' | uniq`; \
+ echo `git remote | sed -e s/[\ \*]//g | cut -f 1 -d ' ' | uniq`; \
+ echo `git | tail -23 | head -21 | cut -d ' ' -f 4`; \
+ echo '--help'; \
+ echo '--staged'; \
+ echo 'remote'; \
+ echo 'help'; \
+ )" g git
+}
+
parse_git_status() {
# TODO add status: LOCKED (.git/index.lock)
@@ -390,6 +412,7 @@ parse_git_status() {
[[ -n ${git_dir/./} ]] || return 1
vcs=git
+ parse_git_complete
########################################################## GIT STATUS
file_regex='\([^/]*\/\?\).*'