Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

some more files

  • Loading branch information...
commit 617dad8af6b64c360bbb148e80309a88339a24a2 1 parent 0230611
Konstantin Käfer authored December 09, 2010
56  .bash_profile
... ...
@@ -0,0 +1,56 @@
  1
+PS1="\u@\h:\w ▶ "
  2
+
  3
+export PATH="~/bin:~/.gem/ruby/1.8/bin:/usr/local/sbin:/usr/local/bin:$PATH"
  4
+
  5
+export DISPLAY=:0.0
  6
+export EDITOR='mate -w'
  7
+export LC_CTYPE=de_DE.UTF-8
  8
+export LC_MESSAGES=en_US.UTF-8
  9
+
  10
+NVM_DIR=$HOME/.nvm
  11
+. $NVM_DIR/nvm.sh
  12
+
  13
+alias start-servers='sudo apachectl start && sudo mysqlctl start'
  14
+alias stop-servers='sudo apachectl stop && sudo mysqlctl stop'
  15
+alias restart-servers='sudo apachectl restart && sudo mysqlctl restart'
  16
+
  17
+export CVSROOT=:pserver:timcn@cvs.drupal.org:/cvs/drupal-contrib
  18
+alias cvs-revert='cvs -q update -dPCR'
  19
+alias cvs-update='cvs -q update -dPR'
  20
+alias cvs-diff='cvs -q diff -udRNF^\\s*function'
  21
+alias cvs-patch='patch -p0'
  22
+
  23
+alias switch='svn switch $(svn info | grep "URL:" | sed "s/URL: //")'
  24
+alias svn-add-recursive="svn stat | grep "^?" | awk '{print $2}' | xargs svn add"
  25
+alias svn-clean="svn stat | grep "^?" | awk '{print $2}' | xargs rm -rf"
  26
+alias svnup='svn up'
  27
+
  28
+alias po-stat='msgfmt --statistics $1'
  29
+alias po-update='for i in *.po; do msgmerge --update $i ../drupal-pot/${i}t --no-wrap ; done'
  30
+alias po-status='for i in *.po; do echo -n "$i: " ; msgfmt --statistics $i ; done'
  31
+alias po-single='msgcat --use-first general.po [^g]*.po | msgattrib --no-fuzzy -o'
  32
+alias po-clean='for i in *.po; do msgattrib -o $i.no-o  --no-wrap --no-obsolete $i && mv $i.no-o $i; done'
  33
+
  34
+alias phplint='for i in `find . -name "*.inc" -o -name "*.module" -o -name "*.php"` ; do php -l $i ; done'
  35
+alias gr='egrep -l -r --exclude="*.svn*" --exclude="*.patch" --exclude=".#*"'
  36
+alias gre='egrep -n -r --colour --exclude="*.svn*" --exclude="*.patch" --exclude=".#*"'
  37
+alias header='wget -S --spider'
  38
+alias top='top -ocpu -R -F -s 2 -n30'
  39
+alias updatedb='sudo /usr/libexec/locate.updatedb'
  40
+alias finder='open -a /System/Library/CoreServices/Finder.app .'
  41
+alias flushdns='dscacheutil -flushcache'
  42
+alias release-notes='php ~/Repositories/HEAD/tricks/cvs-release-notes/cvs-release-notes.php'
  43
+alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport'
  44
+alias optipng-recurse='for i in `find . -name "*.png"` ; do optipng -o7 $i ; done'
  45
+alias jpegtran-recurse='for i in `find . -name "*.jpg" -o -name "*.jpeg"` ; do jpegtran -copy none -optimize $i > $i ; done'
  46
+alias stuck="ps ax | sed '1p;/ [U] /!d'"
  47
+alias cpwd="pwd | pbcopy"
  48
+alias lock="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
  49
+alias s='pmset sleepnow'
  50
+alias nr='rlwrap node-repl'
  51
+alias untar='ruby -e '"'"'exec "tar", "vx#{$*[0] =~ /gz$/?"z":"j"}f", $*[0]'"'"' -- '
  52
+
  53
+
  54
+complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
  55
+
  56
+source ~/git-completion.bash
1  .gitignore
... ...
@@ -0,0 +1 @@
  1
+.DS_Store
2,534  git-completion.bash
... ...
@@ -0,0 +1,2534 @@
  1
+#!bash
  2
+#
  3
+# bash completion support for core Git.
  4
+#
  5
+# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
  6
+# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
  7
+# Distributed under the GNU General Public License, version 2.0.
  8
+#
  9
+# The contained completion routines provide support for completing:
  10
+#
  11
+#    *) local and remote branch names
  12
+#    *) local and remote tag names
  13
+#    *) .git/remotes file names
  14
+#    *) git 'subcommands'
  15
+#    *) tree paths within 'ref:path/to/file' expressions
  16
+#    *) common --long-options
  17
+#
  18
+# To use these routines:
  19
+#
  20
+#    1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
  21
+#    2) Added the following line to your .bashrc:
  22
+#        source ~/.git-completion.sh
  23
+#
  24
+#       Or, add the following lines to your .zshrc:
  25
+#        autoload bashcompinit
  26
+#        bashcompinit
  27
+#        source ~/.git-completion.sh
  28
+#
  29
+#    3) Consider changing your PS1 to also show the current branch:
  30
+#        PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
  31
+#
  32
+#       The argument to __git_ps1 will be displayed only if you
  33
+#       are currently in a git repository.  The %s token will be
  34
+#       the name of the current branch.
  35
+#
  36
+#       In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
  37
+#       value, unstaged (*) and staged (+) changes will be shown next
  38
+#       to the branch name.  You can configure this per-repository
  39
+#       with the bash.showDirtyState variable, which defaults to true
  40
+#       once GIT_PS1_SHOWDIRTYSTATE is enabled.
  41
+#
  42
+#       You can also see if currently something is stashed, by setting
  43
+#       GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
  44
+#       then a '$' will be shown next to the branch name.
  45
+#
  46
+#       If you would like to see if there're untracked files, then you can
  47
+#       set GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're
  48
+#       untracked files, then a '%' will be shown next to the branch name.
  49
+#
  50
+#       If you would like to see the difference between HEAD and its
  51
+#       upstream, set GIT_PS1_SHOWUPSTREAM="auto".  A "<" indicates
  52
+#       you are behind, ">" indicates you are ahead, and "<>"
  53
+#       indicates you have diverged.  You can further control
  54
+#       behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated
  55
+#       list of values:
  56
+#           verbose       show number of commits ahead/behind (+/-) upstream
  57
+#           legacy        don't use the '--count' option available in recent
  58
+#                         versions of git-rev-list
  59
+#           git           always compare HEAD to @{upstream}
  60
+#           svn           always compare HEAD to your SVN upstream
  61
+#       By default, __git_ps1 will compare HEAD to your SVN upstream
  62
+#       if it can find one, or @{upstream} otherwise.  Once you have
  63
+#       set GIT_PS1_SHOWUPSTREAM, you can override it on a
  64
+#       per-repository basis by setting the bash.showUpstream config
  65
+#       variable.
  66
+#
  67
+#
  68
+# To submit patches:
  69
+#
  70
+#    *) Read Documentation/SubmittingPatches
  71
+#    *) Send all patches to the current maintainer:
  72
+#
  73
+#       "Shawn O. Pearce" <spearce@spearce.org>
  74
+#
  75
+#    *) Always CC the Git mailing list:
  76
+#
  77
+#       git@vger.kernel.org
  78
+#
  79
+
  80
+case "$COMP_WORDBREAKS" in
  81
+*:*) : great ;;
  82
+*)   COMP_WORDBREAKS="$COMP_WORDBREAKS:"
  83
+esac
  84
+
  85
+# __gitdir accepts 0 or 1 arguments (i.e., location)
  86
+# returns location of .git repo
  87
+__gitdir ()
  88
+{
  89
+	if [ -z "${1-}" ]; then
  90
+		if [ -n "${__git_dir-}" ]; then
  91
+			echo "$__git_dir"
  92
+		elif [ -d .git ]; then
  93
+			echo .git
  94
+		else
  95
+			git rev-parse --git-dir 2>/dev/null
  96
+		fi
  97
+	elif [ -d "$1/.git" ]; then
  98
+		echo "$1/.git"
  99
+	else
  100
+		echo "$1"
  101
+	fi
  102
+}
  103
+
  104
+# stores the divergence from upstream in $p
  105
+# used by GIT_PS1_SHOWUPSTREAM
  106
+__git_ps1_show_upstream ()
  107
+{
  108
+	local key value
  109
+	local svn_remote=() svn_url_pattern count n
  110
+	local upstream=git legacy="" verbose=""
  111
+
  112
+	# get some config options from git-config
  113
+	while read key value; do
  114
+		case "$key" in
  115
+		bash.showupstream)
  116
+			GIT_PS1_SHOWUPSTREAM="$value"
  117
+			if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
  118
+				p=""
  119
+				return
  120
+			fi
  121
+			;;
  122
+		svn-remote.*.url)
  123
+			svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value"
  124
+			svn_url_pattern+="\\|$value"
  125
+			upstream=svn+git # default upstream is SVN if available, else git
  126
+			;;
  127
+		esac
  128
+	done < <(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')
  129
+
  130
+	# parse configuration values
  131
+	for option in ${GIT_PS1_SHOWUPSTREAM}; do
  132
+		case "$option" in
  133
+		git|svn) upstream="$option" ;;
  134
+		verbose) verbose=1 ;;
  135
+		legacy)  legacy=1  ;;
  136
+		esac
  137
+	done
  138
+
  139
+	# Find our upstream
  140
+	case "$upstream" in
  141
+	git)    upstream="@{upstream}" ;;
  142
+	svn*)
  143
+		# get the upstream from the "git-svn-id: ..." in a commit message
  144
+		# (git-svn uses essentially the same procedure internally)
  145
+		local svn_upstream=($(git log --first-parent -1 \
  146
+					--grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
  147
+		if [[ 0 -ne ${#svn_upstream[@]} ]]; then
  148
+			svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
  149
+			svn_upstream=${svn_upstream%@*}
  150
+			local n_stop="${#svn_remote[@]}"
  151
+			for ((n=1; n <= n_stop; ++n)); do
  152
+				svn_upstream=${svn_upstream#${svn_remote[$n]}}
  153
+			done
  154
+
  155
+			if [[ -z "$svn_upstream" ]]; then
  156
+				# default branch name for checkouts with no layout:
  157
+				upstream=${GIT_SVN_ID:-git-svn}
  158
+			else
  159
+				upstream=${svn_upstream#/}
  160
+			fi
  161
+		elif [[ "svn+git" = "$upstream" ]]; then
  162
+			upstream="@{upstream}"
  163
+		fi
  164
+		;;
  165
+	esac
  166
+
  167
+	# Find how many commits we are ahead/behind our upstream
  168
+	if [[ -z "$legacy" ]]; then
  169
+		count="$(git rev-list --count --left-right \
  170
+				"$upstream"...HEAD 2>/dev/null)"
  171
+	else
  172
+		# produce equivalent output to --count for older versions of git
  173
+		local commits
  174
+		if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"
  175
+		then
  176
+			local commit behind=0 ahead=0
  177
+			for commit in $commits
  178
+			do
  179
+				case "$commit" in
  180
+				"<"*) let ++behind
  181
+					;;
  182
+				*)    let ++ahead
  183
+					;;
  184
+				esac
  185
+			done
  186
+			count="$behind	$ahead"
  187
+		else
  188
+			count=""
  189
+		fi
  190
+	fi
  191
+
  192
+	# calculate the result
  193
+	if [[ -z "$verbose" ]]; then
  194
+		case "$count" in
  195
+		"") # no upstream
  196
+			p="" ;;
  197
+		"0	0") # equal to upstream
  198
+			p="=" ;;
  199
+		"0	"*) # ahead of upstream
  200
+			p=">" ;;
  201
+		*"	0") # behind upstream
  202
+			p="<" ;;
  203
+		*)	    # diverged from upstream
  204
+			p="<>" ;;
  205
+		esac
  206
+	else
  207
+		case "$count" in
  208
+		"") # no upstream
  209
+			p="" ;;
  210
+		"0	0") # equal to upstream
  211
+			p=" u=" ;;
  212
+		"0	"*) # ahead of upstream
  213
+			p=" u+${count#0	}" ;;
  214
+		*"	0") # behind upstream
  215
+			p=" u-${count%	0}" ;;
  216
+		*)	    # diverged from upstream
  217
+			p=" u+${count#*	}-${count%	*}" ;;
  218
+		esac
  219
+	fi
  220
+
  221
+}
  222
+
  223
+
  224
+# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
  225
+# returns text to add to bash PS1 prompt (includes branch name)
  226
+__git_ps1 ()
  227
+{
  228
+	local g="$(__gitdir)"
  229
+	if [ -n "$g" ]; then
  230
+		local r=""
  231
+		local b=""
  232
+		if [ -f "$g/rebase-merge/interactive" ]; then
  233
+			r="|REBASE-i"
  234
+			b="$(cat "$g/rebase-merge/head-name")"
  235
+		elif [ -d "$g/rebase-merge" ]; then
  236
+			r="|REBASE-m"
  237
+			b="$(cat "$g/rebase-merge/head-name")"
  238
+		else
  239
+			if [ -d "$g/rebase-apply" ]; then
  240
+				if [ -f "$g/rebase-apply/rebasing" ]; then
  241
+					r="|REBASE"
  242
+				elif [ -f "$g/rebase-apply/applying" ]; then
  243
+					r="|AM"
  244
+				else
  245
+					r="|AM/REBASE"
  246
+				fi
  247
+			elif [ -f "$g/MERGE_HEAD" ]; then
  248
+				r="|MERGING"
  249
+			elif [ -f "$g/BISECT_LOG" ]; then
  250
+				r="|BISECTING"
  251
+			fi
  252
+
  253
+			b="$(git symbolic-ref HEAD 2>/dev/null)" || {
  254
+
  255
+				b="$(
  256
+				case "${GIT_PS1_DESCRIBE_STYLE-}" in
  257
+				(contains)
  258
+					git describe --contains HEAD ;;
  259
+				(branch)
  260
+					git describe --contains --all HEAD ;;
  261
+				(describe)
  262
+					git describe HEAD ;;
  263
+				(* | default)
  264
+					git describe --tags --exact-match HEAD ;;
  265
+				esac 2>/dev/null)" ||
  266
+
  267
+				b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
  268
+				b="unknown"
  269
+				b="($b)"
  270
+			}
  271
+		fi
  272
+
  273
+		local w=""
  274
+		local i=""
  275
+		local s=""
  276
+		local u=""
  277
+		local c=""
  278
+		local p=""
  279
+
  280
+		if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
  281
+			if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
  282
+				c="BARE:"
  283
+			else
  284
+				b="GIT_DIR!"
  285
+			fi
  286
+		elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
  287
+			if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
  288
+				if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then
  289
+					git diff --no-ext-diff --quiet --exit-code || w="*"
  290
+					if git rev-parse --quiet --verify HEAD >/dev/null; then
  291
+						git diff-index --cached --quiet HEAD -- || i="+"
  292
+					else
  293
+						i="#"
  294
+					fi
  295
+				fi
  296
+			fi
  297
+			if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
  298
+			        git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
  299
+			fi
  300
+
  301
+			if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
  302
+			   if [ -n "$(git ls-files --others --exclude-standard)" ]; then
  303
+			      u="%"
  304
+			   fi
  305
+			fi
  306
+
  307
+			if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
  308
+				__git_ps1_show_upstream
  309
+			fi
  310
+		fi
  311
+
  312
+		local f="$w$i$s$u"
  313
+		printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
  314
+	fi
  315
+}
  316
+
  317
+# __gitcomp_1 requires 2 arguments
  318
+__gitcomp_1 ()
  319
+{
  320
+	local c IFS=' '$'\t'$'\n'
  321
+	for c in $1; do
  322
+		case "$c$2" in
  323
+		--*=*) printf %s$'\n' "$c$2" ;;
  324
+		*.)    printf %s$'\n' "$c$2" ;;
  325
+		*)     printf %s$'\n' "$c$2 " ;;
  326
+		esac
  327
+	done
  328
+}
  329
+
  330
+# __gitcomp accepts 1, 2, 3, or 4 arguments
  331
+# generates completion reply with compgen
  332
+__gitcomp ()
  333
+{
  334
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  335
+	if [ $# -gt 2 ]; then
  336
+		cur="$3"
  337
+	fi
  338
+	case "$cur" in
  339
+	--*=)
  340
+		COMPREPLY=()
  341
+		;;
  342
+	*)
  343
+		local IFS=$'\n'
  344
+		COMPREPLY=($(compgen -P "${2-}" \
  345
+			-W "$(__gitcomp_1 "${1-}" "${4-}")" \
  346
+			-- "$cur"))
  347
+		;;
  348
+	esac
  349
+}
  350
+
  351
+# __git_heads accepts 0 or 1 arguments (to pass to __gitdir)
  352
+__git_heads ()
  353
+{
  354
+	local cmd i is_hash=y dir="$(__gitdir "${1-}")"
  355
+	if [ -d "$dir" ]; then
  356
+		git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
  357
+			refs/heads
  358
+		return
  359
+	fi
  360
+	for i in $(git ls-remote "${1-}" 2>/dev/null); do
  361
+		case "$is_hash,$i" in
  362
+		y,*) is_hash=n ;;
  363
+		n,*^{}) is_hash=y ;;
  364
+		n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
  365
+		n,*) is_hash=y; echo "$i" ;;
  366
+		esac
  367
+	done
  368
+}
  369
+
  370
+# __git_tags accepts 0 or 1 arguments (to pass to __gitdir)
  371
+__git_tags ()
  372
+{
  373
+	local cmd i is_hash=y dir="$(__gitdir "${1-}")"
  374
+	if [ -d "$dir" ]; then
  375
+		git --git-dir="$dir" for-each-ref --format='%(refname:short)' \
  376
+			refs/tags
  377
+		return
  378
+	fi
  379
+	for i in $(git ls-remote "${1-}" 2>/dev/null); do
  380
+		case "$is_hash,$i" in
  381
+		y,*) is_hash=n ;;
  382
+		n,*^{}) is_hash=y ;;
  383
+		n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
  384
+		n,*) is_hash=y; echo "$i" ;;
  385
+		esac
  386
+	done
  387
+}
  388
+
  389
+# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments
  390
+# presence of 2nd argument means use the guess heuristic employed
  391
+# by checkout for tracking branches
  392
+__git_refs ()
  393
+{
  394
+	local i is_hash=y dir="$(__gitdir "${1-}")" track="${2-}"
  395
+	local cur="${COMP_WORDS[COMP_CWORD]}" format refs
  396
+	if [ -d "$dir" ]; then
  397
+		case "$cur" in
  398
+		refs|refs/*)
  399
+			format="refname"
  400
+			refs="${cur%/*}"
  401
+			track=""
  402
+			;;
  403
+		*)
  404
+			for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
  405
+				if [ -e "$dir/$i" ]; then echo $i; fi
  406
+			done
  407
+			format="refname:short"
  408
+			refs="refs/tags refs/heads refs/remotes"
  409
+			;;
  410
+		esac
  411
+		git --git-dir="$dir" for-each-ref --format="%($format)" \
  412
+			$refs
  413
+		if [ -n "$track" ]; then
  414
+			# employ the heuristic used by git checkout
  415
+			# Try to find a remote branch that matches the completion word
  416
+			# but only output if the branch name is unique
  417
+			local ref entry
  418
+			git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \
  419
+				"refs/remotes/" | \
  420
+			while read entry; do
  421
+				eval "$entry"
  422
+				ref="${ref#*/}"
  423
+				if [[ "$ref" == "$cur"* ]]; then
  424
+					echo "$ref"
  425
+				fi
  426
+			done | uniq -u
  427
+		fi
  428
+		return
  429
+	fi
  430
+	for i in $(git ls-remote "$dir" 2>/dev/null); do
  431
+		case "$is_hash,$i" in
  432
+		y,*) is_hash=n ;;
  433
+		n,*^{}) is_hash=y ;;
  434
+		n,refs/tags/*) is_hash=y; echo "${i#refs/tags/}" ;;
  435
+		n,refs/heads/*) is_hash=y; echo "${i#refs/heads/}" ;;
  436
+		n,refs/remotes/*) is_hash=y; echo "${i#refs/remotes/}" ;;
  437
+		n,*) is_hash=y; echo "$i" ;;
  438
+		esac
  439
+	done
  440
+}
  441
+
  442
+# __git_refs2 requires 1 argument (to pass to __git_refs)
  443
+__git_refs2 ()
  444
+{
  445
+	local i
  446
+	for i in $(__git_refs "$1"); do
  447
+		echo "$i:$i"
  448
+	done
  449
+}
  450
+
  451
+# __git_refs_remotes requires 1 argument (to pass to ls-remote)
  452
+__git_refs_remotes ()
  453
+{
  454
+	local cmd i is_hash=y
  455
+	for i in $(git ls-remote "$1" 2>/dev/null); do
  456
+		case "$is_hash,$i" in
  457
+		n,refs/heads/*)
  458
+			is_hash=y
  459
+			echo "$i:refs/remotes/$1/${i#refs/heads/}"
  460
+			;;
  461
+		y,*) is_hash=n ;;
  462
+		n,*^{}) is_hash=y ;;
  463
+		n,refs/tags/*) is_hash=y;;
  464
+		n,*) is_hash=y; ;;
  465
+		esac
  466
+	done
  467
+}
  468
+
  469
+__git_remotes ()
  470
+{
  471
+	local i ngoff IFS=$'\n' d="$(__gitdir)"
  472
+	shopt -q nullglob || ngoff=1
  473
+	shopt -s nullglob
  474
+	for i in "$d/remotes"/*; do
  475
+		echo ${i#$d/remotes/}
  476
+	done
  477
+	[ "$ngoff" ] && shopt -u nullglob
  478
+	for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
  479
+		i="${i#remote.}"
  480
+		echo "${i/.url*/}"
  481
+	done
  482
+}
  483
+
  484
+__git_list_merge_strategies ()
  485
+{
  486
+	git merge -s help 2>&1 |
  487
+	sed -n -e '/[Aa]vailable strategies are: /,/^$/{
  488
+		s/\.$//
  489
+		s/.*://
  490
+		s/^[ 	]*//
  491
+		s/[ 	]*$//
  492
+		p
  493
+	}'
  494
+}
  495
+
  496
+__git_merge_strategies=
  497
+# 'git merge -s help' (and thus detection of the merge strategy
  498
+# list) fails, unfortunately, if run outside of any git working
  499
+# tree.  __git_merge_strategies is set to the empty string in
  500
+# that case, and the detection will be repeated the next time it
  501
+# is needed.
  502
+__git_compute_merge_strategies ()
  503
+{
  504
+	: ${__git_merge_strategies:=$(__git_list_merge_strategies)}
  505
+}
  506
+
  507
+__git_complete_file ()
  508
+{
  509
+	local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
  510
+	case "$cur" in
  511
+	?*:*)
  512
+		ref="${cur%%:*}"
  513
+		cur="${cur#*:}"
  514
+		case "$cur" in
  515
+		?*/*)
  516
+			pfx="${cur%/*}"
  517
+			cur="${cur##*/}"
  518
+			ls="$ref:$pfx"
  519
+			pfx="$pfx/"
  520
+			;;
  521
+		*)
  522
+			ls="$ref"
  523
+			;;
  524
+	    esac
  525
+
  526
+		case "$COMP_WORDBREAKS" in
  527
+		*:*) : great ;;
  528
+		*)   pfx="$ref:$pfx" ;;
  529
+		esac
  530
+
  531
+		local IFS=$'\n'
  532
+		COMPREPLY=($(compgen -P "$pfx" \
  533
+			-W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
  534
+				| sed '/^100... blob /{
  535
+				           s,^.*	,,
  536
+				           s,$, ,
  537
+				       }
  538
+				       /^120000 blob /{
  539
+				           s,^.*	,,
  540
+				           s,$, ,
  541
+				       }
  542
+				       /^040000 tree /{
  543
+				           s,^.*	,,
  544
+				           s,$,/,
  545
+				       }
  546
+				       s/^.*	//')" \
  547
+			-- "$cur"))
  548
+		;;
  549
+	*)
  550
+		__gitcomp "$(__git_refs)"
  551
+		;;
  552
+	esac
  553
+}
  554
+
  555
+__git_complete_revlist ()
  556
+{
  557
+	local pfx cur="${COMP_WORDS[COMP_CWORD]}"
  558
+	case "$cur" in
  559
+	*...*)
  560
+		pfx="${cur%...*}..."
  561
+		cur="${cur#*...}"
  562
+		__gitcomp "$(__git_refs)" "$pfx" "$cur"
  563
+		;;
  564
+	*..*)
  565
+		pfx="${cur%..*}.."
  566
+		cur="${cur#*..}"
  567
+		__gitcomp "$(__git_refs)" "$pfx" "$cur"
  568
+		;;
  569
+	*)
  570
+		__gitcomp "$(__git_refs)"
  571
+		;;
  572
+	esac
  573
+}
  574
+
  575
+__git_complete_remote_or_refspec ()
  576
+{
  577
+	local cmd="${COMP_WORDS[1]}"
  578
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  579
+	local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
  580
+	while [ $c -lt $COMP_CWORD ]; do
  581
+		i="${COMP_WORDS[c]}"
  582
+		case "$i" in
  583
+		--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
  584
+		--all)
  585
+			case "$cmd" in
  586
+			push) no_complete_refspec=1 ;;
  587
+			fetch)
  588
+				COMPREPLY=()
  589
+				return
  590
+				;;
  591
+			*) ;;
  592
+			esac
  593
+			;;
  594
+		-*) ;;
  595
+		*) remote="$i"; break ;;
  596
+		esac
  597
+		c=$((++c))
  598
+	done
  599
+	if [ -z "$remote" ]; then
  600
+		__gitcomp "$(__git_remotes)"
  601
+		return
  602
+	fi
  603
+	if [ $no_complete_refspec = 1 ]; then
  604
+		COMPREPLY=()
  605
+		return
  606
+	fi
  607
+	[ "$remote" = "." ] && remote=
  608
+	case "$cur" in
  609
+	*:*)
  610
+		case "$COMP_WORDBREAKS" in
  611
+		*:*) : great ;;
  612
+		*)   pfx="${cur%%:*}:" ;;
  613
+		esac
  614
+		cur="${cur#*:}"
  615
+		lhs=0
  616
+		;;
  617
+	+*)
  618
+		pfx="+"
  619
+		cur="${cur#+}"
  620
+		;;
  621
+	esac
  622
+	case "$cmd" in
  623
+	fetch)
  624
+		if [ $lhs = 1 ]; then
  625
+			__gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
  626
+		else
  627
+			__gitcomp "$(__git_refs)" "$pfx" "$cur"
  628
+		fi
  629
+		;;
  630
+	pull)
  631
+		if [ $lhs = 1 ]; then
  632
+			__gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
  633
+		else
  634
+			__gitcomp "$(__git_refs)" "$pfx" "$cur"
  635
+		fi
  636
+		;;
  637
+	push)
  638
+		if [ $lhs = 1 ]; then
  639
+			__gitcomp "$(__git_refs)" "$pfx" "$cur"
  640
+		else
  641
+			__gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
  642
+		fi
  643
+		;;
  644
+	esac
  645
+}
  646
+
  647
+__git_complete_strategy ()
  648
+{
  649
+	__git_compute_merge_strategies
  650
+	case "${COMP_WORDS[COMP_CWORD-1]}" in
  651
+	-s|--strategy)
  652
+		__gitcomp "$__git_merge_strategies"
  653
+		return 0
  654
+	esac
  655
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  656
+	case "$cur" in
  657
+	--strategy=*)
  658
+		__gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
  659
+		return 0
  660
+		;;
  661
+	esac
  662
+	return 1
  663
+}
  664
+
  665
+__git_list_all_commands ()
  666
+{
  667
+	local i IFS=" "$'\n'
  668
+	for i in $(git help -a|egrep '^  [a-zA-Z0-9]')
  669
+	do
  670
+		case $i in
  671
+		*--*)             : helper pattern;;
  672
+		*) echo $i;;
  673
+		esac
  674
+	done
  675
+}
  676
+
  677
+__git_all_commands=
  678
+__git_compute_all_commands ()
  679
+{
  680
+	: ${__git_all_commands:=$(__git_list_all_commands)}
  681
+}
  682
+
  683
+__git_list_porcelain_commands ()
  684
+{
  685
+	local i IFS=" "$'\n'
  686
+	__git_compute_all_commands
  687
+	for i in "help" $__git_all_commands
  688
+	do
  689
+		case $i in
  690
+		*--*)             : helper pattern;;
  691
+		applymbox)        : ask gittus;;
  692
+		applypatch)       : ask gittus;;
  693
+		archimport)       : import;;
  694
+		cat-file)         : plumbing;;
  695
+		check-attr)       : plumbing;;
  696
+		check-ref-format) : plumbing;;
  697
+		checkout-index)   : plumbing;;
  698
+		commit-tree)      : plumbing;;
  699
+		count-objects)    : infrequent;;
  700
+		cvsexportcommit)  : export;;
  701
+		cvsimport)        : import;;
  702
+		cvsserver)        : daemon;;
  703
+		daemon)           : daemon;;
  704
+		diff-files)       : plumbing;;
  705
+		diff-index)       : plumbing;;
  706
+		diff-tree)        : plumbing;;
  707
+		fast-import)      : import;;
  708
+		fast-export)      : export;;
  709
+		fsck-objects)     : plumbing;;
  710
+		fetch-pack)       : plumbing;;
  711
+		fmt-merge-msg)    : plumbing;;
  712
+		for-each-ref)     : plumbing;;
  713
+		hash-object)      : plumbing;;
  714
+		http-*)           : transport;;
  715
+		index-pack)       : plumbing;;
  716
+		init-db)          : deprecated;;
  717
+		local-fetch)      : plumbing;;
  718
+		lost-found)       : infrequent;;
  719
+		ls-files)         : plumbing;;
  720
+		ls-remote)        : plumbing;;
  721
+		ls-tree)          : plumbing;;
  722
+		mailinfo)         : plumbing;;
  723
+		mailsplit)        : plumbing;;
  724
+		merge-*)          : plumbing;;
  725
+		mktree)           : plumbing;;
  726
+		mktag)            : plumbing;;
  727
+		pack-objects)     : plumbing;;
  728
+		pack-redundant)   : plumbing;;
  729
+		pack-refs)        : plumbing;;
  730
+		parse-remote)     : plumbing;;
  731
+		patch-id)         : plumbing;;
  732
+		peek-remote)      : plumbing;;
  733
+		prune)            : plumbing;;
  734
+		prune-packed)     : plumbing;;
  735
+		quiltimport)      : import;;
  736
+		read-tree)        : plumbing;;
  737
+		receive-pack)     : plumbing;;
  738
+		reflog)           : plumbing;;
  739
+		remote-*)         : transport;;
  740
+		repo-config)      : deprecated;;
  741
+		rerere)           : plumbing;;
  742
+		rev-list)         : plumbing;;
  743
+		rev-parse)        : plumbing;;
  744
+		runstatus)        : plumbing;;
  745
+		sh-setup)         : internal;;
  746
+		shell)            : daemon;;
  747
+		show-ref)         : plumbing;;
  748
+		send-pack)        : plumbing;;
  749
+		show-index)       : plumbing;;
  750
+		ssh-*)            : transport;;
  751
+		stripspace)       : plumbing;;
  752
+		symbolic-ref)     : plumbing;;
  753
+		tar-tree)         : deprecated;;
  754
+		unpack-file)      : plumbing;;
  755
+		unpack-objects)   : plumbing;;
  756
+		update-index)     : plumbing;;
  757
+		update-ref)       : plumbing;;
  758
+		update-server-info) : daemon;;
  759
+		upload-archive)   : plumbing;;
  760
+		upload-pack)      : plumbing;;
  761
+		write-tree)       : plumbing;;
  762
+		var)              : infrequent;;
  763
+		verify-pack)      : infrequent;;
  764
+		verify-tag)       : plumbing;;
  765
+		*) echo $i;;
  766
+		esac
  767
+	done
  768
+}
  769
+
  770
+__git_porcelain_commands=
  771
+__git_compute_porcelain_commands ()
  772
+{
  773
+	__git_compute_all_commands
  774
+	: ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
  775
+}
  776
+
  777
+__git_pretty_aliases ()
  778
+{
  779
+	local i IFS=$'\n'
  780
+	for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); do
  781
+		case "$i" in
  782
+		pretty.*)
  783
+			i="${i#pretty.}"
  784
+			echo "${i/ */}"
  785
+			;;
  786
+		esac
  787
+	done
  788
+}
  789
+
  790
+__git_aliases ()
  791
+{
  792
+	local i IFS=$'\n'
  793
+	for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); do
  794
+		case "$i" in
  795
+		alias.*)
  796
+			i="${i#alias.}"
  797
+			echo "${i/ */}"
  798
+			;;
  799
+		esac
  800
+	done
  801
+}
  802
+
  803
+# __git_aliased_command requires 1 argument
  804
+__git_aliased_command ()
  805
+{
  806
+	local word cmdline=$(git --git-dir="$(__gitdir)" \
  807
+		config --get "alias.$1")
  808
+	for word in $cmdline; do
  809
+		case "$word" in
  810
+		\!gitk|gitk)
  811
+			echo "gitk"
  812
+			return
  813
+			;;
  814
+		\!*)	: shell command alias ;;
  815
+		-*)	: option ;;
  816
+		*=*)	: setting env ;;
  817
+		git)	: git itself ;;
  818
+		*)
  819
+			echo "$word"
  820
+			return
  821
+		esac
  822
+	done
  823
+}
  824
+
  825
+# __git_find_on_cmdline requires 1 argument
  826
+__git_find_on_cmdline ()
  827
+{
  828
+	local word subcommand c=1
  829
+
  830
+	while [ $c -lt $COMP_CWORD ]; do
  831
+		word="${COMP_WORDS[c]}"
  832
+		for subcommand in $1; do
  833
+			if [ "$subcommand" = "$word" ]; then
  834
+				echo "$subcommand"
  835
+				return
  836
+			fi
  837
+		done
  838
+		c=$((++c))
  839
+	done
  840
+}
  841
+
  842
+__git_has_doubledash ()
  843
+{
  844
+	local c=1
  845
+	while [ $c -lt $COMP_CWORD ]; do
  846
+		if [ "--" = "${COMP_WORDS[c]}" ]; then
  847
+			return 0
  848
+		fi
  849
+		c=$((++c))
  850
+	done
  851
+	return 1
  852
+}
  853
+
  854
+__git_whitespacelist="nowarn warn error error-all fix"
  855
+
  856
+_git_am ()
  857
+{
  858
+	local cur="${COMP_WORDS[COMP_CWORD]}" dir="$(__gitdir)"
  859
+	if [ -d "$dir"/rebase-apply ]; then
  860
+		__gitcomp "--skip --continue --resolved --abort"
  861
+		return
  862
+	fi
  863
+	case "$cur" in
  864
+	--whitespace=*)
  865
+		__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
  866
+		return
  867
+		;;
  868
+	--*)
  869
+		__gitcomp "
  870
+			--3way --committer-date-is-author-date --ignore-date
  871
+			--ignore-whitespace --ignore-space-change
  872
+			--interactive --keep --no-utf8 --signoff --utf8
  873
+			--whitespace= --scissors
  874
+			"
  875
+		return
  876
+	esac
  877
+	COMPREPLY=()
  878
+}
  879
+
  880
+_git_apply ()
  881
+{
  882
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  883
+	case "$cur" in
  884
+	--whitespace=*)
  885
+		__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
  886
+		return
  887
+		;;
  888
+	--*)
  889
+		__gitcomp "
  890
+			--stat --numstat --summary --check --index
  891
+			--cached --index-info --reverse --reject --unidiff-zero
  892
+			--apply --no-add --exclude=
  893
+			--ignore-whitespace --ignore-space-change
  894
+			--whitespace= --inaccurate-eof --verbose
  895
+			"
  896
+		return
  897
+	esac
  898
+	COMPREPLY=()
  899
+}
  900
+
  901
+_git_add ()
  902
+{
  903
+	__git_has_doubledash && return
  904
+
  905
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  906
+	case "$cur" in
  907
+	--*)
  908
+		__gitcomp "
  909
+			--interactive --refresh --patch --update --dry-run
  910
+			--ignore-errors --intent-to-add
  911
+			"
  912
+		return
  913
+	esac
  914
+	COMPREPLY=()
  915
+}
  916
+
  917
+_git_archive ()
  918
+{
  919
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  920
+	case "$cur" in
  921
+	--format=*)
  922
+		__gitcomp "$(git archive --list)" "" "${cur##--format=}"
  923
+		return
  924
+		;;
  925
+	--remote=*)
  926
+		__gitcomp "$(__git_remotes)" "" "${cur##--remote=}"
  927
+		return
  928
+		;;
  929
+	--*)
  930
+		__gitcomp "
  931
+			--format= --list --verbose
  932
+			--prefix= --remote= --exec=
  933
+			"
  934
+		return
  935
+		;;
  936
+	esac
  937
+	__git_complete_file
  938
+}
  939
+
  940
+_git_bisect ()
  941
+{
  942
+	__git_has_doubledash && return
  943
+
  944
+	local subcommands="start bad good skip reset visualize replay log run"
  945
+	local subcommand="$(__git_find_on_cmdline "$subcommands")"
  946
+	if [ -z "$subcommand" ]; then
  947
+		if [ -f "$(__gitdir)"/BISECT_START ]; then
  948
+			__gitcomp "$subcommands"
  949
+		else
  950
+			__gitcomp "replay start"
  951
+		fi
  952
+		return
  953
+	fi
  954
+
  955
+	case "$subcommand" in
  956
+	bad|good|reset|skip|start)
  957
+		__gitcomp "$(__git_refs)"
  958
+		;;
  959
+	*)
  960
+		COMPREPLY=()
  961
+		;;
  962
+	esac
  963
+}
  964
+
  965
+_git_branch ()
  966
+{
  967
+	local i c=1 only_local_ref="n" has_r="n"
  968
+
  969
+	while [ $c -lt $COMP_CWORD ]; do
  970
+		i="${COMP_WORDS[c]}"
  971
+		case "$i" in
  972
+		-d|-m)	only_local_ref="y" ;;
  973
+		-r)	has_r="y" ;;
  974
+		esac
  975
+		c=$((++c))
  976
+	done
  977
+
  978
+	case "${COMP_WORDS[COMP_CWORD]}" in
  979
+	--*)
  980
+		__gitcomp "
  981
+			--color --no-color --verbose --abbrev= --no-abbrev
  982
+			--track --no-track --contains --merged --no-merged
  983
+			--set-upstream
  984
+			"
  985
+		;;
  986
+	*)
  987
+		if [ $only_local_ref = "y" -a $has_r = "n" ]; then
  988
+			__gitcomp "$(__git_heads)"
  989
+		else
  990
+			__gitcomp "$(__git_refs)"
  991
+		fi
  992
+		;;
  993
+	esac
  994
+}
  995
+
  996
+_git_bundle ()
  997
+{
  998
+	local cmd="${COMP_WORDS[2]}"
  999
+	case "$COMP_CWORD" in
  1000
+	2)
  1001
+		__gitcomp "create list-heads verify unbundle"
  1002
+		;;
  1003
+	3)
  1004
+		# looking for a file
  1005
+		;;
  1006
+	*)
  1007
+		case "$cmd" in
  1008
+			create)
  1009
+				__git_complete_revlist
  1010
+			;;
  1011
+		esac
  1012
+		;;
  1013
+	esac
  1014
+}
  1015
+
  1016
+_git_checkout ()
  1017
+{
  1018
+	__git_has_doubledash && return
  1019
+
  1020
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  1021
+	case "$cur" in
  1022
+	--conflict=*)
  1023
+		__gitcomp "diff3 merge" "" "${cur##--conflict=}"
  1024
+		;;
  1025
+	--*)
  1026
+		__gitcomp "
  1027
+			--quiet --ours --theirs --track --no-track --merge
  1028
+			--conflict= --orphan --patch
  1029
+			"
  1030
+		;;
  1031
+	*)
  1032
+		# check if --track, --no-track, or --no-guess was specified
  1033
+		# if so, disable DWIM mode
  1034
+		local flags="--track --no-track --no-guess" track=1
  1035
+		if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
  1036
+			track=''
  1037
+		fi
  1038
+		__gitcomp "$(__git_refs '' $track)"
  1039
+		;;
  1040
+	esac
  1041
+}
  1042
+
  1043
+_git_cherry ()
  1044
+{
  1045
+	__gitcomp "$(__git_refs)"
  1046
+}
  1047
+
  1048
+_git_cherry_pick ()
  1049
+{
  1050
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  1051
+	case "$cur" in
  1052
+	--*)
  1053
+		__gitcomp "--edit --no-commit"
  1054
+		;;
  1055
+	*)
  1056
+		__gitcomp "$(__git_refs)"
  1057
+		;;
  1058
+	esac
  1059
+}
  1060
+
  1061
+_git_clean ()
  1062
+{
  1063
+	__git_has_doubledash && return
  1064
+
  1065
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  1066
+	case "$cur" in
  1067
+	--*)
  1068
+		__gitcomp "--dry-run --quiet"
  1069
+		return
  1070
+		;;
  1071
+	esac
  1072
+	COMPREPLY=()
  1073
+}
  1074
+
  1075
+_git_clone ()
  1076
+{
  1077
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  1078
+	case "$cur" in
  1079
+	--*)
  1080
+		__gitcomp "
  1081
+			--local
  1082
+			--no-hardlinks
  1083
+			--shared
  1084
+			--reference
  1085
+			--quiet
  1086
+			--no-checkout
  1087
+			--bare
  1088
+			--mirror
  1089
+			--origin
  1090
+			--upload-pack
  1091
+			--template=
  1092
+			--depth
  1093
+			"
  1094
+		return
  1095
+		;;
  1096
+	esac
  1097
+	COMPREPLY=()
  1098
+}
  1099
+
  1100
+_git_commit ()
  1101
+{
  1102
+	__git_has_doubledash && return
  1103
+
  1104
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  1105
+	case "$cur" in
  1106
+	--cleanup=*)
  1107
+		__gitcomp "default strip verbatim whitespace
  1108
+			" "" "${cur##--cleanup=}"
  1109
+		return
  1110
+		;;
  1111
+	--reuse-message=*)
  1112
+		__gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
  1113
+		return
  1114
+		;;
  1115
+	--reedit-message=*)
  1116
+		__gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
  1117
+		return
  1118
+		;;
  1119
+	--untracked-files=*)
  1120
+		__gitcomp "all no normal" "" "${cur##--untracked-files=}"
  1121
+		return
  1122
+		;;
  1123
+	--*)
  1124
+		__gitcomp "
  1125
+			--all --author= --signoff --verify --no-verify
  1126
+			--edit --amend --include --only --interactive
  1127
+			--dry-run --reuse-message= --reedit-message=
  1128
+			--reset-author --file= --message= --template=
  1129
+			--cleanup= --untracked-files --untracked-files=
  1130
+			--verbose --quiet
  1131
+			"
  1132
+		return
  1133
+	esac
  1134
+	COMPREPLY=()
  1135
+}
  1136
+
  1137
+_git_describe ()
  1138
+{
  1139
+	local cur="${COMP_WORDS[COMP_CWORD]}"
  1140
+	case "$cur" in
  1141
+	--*)
  1142
+		__gitcomp "
  1143
+			--all --tags --contains --abbrev= --candidates=
  1144
+			--exact-match --debug --long --match --always
  1145
+			"
  1146
+		return
  1147
+	esac
  1148
+	__gitcomp "$(__git_refs)"