Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Let's get this party started

  • Loading branch information...
commit b48c4deba04bd0ca3e5814438ae25133a2822f85 0 parents
@rtomayko authored committed
278 COPYING
@@ -0,0 +1,278 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
15 Makefile
@@ -0,0 +1,15 @@
+SHELL = /bin/sh
+PREFIX = /usr/local
+EXEC_DIR = $(PREFIX)/bin
+
+all: git-sh
+
+git-sh: git-sh.bash git-completion.bash git-sh-config.bash
+ cat $^ > git-sh
+ chmod 0755 git-sh
+
+install: git-sh
+ install -m 0755 git-sh $(EXEC_DIR)
+
+clean:
+ rm git-sh
86 README.markdown
@@ -0,0 +1,86 @@
+git-sh
+======
+
+A customized bash shell suitable for git work.
+
+The `git-sh` command starts an interactive shell tweaked for heavy git
+interaction:
+
+ * Makes all git command porcelains available as top-level command aliases.
+ * Custom prompt with branch and current repository
+ * Customizable via ~/.gitshrc file (add aliases, change prompt, etc.)
+ * Shawn O. Pearce's bash completion support built-in and works with
+ aliases.
+ * Respects `~/.bashrc` and `~/.inputrc` configuration.
+
+Installation
+------------
+
+I suppose we can assume you have git installed:
+
+ $ git clone git://github.com/rtomayko/git-sh.git
+ $ cd git-sh
+ $ make
+ $ sudo make install
+
+The `make install` command copies the `git-sh` executable to
+`/usr/local/bin`. Use the `PREFIX` environment variable to specify
+a different location (or just copy and chmod the `git-sh` file).
+
+If you'd like to be able to run `git sh` instead of `git-sh`, use
+the following to add a command alias in `~/.gitconfig`:
+
+ $ git-sh --configure
+ $ git sh
+
+Basic Usage
+-----------
+
+I typically change into a git working copy before starting the shell:
+
+ $ cd some-git-repo
+ $ git sh
+ master!some-git-repo>
+
+The shell's default prompt shows the current branch, bang, and the relative
+path to the current working directory from the nearest git working copy.
+
+Most git commands can be executed directly:
+
+ master!some-git-repo> checkout -b new-branch
+ new-branch!some-git-repo> log -p
+ new-branch!some-git-repo> rebase -i HEAD~10
+
+IMPORTANT: `rm`, `mv`, and `diff` are aliased to their git counterparts.
+Qualify the command (e.g., `/bin/rm`) to use system versions.
+
+Customizing
+-----------
+
+If the `~/.gitshrc` file exists, it is sourced as the very last thing the
+shell does before becoming interactive. I've included my personal
+[`~/.gitshrc`][1] in the distribution as an example.
+
+[1]: gitshrc-example.bash "Ryan's ~/.gitshrc file"
+
+Note also that your `~/.bashrc` file is sourced into the shell as well so
+any customization made there not explicitly overridden by `git-sh` should
+be available.
+
+Help
+----
+
+The `help` command shows git's help output followed by a list of custom
+aliases from your `~/.gitshrc` file:
+
+ master!some-git-repo> help
+
+License
+-------
+
+Copyright (C) 2008 Ryan Tomayko <r@tomayko.com>
+Copyright (C) 2006, 2007 Shawn O. Pearce <spearce@spearce.org>
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License, version 2, as published
+by the Free Software Foundation.
1,294 git-completion.bash
@@ -0,0 +1,1294 @@
+#
+# bash completion support for core Git.
+#
+# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
+# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
+# Distributed under the GNU General Public License, version 2.0.
+#
+# The contained completion routines provide support for completing:
+#
+# *) local and remote branch names
+# *) local and remote tag names
+# *) .git/remotes file names
+# *) git 'subcommands'
+# *) tree paths within 'ref:path/to/file' expressions
+# *) common --long-options
+#
+# To use these routines:
+#
+# 1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
+# 2) Added the following line to your .bashrc:
+# source ~/.git-completion.sh
+#
+# 3) You may want to make sure the git executable is available
+# in your PATH before this script is sourced, as some caching
+# is performed while the script loads. If git isn't found
+# at source time then all lookups will be done on demand,
+# which may be slightly slower.
+#
+# 4) Consider changing your PS1 to also show the current branch:
+# PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
+#
+# The argument to __git_ps1 will be displayed only if you
+# are currently in a git repository. The %s token will be
+# the name of the current branch.
+#
+# To submit patches:
+#
+# *) Read Documentation/SubmittingPatches
+# *) Send all patches to the current maintainer:
+#
+# "Shawn O. Pearce" <spearce@spearce.org>
+#
+# *) Always CC the Git mailing list:
+#
+# git@vger.kernel.org
+#
+
+__gitdir ()
+{
+ if [ -z "$1" ]; then
+ if [ -n "$__git_dir" ]; then
+ echo "$__git_dir"
+ elif [ -d .git ]; then
+ echo .git
+ else
+ git rev-parse --git-dir 2>/dev/null
+ fi
+ elif [ -d "$1/.git" ]; then
+ echo "$1/.git"
+ else
+ echo "$1"
+ fi
+}
+
+__git_ps1 ()
+{
+ local g="$(git rev-parse --git-dir 2>/dev/null)"
+ if [ -n "$g" ]; then
+ local r
+ local b
+ if [ -d "$g/../.dotest" ]
+ then
+ r="|AM/REBASE"
+ b="$(git symbolic-ref HEAD 2>/dev/null)"
+ elif [ -f "$g/.dotest-merge/interactive" ]
+ then
+ r="|REBASE-i"
+ b="$(cat $g/.dotest-merge/head-name)"
+ elif [ -d "$g/.dotest-merge" ]
+ then
+ r="|REBASE-m"
+ b="$(cat $g/.dotest-merge/head-name)"
+ elif [ -f "$g/MERGE_HEAD" ]
+ then
+ r="|MERGING"
+ b="$(git symbolic-ref HEAD 2>/dev/null)"
+ else
+ if [ -f $g/BISECT_LOG ]
+ then
+ r="|BISECTING"
+ fi
+ if ! b="$(git symbolic-ref HEAD 2>/dev/null)"
+ then
+ b="$(cut -c1-7 $g/HEAD)..."
+ fi
+ fi
+
+ if [ -n "$1" ]; then
+ printf "$1" "${b##refs/heads/}$r"
+ else
+ printf " (%s)" "${b##refs/heads/}$r"
+ fi
+ fi
+}
+
+__gitcomp ()
+{
+ local all c s=$'\n' IFS=' '$'\t'$'\n'
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ if [ $# -gt 2 ]; then
+ cur="$3"
+ fi
+ for c in $1; do
+ case "$c$4" in
+ --*=*) all="$all$c$4$s" ;;
+ *.) all="$all$c$4$s" ;;
+ *) all="$all$c$4 $s" ;;
+ esac
+ done
+ IFS=$s
+ COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
+ return
+}
+
+__git_heads ()
+{
+ local cmd i is_hash=y dir="$(__gitdir "$1")"
+ if [ -d "$dir" ]; then
+ for i in $(git --git-dir="$dir" \
+ for-each-ref --format='%(refname)' \
+ refs/heads ); do
+ echo "${i#refs/heads/}"
+ done
+ return
+ fi
+ for i in $(git-ls-remote "$1" 2>/dev/null); do
+ case "$is_hash,$i" in
+ y,*) is_hash=n ;;
+ n,*^{}) is_hash=y ;;
+ n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
+ n,*) is_hash=y; echo "$i" ;;
+ esac
+ done
+}
+
+__git_tags ()
+{
+ local cmd i is_hash=y dir="$(__gitdir "$1")"
+ if [ -d "$dir" ]; then
+ for i in $(git --git-dir="$dir" \
+ for-each-ref --format='%(refname)' \
+ refs/tags ); do
+ echo "${i#refs/tags/}"
+ done
+ return
+ fi
+ for i in $(git-ls-remote "$1" 2>/dev/null); do
+ case "$is_hash,$i" in
+ y,*) is_hash=n ;;
+ n,*^{}) is_hash=y ;;
+ n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
+ n,*) is_hash=y; echo "$i" ;;
+ esac
+ done
+}
+
+__git_refs ()
+{
+ local cmd i is_hash=y dir="$(__gitdir "$1")"
+ if [ -d "$dir" ]; then
+ if [ -e "$dir/HEAD" ]; then echo HEAD; fi
+ for i in $(git --git-dir="$dir" \
+ for-each-ref --format='%(refname)' \
+ refs/tags refs/heads refs/remotes); do
+ case "$i" in
+ refs/tags/*) echo "${i#refs/tags/}" ;;
+ refs/heads/*) echo "${i#refs/heads/}" ;;
+ refs/remotes/*) echo "${i#refs/remotes/}" ;;
+ *) echo "$i" ;;
+ esac
+ done
+ return
+ fi
+ for i in $(git-ls-remote "$dir" 2>/dev/null); do
+ case "$is_hash,$i" in
+ y,*) is_hash=n ;;
+ n,*^{}) is_hash=y ;;
+ n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
+ n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
+ n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
+ n,*) is_hash=y; echo "$i" ;;
+ esac
+ done
+}
+
+__git_refs2 ()
+{
+ local i
+ for i in $(__git_refs "$1"); do
+ echo "$i:$i"
+ done
+}
+
+__git_refs_remotes ()
+{
+ local cmd i is_hash=y
+ for i in $(git-ls-remote "$1" 2>/dev/null); do
+ case "$is_hash,$i" in
+ n,refs/heads/*)
+ is_hash=y
+ echo "$i:refs/remotes/$1/${i#refs/heads/}"
+ ;;
+ y,*) is_hash=n ;;
+ n,*^{}) is_hash=y ;;
+ n,refs/tags/*) is_hash=y;;
+ n,*) is_hash=y; ;;
+ esac
+ done
+}
+
+__git_remotes ()
+{
+ local i ngoff IFS=$'\n' d="$(__gitdir)"
+ shopt -q nullglob || ngoff=1
+ shopt -s nullglob
+ for i in "$d/remotes"/*; do
+ echo ${i#$d/remotes/}
+ done
+ [ "$ngoff" ] && shopt -u nullglob
+ for i in $(git --git-dir="$d" config --list); do
+ case "$i" in
+ remote.*.url=*)
+ i="${i#remote.}"
+ echo "${i/.url=*/}"
+ ;;
+ esac
+ done
+}
+
+__git_merge_strategies ()
+{
+ if [ -n "$__git_merge_strategylist" ]; then
+ echo "$__git_merge_strategylist"
+ return
+ fi
+ sed -n "/^all_strategies='/{
+ s/^all_strategies='//
+ s/'//
+ p
+ q
+ }" "$(git --exec-path)/git-merge"
+}
+__git_merge_strategylist=
+__git_merge_strategylist="$(__git_merge_strategies 2>/dev/null)"
+
+__git_complete_file ()
+{
+ local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ ?*:*)
+ ref="${cur%%:*}"
+ cur="${cur#*:}"
+ case "$cur" in
+ ?*/*)
+ pfx="${cur%/*}"
+ cur="${cur##*/}"
+ ls="$ref:$pfx"
+ pfx="$pfx/"
+ ;;
+ *)
+ ls="$ref"
+ ;;
+ esac
+ COMPREPLY=($(compgen -P "$pfx" \
+ -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
+ | sed '/^100... blob /s,^.* ,,
+ /^040000 tree /{
+ s,^.* ,,
+ s,$,/,
+ }
+ s/^.* //')" \
+ -- "$cur"))
+ ;;
+ *)
+ __gitcomp "$(__git_refs)"
+ ;;
+ esac
+}
+
+__git_complete_revlist ()
+{
+ local pfx cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ *...*)
+ pfx="${cur%...*}..."
+ cur="${cur#*...}"
+ __gitcomp "$(__git_refs)" "$pfx" "$cur"
+ ;;
+ *..*)
+ pfx="${cur%..*}.."
+ cur="${cur#*..}"
+ __gitcomp "$(__git_refs)" "$pfx" "$cur"
+ ;;
+ *.)
+ __gitcomp "$cur."
+ ;;
+ *)
+ __gitcomp "$(__git_refs)"
+ ;;
+ esac
+}
+
+__git_commands ()
+{
+ if [ -n "$__git_commandlist" ]; then
+ echo "$__git_commandlist"
+ return
+ fi
+ local i IFS=" "$'\n'
+ for i in $(git help -a|egrep '^ ')
+ do
+ case $i in
+ *--*) : helper pattern;;
+ applymbox) : ask gittus;;
+ applypatch) : ask gittus;;
+ archimport) : import;;
+ cat-file) : plumbing;;
+ check-attr) : plumbing;;
+ check-ref-format) : plumbing;;
+ commit-tree) : plumbing;;
+ cvsexportcommit) : export;;
+ cvsimport) : import;;
+ cvsserver) : daemon;;
+ daemon) : daemon;;
+ diff-files) : plumbing;;
+ diff-index) : plumbing;;
+ diff-tree) : plumbing;;
+ fast-import) : import;;
+ fsck-objects) : plumbing;;
+ fetch-pack) : plumbing;;
+ fmt-merge-msg) : plumbing;;
+ for-each-ref) : plumbing;;
+ hash-object) : plumbing;;
+ http-*) : transport;;
+ index-pack) : plumbing;;
+ init-db) : deprecated;;
+ local-fetch) : plumbing;;
+ mailinfo) : plumbing;;
+ mailsplit) : plumbing;;
+ merge-*) : plumbing;;
+ mktree) : plumbing;;
+ mktag) : plumbing;;
+ pack-objects) : plumbing;;
+ pack-redundant) : plumbing;;
+ pack-refs) : plumbing;;
+ parse-remote) : plumbing;;
+ patch-id) : plumbing;;
+ peek-remote) : plumbing;;
+ prune) : plumbing;;
+ prune-packed) : plumbing;;
+ quiltimport) : import;;
+ read-tree) : plumbing;;
+ receive-pack) : plumbing;;
+ reflog) : plumbing;;
+ repo-config) : deprecated;;
+ rerere) : plumbing;;
+ rev-list) : plumbing;;
+ rev-parse) : plumbing;;
+ runstatus) : plumbing;;
+ sh-setup) : internal;;
+ shell) : daemon;;
+ send-pack) : plumbing;;
+ show-index) : plumbing;;
+ ssh-*) : transport;;
+ stripspace) : plumbing;;
+ svn) : import export;;
+ symbolic-ref) : plumbing;;
+ tar-tree) : deprecated;;
+ unpack-file) : plumbing;;
+ unpack-objects) : plumbing;;
+ update-index) : plumbing;;
+ update-ref) : plumbing;;
+ update-server-info) : daemon;;
+ upload-archive) : plumbing;;
+ upload-pack) : plumbing;;
+ write-tree) : plumbing;;
+ verify-tag) : plumbing;;
+ *) echo $i;;
+ esac
+ done
+}
+__git_commandlist=
+__git_commandlist="$(__git_commands 2>/dev/null)"
+
+__git_aliases ()
+{
+ local i IFS=$'\n'
+ for i in $(git --git-dir="$(__gitdir)" config --list); do
+ case "$i" in
+ alias.*)
+ i="${i#alias.}"
+ echo "${i/=*/}"
+ ;;
+ esac
+ done
+}
+
+__git_aliased_command ()
+{
+ local word cmdline=$(git --git-dir="$(__gitdir)" \
+ config --get "alias.$1")
+ for word in $cmdline; do
+ if [ "${word##-*}" ]; then
+ echo $word
+ return
+ fi
+ done
+}
+
+__git_whitespacelist="nowarn warn error error-all strip"
+
+_git_am ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ if [ -d .dotest ]; then
+ __gitcomp "--skip --resolved"
+ return
+ fi
+ case "$cur" in
+ --whitespace=*)
+ __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
+ return
+ ;;
+ --*)
+ __gitcomp "
+ --signoff --utf8 --binary --3way --interactive
+ --whitespace=
+ "
+ return
+ esac
+ COMPREPLY=()
+}
+
+_git_apply ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --whitespace=*)
+ __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
+ return
+ ;;
+ --*)
+ __gitcomp "
+ --stat --numstat --summary --check --index
+ --cached --index-info --reverse --reject --unidiff-zero
+ --apply --no-add --exclude=
+ --whitespace= --inaccurate-eof --verbose
+ "
+ return
+ esac
+ COMPREPLY=()
+}
+
+_git_add ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--interactive --refresh"
+ return
+ esac
+ COMPREPLY=()
+}
+
+_git_bisect ()
+{
+ local i c=1 command
+ while [ $c -lt $COMP_CWORD ]; do
+ i="${COMP_WORDS[c]}"
+ case "$i" in
+ start|bad|good|reset|visualize|replay|log)
+ command="$i"
+ break
+ ;;
+ esac
+ c=$((++c))
+ done
+
+ if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+ __gitcomp "start bad good reset visualize replay log"
+ return
+ fi
+
+ case "$command" in
+ bad|good|reset)
+ __gitcomp "$(__git_refs)"
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+}
+
+_git_branch ()
+{
+ __gitcomp "$(__git_refs)"
+}
+
+_git_bundle ()
+{
+ local mycword="$COMP_CWORD"
+ case "${COMP_WORDS[0]}" in
+ git)
+ local cmd="${COMP_WORDS[2]}"
+ mycword="$((mycword-1))"
+ ;;
+ git-bundle*)
+ local cmd="${COMP_WORDS[1]}"
+ ;;
+ esac
+ case "$mycword" in
+ 1)
+ __gitcomp "create list-heads verify unbundle"
+ ;;
+ 2)
+ # looking for a file
+ ;;
+ *)
+ case "$cmd" in
+ create)
+ __git_complete_revlist
+ ;;
+ esac
+ ;;
+ esac
+}
+
+_git_checkout ()
+{
+ __gitcomp "$(__git_refs)"
+}
+
+_git_cherry ()
+{
+ __gitcomp "$(__git_refs)"
+}
+
+_git_cherry_pick ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--edit --no-commit"
+ ;;
+ *)
+ __gitcomp "$(__git_refs)"
+ ;;
+ esac
+}
+
+_git_commit ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --all --author= --signoff --verify --no-verify
+ --edit --amend --include --only
+ "
+ return
+ esac
+ COMPREPLY=()
+}
+
+_git_describe ()
+{
+ __gitcomp "$(__git_refs)"
+}
+
+_git_diff ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--cached --stat --numstat --shortstat --summary
+ --patch-with-stat --name-only --name-status --color
+ --no-color --color-words --no-renames --check
+ --full-index --binary --abbrev --diff-filter
+ --find-copies-harder --pickaxe-all --pickaxe-regex
+ --text --ignore-space-at-eol --ignore-space-change
+ --ignore-all-space --exit-code --quiet --ext-diff
+ --no-ext-diff"
+ return
+ ;;
+ esac
+ __git_complete_file
+}
+
+_git_diff_tree ()
+{
+ __gitcomp "$(__git_refs)"
+}
+
+_git_fetch ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+
+ case "${COMP_WORDS[0]},$COMP_CWORD" in
+ git-fetch*,1)
+ __gitcomp "$(__git_remotes)"
+ ;;
+ git,2)
+ __gitcomp "$(__git_remotes)"
+ ;;
+ *)
+ case "$cur" in
+ *:*)
+ __gitcomp "$(__git_refs)" "" "${cur#*:}"
+ ;;
+ *)
+ local remote
+ case "${COMP_WORDS[0]}" in
+ git-fetch) remote="${COMP_WORDS[1]}" ;;
+ git) remote="${COMP_WORDS[2]}" ;;
+ esac
+ __gitcomp "$(__git_refs2 "$remote")"
+ ;;
+ esac
+ ;;
+ esac
+}
+
+_git_format_patch ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --stdout --attach --thread
+ --output-directory
+ --numbered --start-number
+ --numbered-files
+ --keep-subject
+ --signoff
+ --in-reply-to=
+ --full-index --binary
+ --not --all
+ "
+ return
+ ;;
+ esac
+ __git_complete_revlist
+}
+
+_git_gc ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--prune --aggressive"
+ return
+ ;;
+ esac
+ COMPREPLY=()
+}
+
+_git_ls_remote ()
+{
+ __gitcomp "$(__git_remotes)"
+}
+
+_git_ls_tree ()
+{
+ __git_complete_file
+}
+
+_git_log ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --pretty=*)
+ __gitcomp "
+ oneline short medium full fuller email raw
+ " "" "${cur##--pretty=}"
+ return
+ ;;
+ --date=*)
+ __gitcomp "
+ relative iso8601 rfc2822 short local default
+ " "" "${cur##--date=}"
+ return
+ ;;
+ --*)
+ __gitcomp "
+ --max-count= --max-age= --since= --after=
+ --min-age= --before= --until=
+ --root --topo-order --date-order --reverse
+ --no-merges --follow
+ --abbrev-commit --abbrev=
+ --relative-date --date=
+ --author= --committer= --grep=
+ --all-match
+ --pretty= --name-status --name-only --raw
+ --not --all
+ --left-right --cherry-pick
+ "
+ return
+ ;;
+ esac
+ __git_complete_revlist
+}
+
+_git_merge ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "${COMP_WORDS[COMP_CWORD-1]}" in
+ -s|--strategy)
+ __gitcomp "$(__git_merge_strategies)"
+ return
+ esac
+ case "$cur" in
+ --strategy=*)
+ __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
+ return
+ ;;
+ --*)
+ __gitcomp "
+ --no-commit --no-summary --squash --strategy
+ "
+ return
+ esac
+ __gitcomp "$(__git_refs)"
+}
+
+_git_merge_base ()
+{
+ __gitcomp "$(__git_refs)"
+}
+
+_git_name_rev ()
+{
+ __gitcomp "--tags --all --stdin"
+}
+
+_git_pull ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+
+ case "${COMP_WORDS[0]},$COMP_CWORD" in
+ git-pull*,1)
+ __gitcomp "$(__git_remotes)"
+ ;;
+ git,2)
+ __gitcomp "$(__git_remotes)"
+ ;;
+ *)
+ local remote
+ case "${COMP_WORDS[0]}" in
+ git-pull) remote="${COMP_WORDS[1]}" ;;
+ git) remote="${COMP_WORDS[2]}" ;;
+ esac
+ __gitcomp "$(__git_refs "$remote")"
+ ;;
+ esac
+}
+
+_git_push ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+
+ case "${COMP_WORDS[0]},$COMP_CWORD" in
+ git-push*,1)
+ __gitcomp "$(__git_remotes)"
+ ;;
+ git,2)
+ __gitcomp "$(__git_remotes)"
+ ;;
+ *)
+ case "$cur" in
+ *:*)
+ local remote
+ case "${COMP_WORDS[0]}" in
+ git-push) remote="${COMP_WORDS[1]}" ;;
+ git) remote="${COMP_WORDS[2]}" ;;
+ esac
+ __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
+ ;;
+ +*)
+ __gitcomp "$(__git_refs)" + "${cur#+}"
+ ;;
+ *)
+ __gitcomp "$(__git_refs)"
+ ;;
+ esac
+ ;;
+ esac
+}
+
+_git_rebase ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ if [ -d .dotest ] || [ -d .git/.dotest-merge ]; then
+ __gitcomp "--continue --skip --abort"
+ return
+ fi
+ case "${COMP_WORDS[COMP_CWORD-1]}" in
+ -s|--strategy)
+ __gitcomp "$(__git_merge_strategies)"
+ return
+ esac
+ case "$cur" in
+ --strategy=*)
+ __gitcomp "$(__git_merge_strategies)" "" "${cur##--strategy=}"
+ return
+ ;;
+ --*)
+ __gitcomp "--onto --merge --strategy"
+ return
+ esac
+ __gitcomp "$(__git_refs)"
+}
+
+_git_config ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ local prv="${COMP_WORDS[COMP_CWORD-1]}"
+ case "$prv" in
+ branch.*.remote)
+ __gitcomp "$(__git_remotes)"
+ return
+ ;;
+ branch.*.merge)
+ __gitcomp "$(__git_refs)"
+ return
+ ;;
+ remote.*.fetch)
+ local remote="${prv#remote.}"
+ remote="${remote%.fetch}"
+ __gitcomp "$(__git_refs_remotes "$remote")"
+ return
+ ;;
+ remote.*.push)
+ local remote="${prv#remote.}"
+ remote="${remote%.push}"
+ __gitcomp "$(git --git-dir="$(__gitdir)" \
+ for-each-ref --format='%(refname):%(refname)' \
+ refs/heads)"
+ return
+ ;;
+ pull.twohead|pull.octopus)
+ __gitcomp "$(__git_merge_strategies)"
+ return
+ ;;
+ color.branch|color.diff|color.status)
+ __gitcomp "always never auto"
+ return
+ ;;
+ color.*.*)
+ __gitcomp "
+ black red green yellow blue magenta cyan white
+ bold dim ul blink reverse
+ "
+ return
+ ;;
+ *.*)
+ COMPREPLY=()
+ return
+ ;;
+ esac
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --global --system --file=
+ --list --replace-all
+ --get --get-all --get-regexp
+ --add --unset --unset-all
+ --remove-section --rename-section
+ "
+ return
+ ;;
+ branch.*.*)
+ local pfx="${cur%.*}."
+ cur="${cur##*.}"
+ __gitcomp "remote merge" "$pfx" "$cur"
+ return
+ ;;
+ branch.*)
+ local pfx="${cur%.*}."
+ cur="${cur#*.}"
+ __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
+ return
+ ;;
+ remote.*.*)
+ local pfx="${cur%.*}."
+ cur="${cur##*.}"
+ __gitcomp "
+ url fetch push skipDefaultUpdate
+ receivepack uploadpack tagopt
+ " "$pfx" "$cur"
+ return
+ ;;
+ remote.*)
+ local pfx="${cur%.*}."
+ cur="${cur#*.}"
+ __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
+ return
+ ;;
+ esac
+ __gitcomp "
+ apply.whitespace
+ core.fileMode
+ core.gitProxy
+ core.ignoreStat
+ core.preferSymlinkRefs
+ core.logAllRefUpdates
+ core.loosecompression
+ core.repositoryFormatVersion
+ core.sharedRepository
+ core.warnAmbiguousRefs
+ core.compression
+ core.legacyHeaders
+ core.packedGitWindowSize
+ core.packedGitLimit
+ clean.requireForce
+ color.branch
+ color.branch.current
+ color.branch.local
+ color.branch.remote
+ color.branch.plain
+ color.diff
+ color.diff.plain
+ color.diff.meta
+ color.diff.frag
+ color.diff.old
+ color.diff.new
+ color.diff.commit
+ color.diff.whitespace
+ color.pager
+ color.status
+ color.status.header
+ color.status.added
+ color.status.changed
+ color.status.untracked
+ diff.renameLimit
+ diff.renames
+ fetch.unpackLimit
+ format.headers
+ format.subjectprefix
+ gitcvs.enabled
+ gitcvs.logfile
+ gitcvs.allbinary
+ gitcvs.dbname gitcvs.dbdriver gitcvs.dbuser gitcvs.dvpass
+ gc.packrefs
+ gc.reflogexpire
+ gc.reflogexpireunreachable
+ gc.rerereresolved
+ gc.rerereunresolved
+ http.sslVerify
+ http.sslCert
+ http.sslKey
+ http.sslCAInfo
+ http.sslCAPath
+ http.maxRequests
+ http.lowSpeedLimit
+ http.lowSpeedTime
+ http.noEPSV
+ i18n.commitEncoding
+ i18n.logOutputEncoding
+ log.showroot
+ merge.tool
+ merge.summary
+ merge.verbosity
+ pack.window
+ pack.depth
+ pack.windowMemory
+ pack.compression
+ pack.deltaCacheSize
+ pack.deltaCacheLimit
+ pull.octopus
+ pull.twohead
+ repack.useDeltaBaseOffset
+ show.difftree
+ showbranch.default
+ tar.umask
+ transfer.unpackLimit
+ receive.unpackLimit
+ receive.denyNonFastForwards
+ user.name
+ user.email
+ user.signingkey
+ whatchanged.difftree
+ branch. remote.
+ "
+}
+
+_git_remote ()
+{
+ local i c=1 command
+ while [ $c -lt $COMP_CWORD ]; do
+ i="${COMP_WORDS[c]}"
+ case "$i" in
+ add|rm|show|prune|update) command="$i"; break ;;
+ esac
+ c=$((++c))
+ done
+
+ if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+ __gitcomp "add rm show prune update"
+ return
+ fi
+
+ case "$command" in
+ rm|show|prune)
+ __gitcomp "$(__git_remotes)"
+ ;;
+ update)
+ local i c='' IFS=$'\n'
+ for i in $(git --git-dir="$(__gitdir)" config --list); do
+ case "$i" in
+ remotes.*)
+ i="${i#remotes.}"
+ c="$c ${i/=*/}"
+ ;;
+ esac
+ done
+ __gitcomp "$c"
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+}
+
+_git_reset ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--mixed --hard --soft"
+ return
+ ;;
+ esac
+ __gitcomp "$(__git_refs)"
+}
+
+_git_shortlog ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "
+ --max-count= --max-age= --since= --after=
+ --min-age= --before= --until=
+ --no-merges
+ --author= --committer= --grep=
+ --all-match
+ --not --all
+ --numbered --summary
+ "
+ return
+ ;;
+ esac
+ __git_complete_revlist
+}
+
+_git_show ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --pretty=*)
+ __gitcomp "
+ oneline short medium full fuller email raw
+ " "" "${cur##--pretty=}"
+ return
+ ;;
+ --*)
+ __gitcomp "--pretty="
+ return
+ ;;
+ esac
+ __git_complete_file
+}
+
+_git_stash ()
+{
+ __gitcomp 'list show apply clear'
+}
+
+_git_submodule ()
+{
+ local i c=1 command
+ while [ $c -lt $COMP_CWORD ]; do
+ i="${COMP_WORDS[c]}"
+ case "$i" in
+ add|status|init|update) command="$i"; break ;;
+ esac
+ c=$((++c))
+ done
+
+ if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--quiet --cached"
+ ;;
+ *)
+ __gitcomp "add status init update"
+ ;;
+ esac
+ return
+ fi
+}
+
+_git_tag ()
+{
+ local i c=1 f=0
+ while [ $c -lt $COMP_CWORD ]; do
+ i="${COMP_WORDS[c]}"
+ case "$i" in
+ -d|-v)
+ __gitcomp "$(__git_tags)"
+ return
+ ;;
+ -f)
+ f=1
+ ;;
+ esac
+ c=$((++c))
+ done
+
+ case "${COMP_WORDS[COMP_CWORD-1]}" in
+ -m|-F)
+ COMPREPLY=()
+ ;;
+ -*|tag|git-tag)
+ if [ $f = 1 ]; then
+ __gitcomp "$(__git_tags)"
+ else
+ COMPREPLY=()
+ fi
+ ;;
+ *)
+ __gitcomp "$(__git_refs)"
+ ;;
+ esac
+}
+
+_git ()
+{
+ local i c=1 command __git_dir
+
+ while [ $c -lt $COMP_CWORD ]; do
+ i="${COMP_WORDS[c]}"
+ case "$i" in
+ --git-dir=*) __git_dir="${i#--git-dir=}" ;;
+ --bare) __git_dir="." ;;
+ --version|--help|-p|--paginate) ;;
+ *) command="$i"; break ;;
+ esac
+ c=$((++c))
+ done
+
+ if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+ case "${COMP_WORDS[COMP_CWORD]}" in
+ --*=*) COMPREPLY=() ;;
+ --*) __gitcomp "
+ --no-pager
+ --git-dir=
+ --bare
+ --version
+ --exec-path
+ "
+ ;;
+ *) __gitcomp "$(__git_commands) $(__git_aliases)" ;;
+ esac
+ return
+ fi
+
+ local expansion=$(__git_aliased_command "$command")
+ [ "$expansion" ] && command="$expansion"
+
+ case "$command" in
+ am) _git_am ;;
+ add) _git_add ;;
+ apply) _git_apply ;;
+ bisect) _git_bisect ;;
+ bundle) _git_bundle ;;
+ branch) _git_branch ;;
+ checkout) _git_checkout ;;
+ cherry) _git_cherry ;;
+ cherry-pick) _git_cherry_pick ;;
+ commit) _git_commit ;;
+ config) _git_config ;;
+ describe) _git_describe ;;
+ diff) _git_diff ;;
+ fetch) _git_fetch ;;
+ format-patch) _git_format_patch ;;
+ gc) _git_gc ;;
+ log) _git_log ;;
+ ls-remote) _git_ls_remote ;;
+ ls-tree) _git_ls_tree ;;
+ merge) _git_merge;;
+ merge-base) _git_merge_base ;;
+ name-rev) _git_name_rev ;;
+ pull) _git_pull ;;
+ push) _git_push ;;
+ rebase) _git_rebase ;;
+ remote) _git_remote ;;
+ reset) _git_reset ;;
+ shortlog) _git_shortlog ;;
+ show) _git_show ;;
+ show-branch) _git_log ;;
+ stash) _git_stash ;;
+ submodule) _git_submodule ;;
+ tag) _git_tag ;;
+ whatchanged) _git_log ;;
+ *) COMPREPLY=() ;;
+ esac
+}
+
+_gitk ()
+{
+ local cur="${COMP_WORDS[COMP_CWORD]}"
+ case "$cur" in
+ --*)
+ __gitcomp "--not --all"
+ return
+ ;;
+ esac
+ __git_complete_revlist
+}
+
+complete -o default -o nospace -F _git git
+complete -o default -o nospace -F _gitk gitk
+complete -o default -o nospace -F _git_am git-am
+complete -o default -o nospace -F _git_apply git-apply
+complete -o default -o nospace -F _git_bisect git-bisect
+complete -o default -o nospace -F _git_branch git-branch
+complete -o default -o nospace -F _git_bundle git-bundle
+complete -o default -o nospace -F _git_checkout git-checkout
+complete -o default -o nospace -F _git_cherry git-cherry
+complete -o default -o nospace -F _git_cherry_pick git-cherry-pick
+complete -o default -o nospace -F _git_commit git-commit
+complete -o default -o nospace -F _git_describe git-describe
+complete -o default -o nospace -F _git_diff git-diff
+complete -o default -o nospace -F _git_fetch git-fetch
+complete -o default -o nospace -F _git_format_patch git-format-patch
+complete -o default -o nospace -F _git_gc git-gc
+complete -o default -o nospace -F _git_log git-log
+complete -o default -o nospace -F _git_ls_remote git-ls-remote
+complete -o default -o nospace -F _git_ls_tree git-ls-tree
+complete -o default -o nospace -F _git_merge git-merge
+complete -o default -o nospace -F _git_merge_base git-merge-base
+complete -o default -o nospace -F _git_name_rev git-name-rev
+complete -o default -o nospace -F _git_pull git-pull
+complete -o default -o nospace -F _git_push git-push
+complete -o default -o nospace -F _git_rebase git-rebase
+complete -o default -o nospace -F _git_config git-config
+complete -o default -o nospace -F _git_remote git-remote
+complete -o default -o nospace -F _git_reset git-reset
+complete -o default -o nospace -F _git_shortlog git-shortlog
+complete -o default -o nospace -F _git_show git-show
+complete -o default -o nospace -F _git_stash git-stash
+complete -o default -o nospace -F _git_submodule git-submodule
+complete -o default -o nospace -F _git_log git-show-branch
+complete -o default -o nospace -F _git_tag git-tag
+complete -o default -o nospace -F _git_log git-whatchanged
+
+# The following are necessary only for Cygwin, and only are needed
+# when the user has tab-completed the executable name and consequently
+# included the '.exe' suffix.
+#
+if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
+complete -o default -o nospace -F _git_add git-add.exe
+complete -o default -o nospace -F _git_apply git-apply.exe
+complete -o default -o nospace -F _git git.exe
+complete -o default -o nospace -F _git_branch git-branch.exe
+complete -o default -o nospace -F _git_bundle git-bundle.exe
+complete -o default -o nospace -F _git_cherry git-cherry.exe
+complete -o default -o nospace -F _git_describe git-describe.exe
+complete -o default -o nospace -F _git_diff git-diff.exe
+complete -o default -o nospace -F _git_format_patch git-format-patch.exe
+complete -o default -o nospace -F _git_log git-log.exe
+complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe
+complete -o default -o nospace -F _git_merge_base git-merge-base.exe
+complete -o default -o nospace -F _git_name_rev git-name-rev.exe
+complete -o default -o nospace -F _git_push git-push.exe
+complete -o default -o nospace -F _git_config git-config
+complete -o default -o nospace -F _git_shortlog git-shortlog.exe
+complete -o default -o nospace -F _git_show git-show.exe
+complete -o default -o nospace -F _git_log git-show-branch.exe
+complete -o default -o nospace -F _git_tag git-tag.exe
+complete -o default -o nospace -F _git_log git-whatchanged.exe
+fi
5 git-sh-config.bash
@@ -0,0 +1,5 @@
+
+# CONFIG ==============================================================
+
+# source the user's rc file:
+[ -r ~/.gitshrc ] && . ~/.gitshrc
183 git-sh.bash
@@ -0,0 +1,183 @@
+#!/usr/bin/env bash
+#
+# A customized bash environment suitable for git work.
+#
+# Copyright (C) 2008 Ryan Tomayko <r@tomayko.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# Distributed under the GNU General Public License, version 2.0.
+
+# use to install the sh alias
+[ "$1" = "--configure" ] && {
+ set -e
+ git config --global alias.sh '!git-sh'
+ echo "alias 'sh' added to ~/.gitconfig"
+ exit 0
+}
+
+# we expect to be sourced into an interactive shell. when executed as a
+# command, kick off a new shell and source us. this is a pretty cool hack;
+# make it better.
+[ "$0" = 'bash' ] ||
+exec /usr/bin/env bash --rcfile "$@" "$0"
+
+# source the user's .bashrc file
+[ -r ~/.bashrc ] && {
+ cd ~
+ . .bashrc
+ cd $OLDPWD
+}
+
+# create aliases for most/all git command porcelains.
+
+alias checkout='git checkout'
+alias add='git add'
+alias am='git am'
+alias annotate='git annotate'
+alias apply='git apply'
+alias archive='git archive'
+alias bisect='git bisect'
+alias blame='git blame'
+alias branch='git branch'
+alias bundle='git bundle'
+alias cat-file='git cat-file'
+alias checkout='git checkout'
+alias cherry='git cherry'
+alias cherry-pick='git cherry-pick'
+alias clean='git clean'
+alias clone='git clone'
+alias commit='git commit'
+alias config='git config'
+alias describe='git describe'
+alias diff='git diff'
+alias fetch='git fetch'
+alias format-patch='git format-patch'
+alias fsck='git fsck'
+alias gc='git gc'
+alias gui='git gui'
+alias init='git init'
+alias instaweb='git instaweb'
+alias log='git log'
+alias lost-found='git lost-found'
+alias ls-files='git ls-files'
+alias ls-remote='git ls-remote'
+alias ls-tree='git ls-tree'
+alias merge='git merge'
+alias mergetool='git mergetool'
+alias mv='git mv'
+alias patch-id='git patch-id'
+alias peek-remote='git peek-remote'
+alias prune='git prune'
+alias pull='git pull'
+alias push='git push'
+alias quiltimport='git quiltimport'
+alias rebase='git rebase'
+alias remote='git remote'
+alias repack='git repack'
+alias repo-config='git repo-config'
+alias request-pull='git request-pull'
+alias reset='git reset'
+alias rev-list='git rev-list'
+alias rev-parse='git rev-parse'
+alias revert='git revert'
+alias rm='git rm'
+alias send-email='git send-email'
+alias send-pack='git send-pack'
+alias show='git show'
+alias stash='git stash'
+alias status='git status'
+alias stripspace='git stripspace'
+alias submodule='git submodule'
+alias svn='git svn'
+alias symbolic-ref='git symbolic-ref'
+alias tag='git tag'
+alias tar-tree='git tar-tree'
+alias var='git var'
+alias whatchanged='git whatchanged'
+
+# configure bash completion for aliases
+
+complete -o default -o nospace -F _git_am am
+complete -o default -o nospace -F _git_apply apply
+complete -o default -o nospace -F _git_bisect bisect
+complete -o default -o nospace -F _git_branch branch
+complete -o default -o nospace -F _git_bundle bundle
+complete -o default -o nospace -F _git_checkout checkout
+complete -o default -o nospace -F _git_cherry cherry
+complete -o default -o nospace -F _git_cherry_pick cherry-pick
+complete -o default -o nospace -F _git_commit commit
+complete -o default -o nospace -F _git_describe describe
+complete -o default -o nospace -F _git_diff diff
+complete -o default -o nospace -F _git_fetch fetch
+complete -o default -o nospace -F _git_format_patch format-patch
+complete -o default -o nospace -F _git_gc gc
+complete -o default -o nospace -F _git_log log
+complete -o default -o nospace -F _git_ls_remote ls-remote
+complete -o default -o nospace -F _git_ls_tree ls-tree
+complete -o default -o nospace -F _git_merge merge
+complete -o default -o nospace -F _git_merge_base merge-base
+complete -o default -o nospace -F _git_name_rev name-rev
+complete -o default -o nospace -F _git_pull pull
+complete -o default -o nospace -F _git_push push
+complete -o default -o nospace -F _git_rebase rebase
+complete -o default -o nospace -F _git_config config
+complete -o default -o nospace -F _git_remote remote
+complete -o default -o nospace -F _git_reset reset
+complete -o default -o nospace -F _git_shortlog shortlog
+complete -o default -o nospace -F _git_show show
+complete -o default -o nospace -F _git_stash stash
+complete -o default -o nospace -F _git_submodule submodule
+complete -o default -o nospace -F _git_log show-branch
+complete -o default -o nospace -F _git_tag tag
+complete -o default -o nospace -F _git_log whatchanged
+
+# setup the prompt
+
+git_prompt_setup() {
+ br=$(git symbolic-ref HEAD 2>/dev/null)
+ br=${br#refs/heads/}
+ rel=$(git rev-parse --show-prefix 2>/dev/null)
+ rel="${rel%/}"
+ loc="${PWD%/$rel}"
+}
+
+git_prompt_plain() {
+ git_prompt_setup
+ PS1="git:$br!${loc/*\/}${rel:+/$rel}> "
+}
+
+git_prompt_color() {
+ git_prompt_setup
+ PS1="${BLACK}${ORANGE_BG}$br${PS_CLEAR}${GREY}!${PS_CLEAR}${LIGHT_BLUE}${loc/*\/}${rel:+/$rel}${PS_CLEAR}${GREY}>${PS_CLEAR} "
+}
+
+PROMPT_COMMAND=git_prompt_color
+
+# try to provide a decent help command
+
+_help_display() {
+ git --help
+ test -r ~/.gitshrc && {
+ printf "\nAliases from ~/.gitshrc\n"
+ cat ~/.gitshrc |
+ /usr/bin/grep -F alias |
+ perl -pe "s/alias //" |
+ perl -pe "s/=/\t\t\t/"
+ }
+}
+
+help() {
+ _help_display | ${PAGER:-less}
+}
57 gitshrc-example.bash
@@ -0,0 +1,57 @@
+# (@) ~rtomayko/.gitshrc
+
+alias commit='git commit -v'
+alias ci='git commit -v'
+alias ca='git commit -a'
+alias n='git commit -v --amend'
+complete -o default -o nospace -F _git_commit ci
+complete -o default -o nospace -F _git_commit ca
+complete -o default -o nospace -F _git_commit n
+
+alias a='git add'
+alias aa='git add -u'
+complete -o default -o nospace -F _git_add a
+complete -o default -o nospace -F _git_add aa
+
+alias c='git checkout'
+complete -o default -o nospace -F _git_checkout c
+
+alias f='git fetch'
+complete -o default -o nospace -F _git_fetch f
+
+alias r='git rebase -i HEAD~10'
+
+alias d='git diff'
+alias p='git diff --cached'
+complete -o default -o nospace -F _git_diff d
+complete -o default -o nospace -F _git_diff p
+
+
+alias s='git status'
+complete -o default -o nospace -F _git_status s
+
+alias L='git log'
+alias l='git log --pretty=oneline --abbrev-commit'
+alias l1='l -n1'
+alias l2='l -n2'
+alias l5='l -n5'
+alias l10='l -n10'
+alias ll='l -n10'
+
+complete -o default -o nospace -F _git_log L
+complete -o default -o nospace -F _git_log l
+complete -o default -o nospace -F _git_log l1
+complete -o default -o nospace -F _git_log l2
+complete -o default -o nospace -F _git_log l5
+complete -o default -o nospace -F _git_log l10
+complete -o default -o nospace -F _git_log ll
+
+alias mirror='git reset --hard'
+alias unstage='git reset HEAD'
+complete -o default -o nospace -F _git_reset mirror
+complete -o default -o nospace -F _git_reset unstage
+
+alias stage='git add'
+alias queue='git add'
+alias amend='git commit -v --amend'
+alias pop='git reset --soft HEAD^'
Please sign in to comment.
Something went wrong with that request. Please try again.