|
21 | 21 | # 2) Added the following line to your .bashrc:
|
22 | 22 | # source ~/.git-completion.sh
|
23 | 23 | #
|
| 24 | +# Or, add the following lines to your .zshrc: |
| 25 | +# autoload bashcompinit |
| 26 | +# bashcompinit |
| 27 | +# source ~/.git-completion.sh |
| 28 | +# |
24 | 29 | # 3) Consider changing your PS1 to also show the current branch:
|
25 | 30 | # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
|
26 | 31 | #
|
@@ -138,11 +143,12 @@ __git_ps1_show_upstream ()
|
138 | 143 | # get the upstream from the "git-svn-id: ..." in a commit message
|
139 | 144 | # (git-svn uses essentially the same procedure internally)
|
140 | 145 | local svn_upstream=($(git log --first-parent -1 \
|
141 |
| - --grep="^git-svn-id: \(${svn_url_pattern:2}\)" 2>/dev/null)) |
| 146 | + --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) |
142 | 147 | if [[ 0 -ne ${#svn_upstream[@]} ]]; then
|
143 | 148 | svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
|
144 | 149 | svn_upstream=${svn_upstream%@*}
|
145 |
| - for ((n=1; "$n" <= "${#svn_remote[@]}"; ++n)); do |
| 150 | + local n_stop="${#svn_remote[@]}" |
| 151 | + for ((n=1; n <= n_stop; ++n)); do |
146 | 152 | svn_upstream=${svn_upstream#${svn_remote[$n]}}
|
147 | 153 | done
|
148 | 154 |
|
@@ -2339,6 +2345,11 @@ _git ()
|
2339 | 2345 | {
|
2340 | 2346 | local i c=1 command __git_dir
|
2341 | 2347 |
|
| 2348 | + if [[ -n $ZSH_VERSION ]]; then |
| 2349 | + emulate -L bash |
| 2350 | + setopt KSH_TYPESET |
| 2351 | + fi |
| 2352 | + |
2342 | 2353 | while [ $c -lt $COMP_CWORD ]; do
|
2343 | 2354 | i="${COMP_WORDS[c]}"
|
2344 | 2355 | case "$i" in
|
@@ -2372,17 +2383,22 @@ _git ()
|
2372 | 2383 | fi
|
2373 | 2384 |
|
2374 | 2385 | local completion_func="_git_${command//-/_}"
|
2375 |
| - declare -F $completion_func >/dev/null && $completion_func && return |
| 2386 | + declare -f $completion_func >/dev/null && $completion_func && return |
2376 | 2387 |
|
2377 | 2388 | local expansion=$(__git_aliased_command "$command")
|
2378 | 2389 | if [ -n "$expansion" ]; then
|
2379 | 2390 | completion_func="_git_${expansion//-/_}"
|
2380 |
| - declare -F $completion_func >/dev/null && $completion_func |
| 2391 | + declare -f $completion_func >/dev/null && $completion_func |
2381 | 2392 | fi
|
2382 | 2393 | }
|
2383 | 2394 |
|
2384 | 2395 | _gitk ()
|
2385 | 2396 | {
|
| 2397 | + if [[ -n $ZSH_VERSION ]]; then |
| 2398 | + emulate -L bash |
| 2399 | + setopt KSH_TYPESET |
| 2400 | + fi |
| 2401 | + |
2386 | 2402 | __git_has_doubledash && return
|
2387 | 2403 |
|
2388 | 2404 | local cur="${COMP_WORDS[COMP_CWORD]}"
|
@@ -2417,3 +2433,29 @@ if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
|
2417 | 2433 | complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
|
2418 | 2434 | || complete -o default -o nospace -F _git git.exe
|
2419 | 2435 | fi
|
| 2436 | + |
| 2437 | +if [[ -n $ZSH_VERSION ]]; then |
| 2438 | + shopt () { |
| 2439 | + local option |
| 2440 | + if [ $# -ne 2 ]; then |
| 2441 | + echo "USAGE: $0 (-q|-s|-u) <option>" >&2 |
| 2442 | + return 1 |
| 2443 | + fi |
| 2444 | + case "$2" in |
| 2445 | + nullglob) |
| 2446 | + option="$2" |
| 2447 | + ;; |
| 2448 | + *) |
| 2449 | + echo "$0: invalid option: $2" >&2 |
| 2450 | + return 1 |
| 2451 | + esac |
| 2452 | + case "$1" in |
| 2453 | + -q) setopt | grep -q "$option" ;; |
| 2454 | + -u) unsetopt "$option" ;; |
| 2455 | + -s) setopt "$option" ;; |
| 2456 | + *) |
| 2457 | + echo "$0: invalid flag: $1" >&2 |
| 2458 | + return 1 |
| 2459 | + esac |
| 2460 | + } |
| 2461 | +fi |
0 commit comments