Unverified Commit 0232ac4b authored by Marc Cornellà's avatar Marc Cornellà Committed by GitHub
Browse files

Merge branch 'master' into master

parents afb02876 ebc700be
# ZSH Git Prompt Plugin from:
# http://github.com/olivierverdier/zsh-git-prompt
__GIT_PROMPT_DIR="${0:A:h}" __GIT_PROMPT_DIR="${0:A:h}"
## Hook function definitions ## Hook function definitions
......
#!/usr/bin/env python #!/usr/bin/env python
from __future__ import print_function from __future__ import print_function
import os
import sys import sys
import re import re
import shlex import shlex
...@@ -22,7 +23,7 @@ def get_tagname_or_hash(): ...@@ -22,7 +23,7 @@ def get_tagname_or_hash():
tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1] tagname = 'tags/' + output[m.start()+len('tag: '): m.end()-1]
if tagname: if tagname:
return tagname return tagname.replace(' ', '')
elif hash_: elif hash_:
return hash_ return hash_
return None return None
...@@ -30,7 +31,7 @@ def get_tagname_or_hash(): ...@@ -30,7 +31,7 @@ def get_tagname_or_hash():
# `git status --porcelain --branch` can collect all information # `git status --porcelain --branch` can collect all information
# branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind # branch, remote_branch, untracked, staged, changed, conflicts, ahead, behind
po = Popen(['git', 'status', '--porcelain', '--branch'], stdout=PIPE, stderr=PIPE) po = Popen(['git', 'status', '--porcelain', '--branch'], env=dict(os.environ, LANG="C"), stdout=PIPE, stderr=PIPE)
stdout, sterr = po.communicate() stdout, sterr = po.communicate()
if po.returncode != 0: if po.returncode != 0:
sys.exit(0) # Not a git repository sys.exit(0) # Not a git repository
...@@ -41,7 +42,7 @@ ahead, behind = 0, 0 ...@@ -41,7 +42,7 @@ ahead, behind = 0, 0
status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()] status = [(line[0], line[1], line[2:]) for line in stdout.decode('utf-8').splitlines()]
for st in status: for st in status:
if st[0] == '#' and st[1] == '#': if st[0] == '#' and st[1] == '#':
if re.search('Initial commit on', st[2]): if re.search('Initial commit on', st[2]) or re.search('No commits yet on', st[2]):
branch = st[2].split(' ')[-1] branch = st[2].split(' ')[-1]
elif re.search('no branch', st[2]): # detached status elif re.search('no branch', st[2]): # detached status
branch = get_tagname_or_hash() branch = get_tagname_or_hash()
......
...@@ -44,12 +44,14 @@ alias ga='git add' ...@@ -44,12 +44,14 @@ alias ga='git add'
alias gaa='git add --all' alias gaa='git add --all'
alias gapa='git add --patch' alias gapa='git add --patch'
alias gau='git add --update' alias gau='git add --update'
alias gav='git add --verbose'
alias gap='git apply' alias gap='git apply'
alias gb='git branch' alias gb='git branch'
alias gba='git branch -a' alias gba='git branch -a'
alias gbd='git branch -d' alias gbd='git branch -d'
alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' alias gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d'
alias gbD='git branch -D'
alias gbl='git blame -b -w' alias gbl='git blame -b -w'
alias gbnm='git branch --no-merged' alias gbnm='git branch --no-merged'
alias gbr='git branch --remote' alias gbr='git branch --remote'
...@@ -70,8 +72,8 @@ alias gcam='git commit -a -m' ...@@ -70,8 +72,8 @@ alias gcam='git commit -a -m'
alias gcsm='git commit -s -m' alias gcsm='git commit -s -m'
alias gcb='git checkout -b' alias gcb='git checkout -b'
alias gcf='git config --list' alias gcf='git config --list'
alias gcl='git clone --recursive' alias gcl='git clone --recurse-submodules'
alias gclean='git clean -fd' alias gclean='git clean -id'
alias gpristine='git reset --hard && git clean -dfx' alias gpristine='git reset --hard && git clean -dfx'
alias gcm='git checkout master' alias gcm='git checkout master'
alias gcd='git checkout develop' alias gcd='git checkout develop'
...@@ -88,6 +90,7 @@ alias gd='git diff' ...@@ -88,6 +90,7 @@ alias gd='git diff'
alias gdca='git diff --cached' alias gdca='git diff --cached'
alias gdcw='git diff --cached --word-diff' alias gdcw='git diff --cached --word-diff'
alias gdct='git describe --tags `git rev-list --tags --max-count=1`' alias gdct='git describe --tags `git rev-list --tags --max-count=1`'
alias gds='git diff --staged'
alias gdt='git diff-tree --no-commit-id --name-only -r' alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gdw='git diff --word-diff' alias gdw='git diff --word-diff'
...@@ -109,8 +112,8 @@ ggf() { ...@@ -109,8 +112,8 @@ ggf() {
git push --force origin "${b:=$1}" git push --force origin "${b:=$1}"
} }
ggfl() { ggfl() {
[[ "$#" != 1 ]] && local b="$(git_current_branch)" [[ "$#" != 1 ]] && local b="$(git_current_branch)"
git push --force-with-lease origin "${b:=$1}" git push --force-with-lease origin "${b:=$1}"
} }
compdef _git ggf=git-checkout compdef _git ggf=git-checkout
...@@ -152,10 +155,10 @@ compdef _git ggu=git-checkout ...@@ -152,10 +155,10 @@ compdef _git ggu=git-checkout
alias ggpur='ggu' alias ggpur='ggu'
compdef _git ggpur=git-checkout compdef _git ggpur=git-checkout
alias ggpull='git pull origin $(git_current_branch)' alias ggpull='git pull origin "$(git_current_branch)"'
compdef _git ggpull=git-checkout compdef _git ggpull=git-checkout
alias ggpush='git push origin $(git_current_branch)' alias ggpush='git push origin "$(git_current_branch)"'
compdef _git ggpush=git-checkout compdef _git ggpush=git-checkout
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
...@@ -180,8 +183,11 @@ alias glgg='git log --graph' ...@@ -180,8 +183,11 @@ alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all' alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10' alias glgm='git log --graph --max-count=10'
alias glo='git log --oneline --decorate' alias glo='git log --oneline --decorate'
alias glol="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" alias glol="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"
alias glola="git log --graph --pretty='%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all" alias glols="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --stat"
alias glod="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"
alias glods="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"
alias glola="git log --graph --pretty='%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --all"
alias glog='git log --oneline --decorate --graph' alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all' alias gloga='git log --oneline --decorate --graph --all'
alias glp="_git_log_prettily" alias glp="_git_log_prettily"
...@@ -196,6 +202,8 @@ alias gma='git merge --abort' ...@@ -196,6 +202,8 @@ alias gma='git merge --abort'
alias gp='git push' alias gp='git push'
alias gpd='git push --dry-run' alias gpd='git push --dry-run'
alias gpf='git push --force-with-lease'
alias gpf!='git push --force'
alias gpoat='git push origin --all && git push origin --tags' alias gpoat='git push origin --all && git push origin --tags'
compdef _git gpoat=git-push compdef _git gpoat=git-push
alias gpu='git push upstream' alias gpu='git push upstream'
...@@ -206,43 +214,58 @@ alias gra='git remote add' ...@@ -206,43 +214,58 @@ alias gra='git remote add'
alias grb='git rebase' alias grb='git rebase'
alias grba='git rebase --abort' alias grba='git rebase --abort'
alias grbc='git rebase --continue' alias grbc='git rebase --continue'
alias grbd='git rebase develop'
alias grbi='git rebase -i' alias grbi='git rebase -i'
alias grbm='git rebase master' alias grbm='git rebase master'
alias grbs='git rebase --skip' alias grbs='git rebase --skip'
alias grh='git reset HEAD' alias grh='git reset'
alias grhh='git reset HEAD --hard' alias grhh='git reset --hard'
alias groh='git reset origin/$(git_current_branch) --hard'
alias grm='git rm'
alias grmc='git rm --cached'
alias grmv='git remote rename' alias grmv='git remote rename'
alias grrm='git remote remove' alias grrm='git remote remove'
alias grset='git remote set-url' alias grset='git remote set-url'
alias grt='cd $(git rev-parse --show-toplevel || echo ".")' alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
alias gru='git reset --' alias gru='git reset --'
alias grup='git remote update' alias grup='git remote update'
alias grv='git remote -v' alias grv='git remote -v'
alias gsb='git status -sb' alias gsb='git status -sb'
alias gsd='git svn dcommit' alias gsd='git svn dcommit'
alias gsh='git show'
alias gsi='git submodule init' alias gsi='git submodule init'
alias gsps='git show --pretty=short --show-signature' alias gsps='git show --pretty=short --show-signature'
alias gsr='git svn rebase' alias gsr='git svn rebase'
alias gss='git status -s' alias gss='git status -s'
alias gst='git status' alias gst='git status'
alias gsta='git stash save'
# use the default stash push on git 2.13 and newer
autoload -Uz is-at-least
is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')" \
&& alias gsta='git stash push' \
|| alias gsta='git stash save'
alias gstaa='git stash apply' alias gstaa='git stash apply'
alias gstc='git stash clear' alias gstc='git stash clear'
alias gstd='git stash drop' alias gstd='git stash drop'
alias gstl='git stash list' alias gstl='git stash list'
alias gstp='git stash pop' alias gstp='git stash pop'
alias gsts='git stash show --text' alias gsts='git stash show --text'
alias gstall='git stash --all'
alias gsu='git submodule update' alias gsu='git submodule update'
alias gts='git tag -s' alias gts='git tag -s'
alias gtv='git tag | sort -V' alias gtv='git tag | sort -V'
alias gtl='gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl'
alias gunignore='git update-index --no-assume-unchanged' alias gunignore='git update-index --no-assume-unchanged'
alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1'
alias gup='git pull --rebase' alias gup='git pull --rebase'
alias gupv='git pull --rebase -v' alias gupv='git pull --rebase -v'
alias gupa='git pull --rebase --autostash'
alias gupav='git pull --rebase --autostash -v'
alias glum='git pull upstream master' alias glum='git pull upstream master'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium' alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify -m "--wip-- [skip ci]"' alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"'
# Gitfast plugin
This plugin adds completion for Git, using the zsh completion from git.git folks, which is much faster than the official one from zsh. A lot of zsh-specific features are not supported, like descriptions for every argument, but everything the bash completion has, this one does too (as it is using it behind the scenes). Not only is it faster, it should be more robust, and updated regularly to the latest git upstream version..
To use it, add `gitfast` to the plugins array in your zshrc file:
```zsh
plugins=(... gitfast)
```
## Aliases
An earlier version of the plugin also loaded the git plugin. If you want to keep those
aliases enable the [git plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/git)
as well.
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
# #
# If your script is somewhere else, you can configure it on your ~/.zshrc: # If your script is somewhere else, you can configure it on your ~/.zshrc:
# #
# zstyle ':completion:*:*:git:*' script ~/.git-completion.sh # zstyle ':completion:*:*:git:*' script ~/.git-completion.zsh
# #
# The recommended way to install this script is to copy to '~/.zsh/_git', and # The recommended way to install this script is to copy to '~/.zsh/_git', and
# then add the following to your ~/.zshrc file: # then add the following to your ~/.zshrc file:
...@@ -67,6 +67,15 @@ __gitcomp () ...@@ -67,6 +67,15 @@ __gitcomp ()
esac esac
} }
__gitcomp_direct ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -Q -- ${=1} && _ret=0
}
__gitcomp_nl () __gitcomp_nl ()
{ {
emulate -L zsh emulate -L zsh
......
...@@ -28,27 +28,55 @@ ...@@ -28,27 +28,55 @@
# completion style. For example '!f() { : git commit ; ... }; f' will # completion style. For example '!f() { : git commit ; ... }; f' will
# tell the completion to use commit completion. This also works with aliases # tell the completion to use commit completion. This also works with aliases
# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '". # of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
#
# You can set the following environment variables to influence the behavior of
# the completion routines:
#
# GIT_COMPLETION_CHECKOUT_NO_GUESS
#
# When set to "1", do not include "DWIM" suggestions in git-checkout
# completion (e.g., completing "foo" when "origin/foo" exists).
case "$COMP_WORDBREAKS" in case "$COMP_WORDBREAKS" in
*:*) : great ;; *:*) : great ;;
*) COMP_WORDBREAKS="$COMP_WORDBREAKS:" *) COMP_WORDBREAKS="$COMP_WORDBREAKS:"
esac esac
# Discovers the path to the git repository taking any '--git-dir=<path>' and
# '-C <path>' options into account and stores it in the $__git_repo_path
# variable.
__git_find_repo_path ()
{
if [ -n "$__git_repo_path" ]; then
# we already know where it is
return
fi
if [ -n "${__git_C_args-}" ]; then
__git_repo_path="$(git "${__git_C_args[@]}" \
${__git_dir:+--git-dir="$__git_dir"} \
rev-parse --absolute-git-dir 2>/dev/null)"
elif [ -n "${__git_dir-}" ]; then
test -d "$__git_dir" &&
__git_repo_path="$__git_dir"
elif [ -n "${GIT_DIR-}" ]; then
test -d "${GIT_DIR-}" &&
__git_repo_path="$GIT_DIR"
elif [ -d .git ]; then
__git_repo_path=.git
else
__git_repo_path="$(git rev-parse --git-dir 2>/dev/null)"
fi
}
# Deprecated: use __git_find_repo_path() and $__git_repo_path instead
# __gitdir accepts 0 or 1 arguments (i.e., location) # __gitdir accepts 0 or 1 arguments (i.e., location)
# returns location of .git repo # returns location of .git repo
__gitdir () __gitdir ()
{ {
if [ -z "${1-}" ]; then if [ -z "${1-}" ]; then
if [ -n "${__git_dir-}" ]; then __git_find_repo_path || return 1
echo "$__git_dir" echo "$__git_repo_path"
elif [ -n "${GIT_DIR-}" ]; then
test -d "${GIT_DIR-}" || return 1
echo "$GIT_DIR"
elif [ -d .git ]; then
echo .git
else
git rev-parse --git-dir 2>/dev/null
fi
elif [ -d "$1/.git" ]; then elif [ -d "$1/.git" ]; then
echo "$1/.git" echo "$1/.git"
else else
...@@ -56,6 +84,14 @@ __gitdir () ...@@ -56,6 +84,14 @@ __gitdir ()
fi fi
} }
# Runs git with all the options given as argument, respecting any
# '--git-dir=<path>' and '-C <path>' options present on the command line
__git ()
{
git ${__git_C_args:+"${__git_C_args[@]}"} \
${__git_dir:+--git-dir="$__git_dir"} "$@" 2>/dev/null
}
# The following function is based on code from: # The following function is based on code from:
# #
# bash_completion - programmable completion functions for bash 3.2+ # bash_completion - programmable completion functions for bash 3.2+
...@@ -185,6 +221,20 @@ _get_comp_words_by_ref () ...@@ -185,6 +221,20 @@ _get_comp_words_by_ref ()
} }
fi fi
# Fills the COMPREPLY array with prefiltered words without any additional
# processing.
# Callers must take care of providing only words that match the current word
# to be completed and adding any prefix and/or suffix (trailing space!), if
# necessary.
# 1: List of newline-separated matching completion words, complete with
# prefix and suffix.
__gitcomp_direct ()
{
local IFS=$'\n'
COMPREPLY=($1)
}
__gitcompappend () __gitcompappend ()
{ {
local x i=${#COMPREPLY[@]} local x i=${#COMPREPLY[@]}
...@@ -283,11 +333,11 @@ __gitcomp_file () ...@@ -283,11 +333,11 @@ __gitcomp_file ()
__git_ls_files_helper () __git_ls_files_helper ()
{ {
if [ "$2" == "--committable" ]; then if [ "$2" == "--committable" ]; then
git -C "$1" diff-index --name-only --relative HEAD __git -C "$1" diff-index --name-only --relative HEAD
else else
# NOTE: $2 is not quoted in order to support multiple options # NOTE: $2 is not quoted in order to support multiple options
git -C "$1" ls-files --exclude-standard $2 __git -C "$1" ls-files --exclude-standard $2
fi 2>/dev/null fi
} }
...@@ -299,99 +349,195 @@ __git_ls_files_helper () ...@@ -299,99 +349,195 @@ __git_ls_files_helper ()
# slash. # slash.
__git_index_files () __git_index_files ()
{ {
local dir="$(__gitdir)" root="${2-.}" file local root="${2-.}" file
if [ -d "$dir" ]; then __git_ls_files_helper "$root" "$1" |
__git_ls_files_helper "$root" "$1" | while read -r file; do
while read -r file; do case "$file" in
case "$file" in ?*/*) echo "${file%%/*}" ;;
?*/*) echo "${file%%/*}" ;; *) echo "$file" ;;
*) echo "$file" ;; esac
esac done | sort | uniq
done | sort | uniq
fi
} }
# Lists branches from the local repository.
# 1: A prefix to be added to each listed branch (optional).
# 2: List only branches matching this word (optional; list all branches if
# unset or empty).
# 3: A suffix to be appended to each listed branch (optional).
__git_heads () __git_heads ()
{ {
local dir="$(__gitdir)" local pfx="${1-}" cur_="${2-}" sfx="${3-}"
if [ -d "$dir" ]; then
git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
refs/heads "refs/heads/$cur_*" "refs/heads/$cur_*/**"
return
fi
} }
# Lists tags from the local repository.
# Accepts the same positional parameters as __git_heads() above.
__git_tags () __git_tags ()
{ {
local dir="$(__gitdir)" local pfx="${1-}" cur_="${2-}" sfx="${3-}"
if [ -d "$dir" ]; then
git --git-dir="$dir" for-each-ref --format='%(refname:short)' \ __git for-each-ref --format="${pfx//\%/%%}%(refname:strip=2)$sfx" \
refs/tags "refs/tags/$cur_*" "refs/tags/$cur_*/**"
return
fi
} }
# __git_refs accepts 0, 1 (to pass to __gitdir), or 2 arguments # Lists refs from the local (by default) or from a remote repository.
# presence of 2nd argument means use the guess heuristic employed # It accepts 0, 1 or 2 arguments:
# by checkout for tracking branches # 1: The remote to list refs from (optional; ignored, if set but empty).
# Can be the name of a configured remote, a path, or a URL.
# 2: In addition to local refs, list unique branches from refs/remotes/ for
# 'git checkout's tracking DWIMery (optional; ignored, if set but empty).
# 3: A prefix to be added to each listed ref (optional).
# 4: List only refs matching this word (optional; list all refs if unset or
# empty).
# 5: A suffix to be appended to each listed ref (optional; ignored, if set
# but empty).
#
# Use __git_complete_refs() instead.
__git_refs () __git_refs ()
{ {
local i hash dir="$(__gitdir "${1-}")" track="${2-}" local i hash dir track="${2-}"
local list_refs_from=path remote="${1-}"
local format refs local format refs
if [ -d "$dir" ]; then local pfx="${3-}" cur_="${4-$cur}" sfx="${5-}"
case "$cur" in local match="${4-}"
local fer_pfx="${pfx//\%/%%}" # "escape" for-each-ref format specifiers
__git_find_repo_path
dir="$__git_repo_path"
if [ -z "$remote" ]; then
if [ -z "$dir" ]; then
return
fi
else
if __git_is_configured_remote "$remote"; then
# configured remote takes precedence over a
# local directory with the same name
list_refs_from=remote
elif [ -d "$remote/.git" ]; then
dir="$remote/.git"
elif [ -d "$remote" ]; then
dir="$remote"
else
list_refs_from=url
fi
fi
if [ "$list_refs_from" = path ]; then
if [[ "$cur_" == ^* ]]; then
pfx="$pfx^"
fer_pfx="$fer_pfx^"
cur_=${cur_#^}
match=${match#^}
fi
case "$cur_" in
refs|refs/*) refs|refs/*)
format="refname" format="refname"
refs="${cur%/*}" refs=("$match*" "$match*/**")
track="" track=""
;; ;;
*) *)
for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
if [ -e "$dir/$i" ]; then echo $i; fi case "$i" in
$match*)
if [ -e "$dir/$i" ]; then
echo "$pfx$i$sfx"
fi
;;
esac
done done
format="refname:short" format="refname:strip=2"
refs="refs/tags refs/heads refs/remotes" refs=("refs/tags/$match*" "refs/tags/$match*/**"
"refs/heads/$match*" "refs/heads/$match*/**"
"refs/remotes/$match*" "refs/remotes/$match*/**")
;; ;;
esac esac
git --git-dir="$dir" for-each-ref --format="%($format)" \ __git_dir="$dir" __git for-each-ref --format="$fer_pfx%($format)$sfx" \
$refs "${refs[@]}"
if [ -n "$track" ]; then if [ -n "$track" ]; then
# employ the heuristic used by git checkout # employ the heuristic used by git checkout
# Try to find a remote branch that matches the completion word # Try to find a remote branch that matches the completion word
# but only output if the branch name is unique # but only output if the branch name is unique
local ref entry __git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" \ --sort="refname:strip=3" \
"refs/remotes/" | \ "refs/remotes/*/$match*" "refs/remotes/*/$match*/**" | \
while read -r entry; do uniq -u
eval "$entry"
ref="${ref#*/}"
if [[ "$ref" == "$cur"* ]]; then
echo "$ref"
fi
done | sort | uniq -u
fi fi
return return
fi fi
case "$cur" in case "$cur_" in
refs|refs/*) refs|refs/*)
git ls-remote "$dir" "$cur*" 2>/dev/null | \ __git ls-remote "$remote" "$match*" | \
while read -r hash i; do while read -r hash i; do
case "$i" in case "$i" in
*^{}) ;; *^{}) ;;
*) echo "$i" ;; *) echo "$pfx$i$sfx" ;;
esac esac
done done
;; ;;
*) *)
echo "HEAD" if [ "$list_refs_from" = remote ]; then
git for-each-ref --format="%(refname:short)" -- \ case "HEAD" in
"refs/remotes/$dir/" 2>/dev/null | sed -e "s#^$dir/##" $match*) echo "${pfx}HEAD$sfx" ;;
esac
__git for-each-ref --format="$fer_pfx%(refname:strip=3)$sfx" \
"refs/remotes/$remote/$match*" \
"refs/remotes/$remote/$match*/**"
else
local query_symref
case "HEAD" in
$match*) query_symref="HEAD" ;;
esac
__git ls-remote "$remote" $query_symref \
"refs/tags/$match*" "refs/heads/$match*" \
"refs/remotes/$match*" |
while read -r hash i; do
case "$i" in
*^{}) ;;
refs/*) echo "$pfx${i#refs/*/}$sfx" ;;
*) echo "$pfx$i$sfx" ;; # symbolic refs
esac
done
fi
;; ;;
esac esac
} }
# Completes refs, short and long, local and remote, symbolic and pseudo.
#
# Usage: __git_complete_refs [<option>]...
# --remote=<remote>: The remote to list refs from, can be the name of a
# configured remote, a path, or a URL.
# --track: List unique remote branches for 'git checkout's tracking DWIMery.
# --pfx=<prefix>: A prefix to be added to each ref.
# --cur=<word>: The current ref to be completed. Defaults to the current
# word to be completed.
# --sfx=<suffix>: A suffix to be appended to each ref instead of the default
# space.
__git_complete_refs ()
{
local remote track pfx cur_="$cur" sfx=" "
while test $# != 0; do
case "$1" in
--remote=*) remote="${1##--remote=}" ;;
--track) track="yes" ;;
--pfx=*) pfx="${1##--pfx=}" ;;
--cur=*) cur_="${1##--cur=}" ;;
--sfx=*) sfx="${1##--sfx=}" ;;
*) return 1 ;;
esac
shift
done
__gitcomp_direct "$(__git_refs "$remote" "$track" "$pfx" "$cur_" "$sfx")"
}
# __git_refs2 requires 1 argument (to pass to __git_refs) # __git_refs2 requires 1 argument (to pass to __git_refs)
# Deprecated: use __git_complete_fetch_refspecs() instead.
__git_refs2 () __git_refs2 ()
{ {
local i local i
...@@ -400,11 +546,29 @@ __git_refs2 () ...@@ -400,11 +546,29 @@ __git_refs2 ()
done done
} }
# Completes refspecs for fetching from a remote repository.
# 1: The remote repository.
# 2: A prefix to be added to each listed refspec (optional).
# 3: The ref to be completed as a refspec instead of the current word to be
# completed (optional)
# 4: A suffix to be appended to each listed refspec instead of the default
# space (optional).
__git_complete_fetch_refspecs ()
{
local i remote="$1" pfx="${2-}" cur_="${3-$cur}" sfx="${4- }"
__gitcomp_direct "$(
for i in $(__git_refs "$remote" "" "" "$cur_") ; do
echo "$pfx$i:$i$sfx"
done
)"
}
# __git_refs_remotes requires 1 argument (to pass to ls-remote) # __git_refs_remotes requires 1 argument (to pass to ls-remote)
__git_refs_remotes () __git_refs_remotes ()
{ {
local i hash local i hash
git ls-remote "$1" 'refs/heads/*' 2>/dev/null | \ __git ls-remote "$1" 'refs/heads/*' | \
while read -r hash i; do while read -r hash i; do
echo "$i:refs/remotes/$1/${i#refs/heads/}" echo "$i:refs/remotes/$1/${i#refs/heads/}"
done done
...@@ -412,9 +576,21 @@ __git_refs_remotes () ...@@ -412,9 +576,21 @@ __git_refs_remotes ()
__git_remotes () __git_remotes ()
{ {
local d="$(__gitdir)" __git_find_repo_path
test -d "$d/remotes" && ls -1 "$d/remotes" test -d "$__git_repo_path/remotes" && ls -1 "$__git_repo_path/remotes"
git --git-dir="$d" remote __git remote
}
# Returns true if $1 matches the name of a configured remote, false otherwise.
__git_is_configured_remote ()
{
local remote
for remote in $(__git_remotes); do
if [ "$remote" = "$1" ]; then
return 0
fi
done
return 1
} }
__git_list_merge_strategies () __git_list_merge_strategies ()
...@@ -468,7 +644,7 @@ __git_complete_revlist_file () ...@@ -468,7 +644,7 @@ __git_complete_revlist_file ()
*) pfx="$ref:$pfx" ;; *) pfx="$ref:$pfx" ;;
esac esac
__gitcomp_nl "$(git --git-dir="$(__gitdir)" ls-tree "$ls" 2>/dev/null \ __gitcomp_nl "$(__git ls-tree "$ls" \
| sed '/^100... blob /{ | sed '/^100... blob /{
s,^.* ,, s,^.* ,,
s,$, , s,$, ,
...@@ -487,15 +663,15 @@ __git_complete_revlist_file () ...@@ -487,15 +663,15 @@ __git_complete_revlist_file ()
*...*) *...*)
pfx="${cur_%...*}..." pfx="${cur_%...*}..."
cur_="${cur_#*...}" cur_="${cur_#*...}"
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" __git_complete_refs --pfx="$pfx" --cur="$cur_"
;; ;;
*..*) *..*)
pfx="${cur_%..*}.." pfx="${cur_%..*}.."
cur_="${cur_#*..}" cur_="${cur_#*..}"
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" __git_complete_refs --pfx="$pfx" --cur="$cur_"
;; ;;
*) *)
__gitcomp_nl "$(__git_refs)" __git_complete_refs
;; ;;
esac esac
} }
...@@ -541,6 +717,7 @@ __git_complete_remote_or_refspec () ...@@ -541,6 +717,7 @@ __git_complete_remote_or_refspec ()
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
--mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;;
-d|--delete) [ "$cmd" = "push" ] && lhs=0 ;;
--all) --all)
case "$cmd" in case "$cmd" in
push) no_complete_refspec=1 ;; push) no_complete_refspec=1 ;;
...@@ -580,23 +757,23 @@ __git_complete_remote_or_refspec () ...@@ -580,23 +757,23 @@ __git_complete_remote_or_refspec ()
case "$cmd" in case "$cmd" in
fetch) fetch)
if [ $lhs = 1 ]; then if [ $lhs = 1 ]; then
__gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_" __git_complete_fetch_refspecs "$remote" "$pfx" "$cur_"
else else
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" __git_complete_refs --pfx="$pfx" --cur="$cur_"
fi fi
;; ;;
pull|remote) pull|remote)
if [ $lhs = 1 ]; then if [ $lhs = 1 ]; then
__gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
else else
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" __git_complete_refs --pfx="$pfx" --cur="$cur_"
fi fi
;; ;;
push) push)
if [ $lhs = 1 ]; then if [ $lhs = 1 ]; then
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" __git_complete_refs --pfx="$pfx" --cur="$cur_"
else else
__gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_" __git_complete_refs --remote="$remote" --pfx="$pfx" --cur="$cur_"
fi fi
;; ;;
esac esac
...@@ -746,7 +923,7 @@ __git_compute_porcelain_commands () ...@@ -746,7 +923,7 @@ __git_compute_porcelain_commands ()
__git_get_config_variables () __git_get_config_variables ()
{ {
local section="$1" i IFS=$'\n' local section="$1" i IFS=$'\n'
for i in $(git --git-dir="$(__gitdir)" config --name-only --get-regexp "^$section\..*" 2>/dev/null); do for i in $(__git config --name-only --get-regexp "^$section\..*"); do
echo "${i#$section.}" echo "${i#$section.}"
done done
} }
...@@ -764,8 +941,7 @@ __git_aliases () ...@@ -764,8 +941,7 @@ __git_aliases ()
# __git_aliased_command requires 1 argument # __git_aliased_command requires 1 argument
__git_aliased_command () __git_aliased_command ()
{ {
local word cmdline=$(git --git-dir="$(__gitdir)" \ local word cmdline=$(__git config --get "alias.$1")
config --get "alias.$1")
for word in $cmdline; do for word in $cmdline; do
case "$word" in case "$word" in
\!gitk|gitk) \!gitk|gitk)
...@@ -803,6 +979,50 @@ __git_find_on_cmdline () ...@@ -803,6 +979,50 @@ __git_find_on_cmdline ()
done done
} }
# Echo the value of an option set on the command line or config
#
# $1: short option name
# $2: long option name including =
# $3: list of possible values
# $4: config string (optional)
#
# example:
# result="$(__git_get_option_value "-d" "--do-something=" \
# "yes no" "core.doSomething")"
#
# result is then either empty (no option set) or "yes" or "no"
#
# __git_get_option_value requires 3 arguments
__git_get_option_value ()
{
local c short_opt long_opt val
local result= values config_key word
short_opt="$1"
long_opt="$2"
values="$3"
config_key="$4"
((c = $cword - 1))
while [ $c -ge 0 ]; do
word="${words[c]}"
for val in $values; do
if [ "$short_opt$val" = "$word" ] ||
[ "$long_opt$val" = "$word" ]; then
result="$val"
break 2
fi
done
((c--))
done
if [ -n "$config_key" ] && [ -z "$result" ]; then
result="$(__git config "$config_key")"
fi
echo "$result"
}
__git_has_doubledash () __git_has_doubledash ()
{ {
local c=1 local c=1
...@@ -856,8 +1076,8 @@ __git_whitespacelist="nowarn warn error error-all fix" ...@@ -856,8 +1076,8 @@ __git_whitespacelist="nowarn warn error error-all fix"
_git_am () _git_am ()
{ {
local dir="$(__gitdir)" __git_find_repo_path
if [ -d "$dir"/rebase-apply ]; then if [ -d "$__git_repo_path"/rebase-apply ]; then
__gitcomp "--skip --continue --resolved --abort" __gitcomp "--skip --continue --resolved --abort"
return return
fi fi
...@@ -891,6 +1111,7 @@ _git_apply () ...@@ -891,6 +1111,7 @@ _git_apply ()
--apply --no-add --exclude= --apply --no-add --exclude=
--ignore-whitespace --ignore-space-change --ignore-whitespace --ignore-space-change
--whitespace= --inaccurate-eof --verbose --whitespace= --inaccurate-eof --verbose
--recount --directory=
" "
return return
esac esac
...@@ -902,13 +1123,17 @@ _git_add () ...@@ -902,13 +1123,17 @@ _git_add ()
--*) --*)
__gitcomp " __gitcomp "
--interactive --refresh --patch --update --dry-run --interactive --refresh --patch --update --dry-run
--ignore-errors --intent-to-add --ignore-errors --intent-to-add --force --edit --chmod=
" "
return return
esac esac
# XXX should we check for --update and --all options ? local complete_opt="--others --modified --directory --no-empty-directory"
__git_complete_index_file "--others --modified --directory --no-empty-directory" if test -n "$(__git_find_on_cmdline "-u --update")"
then
complete_opt="--modified"
fi
__git_complete_index_file "$complete_opt"
} }
_git_archive () _git_archive ()
...@@ -925,7 +1150,7 @@ _git_archive () ...@@ -925,7 +1150,7 @@ _git_archive ()
--*) --*)
__gitcomp " __gitcomp "
--format= --list --verbose --format= --list --verbose
--prefix= --remote= --exec= --prefix= --remote= --exec= --output
" "
return return
;; ;;
...@@ -940,7 +1165,8 @@ _git_bisect () ...@@ -940,7 +1165,8 @@ _git_bisect ()
local subcommands="start bad good skip reset visualize replay log run" local subcommands="start bad good skip reset visualize replay log run"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
if [ -f "$(__gitdir)"/BISECT_START ]; then __git_find_repo_path
if [ -f "$__git_repo_path"/BISECT_START ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
else else
__gitcomp "replay start" __gitcomp "replay start"
...@@ -950,7 +1176,7 @@ _git_bisect () ...@@ -950,7 +1176,7 @@ _git_bisect ()
case "$subcommand" in case "$subcommand" in
bad|good|reset|skip|start) bad|good|reset|skip|start)
__gitcomp_nl "$(__git_refs)" __git_complete_refs
;; ;;
*) *)
;; ;;
...@@ -964,29 +1190,30 @@ _git_branch () ...@@ -964,29 +1190,30 @@ _git_branch ()
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-d|-m) only_local_ref="y" ;; -d|--delete|-m|--move) only_local_ref="y" ;;
-r) has_r="y" ;; -r|--remotes) has_r="y" ;;
esac esac
((c++)) ((c++))
done done
case "$cur" in case "$cur" in
--set-upstream-to=*) --set-upstream-to=*)
__gitcomp_nl "$(__git_refs)" "" "${cur##--set-upstream-to=}" __git_complete_refs --cur="${cur##--set-upstream-to=}"
;; ;;
--*) --*)
__gitcomp " __gitcomp "
--color --no-color --verbose --abbrev= --no-abbrev --color --no-color --verbose --abbrev= --no-abbrev
--track --no-track --contains --merged --no-merged --track --no-track --contains --no-contains --merged --no-merged
--set-upstream-to= --edit-description --list --set-upstream-to= --edit-description --list
--unset-upstream --unset-upstream --delete --move --remotes
--column --no-column --sort= --points-at
" "
;; ;;
*) *)
if [ $only_local_ref = "y" -a $has_r = "n" ]; then if [ $only_local_ref = "y" -a $has_r = "n" ]; then
__gitcomp_nl "$(__git_heads)" __gitcomp_direct "$(__git_heads "" "$cur" " ")"
else else
__gitcomp_nl "$(__git_refs)" __git_complete_refs
fi fi
;; ;;
esac esac
...@@ -1029,24 +1256,25 @@ _git_checkout () ...@@ -1029,24 +1256,25 @@ _git_checkout ()
*) *)
# check if --track, --no-track, or --no-guess was specified # check if --track, --no-track, or --no-guess was specified
# if so, disable DWIM mode # if so, disable DWIM mode
local flags="--track --no-track --no-guess" track=1 local flags="--track --no-track --no-guess" track_opt="--track"
if [ -n "$(__git_find_on_cmdline "$flags")" ]; then if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] ||
track='' [ -n "$(__git_find_on_cmdline "$flags")" ]; then
track_opt=''
fi fi
__gitcomp_nl "$(__git_refs '' $track)" __git_complete_refs $track_opt
;; ;;
esac esac
} }
_git_cherry () _git_cherry ()
{ {
__gitcomp_nl "$(__git_refs)" __git_complete_refs
} }
_git_cherry_pick () _git_cherry_pick ()
{ {
local dir="$(__gitdir)" __git_find_repo_path
if [ -f "$dir"/CHERRY_PICK_HEAD ]; then if [ -f "$__git_repo_path"/CHERRY_PICK_HEAD ]; then
__gitcomp "--continue --quit --abort" __gitcomp "--continue --quit --abort"
return return
fi fi
...@@ -1055,7 +1283,7 @@ _git_cherry_pick () ...@@ -1055,7 +1283,7 @@ _git_cherry_pick ()
__gitcomp "--edit --no-commit --signoff --strategy= --mainline" __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
;; ;;
*) *)
__gitcomp_nl "$(__git_refs)" __git_complete_refs
;; ;;
esac esac
} }
...@@ -1091,18 +1319,24 @@ _git_clone () ...@@ -1091,18 +1319,24 @@ _git_clone ()
--template= --template=
--depth --depth
--single-branch --single-branch
--no-tags
--branch --branch
--recurse-submodules
--no-single-branch
--shallow-submodules
" "
return return
;; ;;
esac esac
} }
__git_untracked_file_modes="all no normal"
_git_commit () _git_commit ()
{ {
case "$prev" in case "$prev" in
-c|-C) -c|-C)
__gitcomp_nl "$(__git_refs)" "" "${cur}" __git_complete_refs
return return
;; ;;
esac esac
...@@ -1115,11 +1349,11 @@ _git_commit () ...@@ -1115,11 +1349,11 @@ _git_commit ()
;; ;;
--reuse-message=*|--reedit-message=*|\ --reuse-message=*|--reedit-message=*|\
--fixup=*|--squash=*) --fixup=*|--squash=*)
__gitcomp_nl "$(__git_refs)" "" "${cur#*=}" __git_complete_refs --cur="${cur#*=}"
return return
;; ;;
--untracked-files=*) --untracked-files=*)
__gitcomp "all no normal" "" "${cur##--untracked-files=}" __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
return return
;; ;;
--*) --*)
...@@ -1131,11 +1365,12 @@ _git_commit () ...@@ -1131,11 +1365,12 @@ _git_commit ()
--reset-author --file= --message= --template= --reset-author --file= --message= --template=
--cleanup= --untracked-files --untracked-files= --cleanup= --untracked-files --untracked-files=
--verbose --quiet --fixup= --squash= --verbose --quiet --fixup= --squash=
--patch --short --date --allow-empty
" "
return return
esac esac
if git rev-parse --verify --quiet HEAD >/dev/null; then if __git rev-parse --verify --quiet HEAD >/dev/null; then
__git_complete_index_file "--committable" __git_complete_index_file "--committable"
else else
# This is the first commit # This is the first commit
...@@ -1149,15 +1384,18 @@ _git_describe () ...@@ -1149,15 +1384,18 @@ _git_describe ()
--*) --*)
__gitcomp " __gitcomp "
--all --tags --contains --abbrev= --candidates= --all --tags --contains --abbrev= --candidates=
--exact-match --debug --long --match --always --exact-match --debug --long --match --always --first-parent
--exclude
" "
return return
esac esac
__gitcomp_nl "$(__git_refs)" __git_complete_refs
} }
__git_diff_algorithms="myers minimal patience histogram" __git_diff_algorithms="myers minimal patience histogram"
__git_diff_submodule_formats="diff log short"
__git_diff_common_options="--stat --numstat --shortstat --summary __git_diff_common_options="--stat --numstat --shortstat --summary
--patch-with-stat --name-only --name-status --color --patch-with-stat --name-only --name-status --color
--no-color --color-words --no-renames --check --no-color --color-words --no-renames --check
...@@ -1173,6 +1411,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary ...@@ -1173,6 +1411,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary
--dirstat --dirstat= --dirstat-by-file --dirstat --dirstat= --dirstat-by-file
--dirstat-by-file= --cumulative --dirstat-by-file= --cumulative
--diff-algorithm= --diff-algorithm=
--submodule --submodule=
" "
_git_diff () _git_diff ()
...@@ -1184,6 +1423,10 @@ _git_diff () ...@@ -1184,6 +1423,10 @@ _git_diff ()
__gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
return return
;; ;;
--submodule=*)
__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
return
;;
--*) --*)
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
--base --ours --theirs --no-index --base --ours --theirs --no-index
...@@ -1225,6 +1468,7 @@ __git_fetch_recurse_submodules="yes on-demand no" ...@@ -1225,6 +1468,7 @@ __git_fetch_recurse_submodules="yes on-demand no"
__git_fetch_options=" __git_fetch_options="
--quiet --verbose --append --upload-pack --force --keep --depth= --quiet --verbose --append --upload-pack --force --keep --depth=
--tags --no-tags --all --prune --dry-run --recurse-submodules= --tags --no-tags --all --prune --dry-run --recurse-submodules=
--unshallow --update-shallow
" "
_git_fetch () _git_fetch ()
...@@ -1274,7 +1518,7 @@ _git_fsck () ...@@ -1274,7 +1518,7 @@ _git_fsck ()
--*) --*)
__gitcomp " __gitcomp "
--tags --root --unreachable --cache --no-reflogs --full --tags --root --unreachable --cache --no-reflogs --full
--strict --verbose --lost-found --strict --verbose --lost-found --name-objects
" "
return return
;; ;;
...@@ -1296,8 +1540,43 @@ _git_gitk () ...@@ -1296,8 +1540,43 @@ _git_gitk ()
_gitk _gitk
} }
__git_match_ctag() { # Lists matching symbol names from a tag (as in ctags) file.
awk "/^${1//\//\\/}/ { print \$1 }" "$2" # 1: List symbol names matching this word.
# 2: The tag file to list symbol names from.
# 3: A prefix to be added to each listed symbol name (optional).
# 4: A suffix to be appended to each listed symbol name (optional).
__git_match_ctag () {
awk -v pfx="${3-}" -v sfx="${4-}" "
/^${1//\//\\/}/ { print pfx \$1 sfx }
" "$2"
}
# Complete symbol names from a tag file.
# Usage: __git_complete_symbol [<option>]...
# --tags=<file>: The tag file to list symbol names from instead of the
# default "tags".
# --pfx=<prefix>: A prefix to be added to each symbol name.
# --cur=<word>: The current symbol name to be completed. Defaults to
# the current word to be completed.
# --sfx=<suffix>: A suffix to be appended to each symbol name instead
# of the default space.
__git_complete_symbol () {
local tags=tags pfx="" cur_="${cur-}" sfx=" "
while test $# != 0; do
case "$1" in
--tags=*) tags="${1##--tags=}" ;;
--pfx=*) pfx="${1##--pfx=}" ;;
--cur=*) cur_="${1##--cur=}" ;;
--sfx=*) sfx="${1##--sfx=}" ;;
*) return 1 ;;
esac
shift
done
if test -r "$tags"; then
__gitcomp_direct "$(__git_match_ctag "$cur_" "$tags" "$pfx" "$sfx")"
fi
} }
_git_grep () _git_grep ()
...@@ -1318,6 +1597,8 @@ _git_grep () ...@@ -1318,6 +1597,8 @@ _git_grep ()
--max-depth --max-depth
--count --count
--and --or --not --all-match --and --or --not --all-match
--break --heading --show-function --function-context
--untracked --no-index
" "
return return
;; ;;
...@@ -1325,29 +1606,26 @@ _git_grep () ...@@ -1325,29 +1606,26 @@ _git_grep ()
case "$cword,$prev" in case "$cword,$prev" in
2,*|*,-*) 2,*|*,-*)
if test -r tags; then __git_complete_symbol && return
__gitcomp_nl "$(__git_match_ctag "$cur" tags)"
return
fi
;; ;;
esac esac
__gitcomp_nl "$(__git_refs)" __git_complete_refs
} }
_git_help () _git_help ()
{ {
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--all --info --man --web" __gitcomp "--all --guides --info --man --web"
return return
;; ;;
esac esac
__git_compute_all_commands __git_compute_all_commands
__gitcomp "$__git_all_commands $(__git_aliases) __gitcomp "$__git_all_commands $(__git_aliases)
attributes cli core-tutorial cvs-migration attributes cli core-tutorial cvs-migration
diffcore gitk glossary hooks ignore modules diffcore everyday gitk glossary hooks ignore modules
namespaces repository-layout tutorial tutorial-2 namespaces repository-layout revisions tutorial tutorial-2
workflows workflows
" "
} }
...@@ -1390,6 +1668,12 @@ _git_ls_files () ...@@ -1390,6 +1668,12 @@ _git_ls_files ()
_git_ls_remote () _git_ls_remote ()
{ {
case "$cur" in
--*)
__gitcomp "--heads --tags --refs --get-url --symref"
return
;;
esac
__gitcomp_nl "$(__git_remotes)" __gitcomp_nl "$(__git_remotes)"
} }
...@@ -1427,12 +1711,25 @@ __git_log_date_formats="relative iso8601 rfc2822 short local default raw" ...@@ -1427,12 +1711,25 @@ __git_log_date_formats="relative iso8601 rfc2822 short local default raw"
_git_log () _git_log ()
{ {
__git_has_doubledash && return __git_has_doubledash && return
__git_find_repo_path
local g="$(git rev-parse --git-dir 2>/dev/null)"
local merge="" local merge=""
if [ -f "$g/MERGE_HEAD" ]; then if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
merge="--merge" merge="--merge"
fi fi
case "$prev,$cur" in
-L,:*:*)
return # fall back to Bash filename completion
;;
-L,:*)
__git_complete_symbol --cur="${cur#:}" --sfx=":"
return
;;
-G,*|-S,*)
__git_complete_symbol
return
;;
esac
case "$cur" in case "$cur" in
--pretty=*|--format=*) --pretty=*|--format=*)
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
...@@ -1447,6 +1744,14 @@ _git_log () ...@@ -1447,6 +1744,14 @@ _git_log ()
__gitcomp "full short no" "" "${cur##--decorate=}" __gitcomp "full short no" "" "${cur##--decorate=}"
return return
;; ;;
--diff-algorithm=*)
__gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
return
;;
--submodule=*)
__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
return
;;
--*) --*)
__gitcomp " __gitcomp "
$__git_log_common_options $__git_log_common_options
...@@ -1458,6 +1763,7 @@ _git_log () ...@@ -1458,6 +1763,7 @@ _git_log ()
--relative-date --date= --relative-date --date=
--pretty= --format= --oneline --pretty= --format= --oneline
--show-signature --show-signature
--cherry-mark
--cherry-pick --cherry-pick
--graph --graph
--decorate --decorate= --decorate --decorate=
...@@ -1469,6 +1775,21 @@ _git_log () ...@@ -1469,6 +1775,21 @@ _git_log ()
" "
return return
;; ;;
-L:*:*)
return # fall back to Bash filename completion
;;
-L:*)
__git_complete_symbol --cur="${cur#-L:}" --sfx=":"
return
;;
-G*)
__git_complete_symbol --pfx="-G" --cur="${cur#-G}"
return
;;
-S*)
__git_complete_symbol --pfx="-S" --cur="${cur#-S}"
return
;;
esac esac
__git_complete_revlist __git_complete_revlist
} }
...@@ -1488,10 +1809,10 @@ _git_merge () ...@@ -1488,10 +1809,10 @@ _git_merge ()
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "$__git_merge_options __gitcomp "$__git_merge_options
--rerere-autoupdate --no-rerere-autoupdate --abort" --rerere-autoupdate --no-rerere-autoupdate --abort --continue"
return return
esac esac
__gitcomp_nl "$(__git_refs)" __git_complete_refs
} }
_git_mergetool () _git_mergetool ()
...@@ -1502,7 +1823,7 @@ _git_mergetool () ...@@ -1502,7 +1823,7 @@ _git_mergetool ()
return return
;; ;;
--*) --*)
__gitcomp "--tool=" __gitcomp "--tool= --prompt --no-prompt"
return return
;; ;;
esac esac
...@@ -1516,7 +1837,7 @@ _git_merge_base () ...@@ -1516,7 +1837,7 @@ _git_merge_base ()
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_refs)" __git_complete_refs
} }
_git_mv () _git_mv ()
...@@ -1554,7 +1875,7 @@ _git_notes () ...@@ -1554,7 +1875,7 @@ _git_notes ()
,*) ,*)
case "$prev" in case "$prev" in
--ref) --ref)
__gitcomp_nl "$(__git_refs)" __git_complete_refs
;; ;;
*) *)
__gitcomp "$subcommands --ref" __gitcomp "$subcommands --ref"
...@@ -1563,7 +1884,7 @@ _git_notes () ...@@ -1563,7 +1884,7 @@ _git_notes ()
;; ;;
add,--reuse-message=*|append,--reuse-message=*|\ add,--reuse-message=*|append,--reuse-message=*|\
add,--reedit-message=*|append,--reedit-message=*) add,--reedit-message=*|append,--reedit-message=*)
__gitcomp_nl "$(__git_refs)" "" "${cur#*=}" __git_complete_refs --cur="${cur#*=}"
;; ;;
add,--*|append,--*) add,--*|append,--*)
__gitcomp '--file= --message= --reedit-message= __gitcomp '--file= --message= --reedit-message=
...@@ -1582,7 +1903,7 @@ _git_notes () ...@@ -1582,7 +1903,7 @@ _git_notes ()
-m|-F) -m|-F)
;; ;;
*) *)
__gitcomp_nl "$(__git_refs)" __git_complete_refs
;; ;;
esac esac
;; ;;
...@@ -1610,7 +1931,7 @@ _git_pull () ...@@ -1610,7 +1931,7 @@ _git_pull ()
__git_complete_remote_or_refspec __git_complete_remote_or_refspec
} }
__git_push_recurse_submodules="check on-demand" __git_push_recurse_submodules="check on-demand only"
__git_complete_force_with_lease () __git_complete_force_with_lease ()
{ {
...@@ -1620,10 +1941,10 @@ __git_complete_force_with_lease () ...@@ -1620,10 +1941,10 @@ __git_complete_force_with_lease ()
--*=) --*=)
;; ;;
*:*) *:*)
__gitcomp_nl "$(__git_refs)" "" "${cur_#*:}" __git_complete_refs --cur="${cur_#*:}"
;; ;;
*) *)
__gitcomp_nl "$(__git_refs)" "" "$cur_" __git_complete_refs --cur="$cur_"
;; ;;
esac esac
} }
...@@ -1668,12 +1989,13 @@ _git_push () ...@@ -1668,12 +1989,13 @@ _git_push ()
_git_rebase () _git_rebase ()
{ {
local dir="$(__gitdir)" __git_find_repo_path
if [ -f "$dir"/rebase-merge/interactive ]; then if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
__gitcomp "--continue --skip --abort --edit-todo" __gitcomp "--continue --skip --abort --quit --edit-todo"
return return
elif [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then elif [ -d "$__git_repo_path"/rebase-apply ] || \
__gitcomp "--continue --skip --abort" [ -d "$__git_repo_path"/rebase-merge ]; then
__gitcomp "--continue --skip --abort --quit"
return return
fi fi
__git_complete_strategy && return __git_complete_strategy && return
...@@ -1698,7 +2020,7 @@ _git_rebase () ...@@ -1698,7 +2020,7 @@ _git_rebase ()
return return
esac esac
__gitcomp_nl "$(__git_refs)" __git_complete_refs
} }
_git_reflog () _git_reflog ()
...@@ -1709,7 +2031,7 @@ _git_reflog () ...@@ -1709,7 +2031,7 @@ _git_reflog ()
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" __gitcomp "$subcommands"
else else
__gitcomp_nl "$(__git_refs)" __git_complete_refs
fi fi
} }
...@@ -1720,9 +2042,7 @@ _git_send_email () ...@@ -1720,9 +2042,7 @@ _git_send_email ()
{ {
case "$prev" in case "$prev" in
--to|--cc|--bcc|--from) --to|--cc|--bcc|--from)
__gitcomp " __gitcomp "$(__git send-email --dump-aliases)"
$(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
"
return return
;; ;;
esac esac
...@@ -1752,9 +2072,7 @@ _git_send_email () ...@@ -1752,9 +2072,7 @@ _git_send_email ()
return return
;; ;;
--to=*|--cc=*|--bcc=*|--from=*) --to=*|--cc=*|--bcc=*|--from=*)
__gitcomp " __gitcomp "$(__git send-email --dump-aliases)" "" "${cur#--*=}"
$(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
" "" "${cur#--*=}"
return return
;; ;;
--*) --*)
...@@ -1779,6 +2097,56 @@ _git_stage () ...@@ -1779,6 +2097,56 @@ _git_stage ()
_git_add _git_add
} }
_git_status ()
{
local complete_opt
local untracked_state
case "$cur" in
--ignore-submodules=*)
__gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}"
return
;;
--untracked-files=*)
__gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
return
;;
--column=*)
__gitcomp "
always never auto column row plain dense nodense
" "" "${cur##--column=}"
return
;;
--*)
__gitcomp "
--short --branch --porcelain --long --verbose
--untracked-files= --ignore-submodules= --ignored
--column= --no-column
"
return
;;
esac
untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \
"$__git_untracked_file_modes" "status.showUntrackedFiles")"
case "$untracked_state" in
no)
# --ignored option does not matter
complete_opt=
;;
all|normal|*)
complete_opt="--cached --directory --no-empty-directory --others"
if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
complete_opt="$complete_opt --ignored --exclude=*"
fi
;;
esac
__git_complete_index_file "$complete_opt"
}
__git_config_get_set_variables () __git_config_get_set_variables ()
{ {
local prevword word config_file= c=$cword local prevword word config_file= c=$cword
...@@ -1798,7 +2166,7 @@ __git_config_get_set_variables () ...@@ -1798,7 +2166,7 @@ __git_config_get_set_variables ()
c=$((--c)) c=$((--c))
done done
git --git-dir="$(__gitdir)" config $config_file --name-only --list 2>/dev/null __git config $config_file --name-only --list
} }
_git_config () _git_config ()
...@@ -1809,7 +2177,7 @@ _git_config () ...@@ -1809,7 +2177,7 @@ _git_config ()
return return
;; ;;
branch.*.merge) branch.*.merge)
__gitcomp_nl "$(__git_refs)" __git_complete_refs
return return
;; ;;
branch.*.rebase) branch.*.rebase)
...@@ -1833,9 +2201,8 @@ _git_config () ...@@ -1833,9 +2201,8 @@ _git_config ()
remote.*.push) remote.*.push)
local remote="${prev#remote.}" local remote="${prev#remote.}"
remote="${remote%.push}" remote="${remote%.push}"
__gitcomp_nl "$(git --git-dir="$(__gitdir)" \ __gitcomp_nl "$(__git for-each-ref \
for-each-ref --format='%(refname):%(refname)' \ --format='%(refname):%(refname)' refs/heads)"
refs/heads)"
return return
;; ;;
pull.twohead|pull.octopus) pull.twohead|pull.octopus)
...@@ -1914,7 +2281,7 @@ _git_config () ...@@ -1914,7 +2281,7 @@ _git_config ()
;; ;;
branch.*) branch.*)
local pfx="${cur%.*}." cur_="${cur#*.}" local pfx="${cur%.*}." cur_="${cur#*.}"
__gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "." __gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
__gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_" __gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
return return
;; ;;
...@@ -1969,14 +2336,23 @@ _git_config () ...@@ -1969,14 +2336,23 @@ _git_config ()
esac esac
__gitcomp " __gitcomp "
add.ignoreErrors add.ignoreErrors
advice.amWorkDir
advice.commitBeforeMerge advice.commitBeforeMerge
advice.detachedHead advice.detachedHead
advice.implicitIdentity advice.implicitIdentity
advice.pushNonFastForward advice.pushAlreadyExists
advice.pushFetchFirst
advice.pushNeedsForce
advice.pushNonFFCurrent
advice.pushNonFFMatching
advice.pushUpdateRejected
advice.resolveConflict advice.resolveConflict
advice.rmHints
advice.statusHints advice.statusHints
advice.statusUoption
alias. alias.
am.keepcr am.keepcr
am.threeWay
apply.ignorewhitespace apply.ignorewhitespace
apply.whitespace apply.whitespace
branch.autosetupmerge branch.autosetupmerge
...@@ -2021,19 +2397,26 @@ _git_config () ...@@ -2021,19 +2397,26 @@ _git_config ()
color.status.added color.status.added
color.status.changed color.status.changed
color.status.header color.status.header
color.status.localBranch
color.status.nobranch color.status.nobranch
color.status.remoteBranch
color.status.unmerged color.status.unmerged
color.status.untracked color.status.untracked
color.status.updated color.status.updated
color.ui color.ui
commit.cleanup
commit.gpgSign
commit.status commit.status
commit.template commit.template
commit.verbose
core.abbrev core.abbrev
core.askpass core.askpass
core.attributesfile core.attributesfile
core.autocrlf core.autocrlf
core.bare core.bare
core.bigFileThreshold core.bigFileThreshold
core.checkStat
core.commentChar
core.compression core.compression
core.createObject core.createObject
core.deltaBaseCacheLimit core.deltaBaseCacheLimit
...@@ -2043,6 +2426,8 @@ _git_config () ...@@ -2043,6 +2426,8 @@ _git_config ()
core.fileMode core.fileMode
core.fsyncobjectfiles core.fsyncobjectfiles
core.gitProxy core.gitProxy
core.hideDotFiles
core.hooksPath
core.ignoreStat core.ignoreStat
core.ignorecase core.ignorecase
core.logAllRefUpdates core.logAllRefUpdates
...@@ -2050,20 +2435,30 @@ _git_config () ...@@ -2050,20 +2435,30 @@ _git_config ()
core.notesRef core.notesRef
core.packedGitLimit core.packedGitLimit
core.packedGitWindowSize core.packedGitWindowSize
core.packedRefsTimeout
core.pager core.pager
core.precomposeUnicode
core.preferSymlinkRefs core.preferSymlinkRefs
core.preloadindex core.preloadindex
core.protectHFS
core.protectNTFS
core.quotepath core.quotepath
core.repositoryFormatVersion core.repositoryFormatVersion
core.safecrlf core.safecrlf
core.sharedRepository core.sharedRepository
core.sparseCheckout core.sparseCheckout
core.splitIndex
core.sshCommand
core.symlinks core.symlinks
core.trustctime core.trustctime
core.untrackedCache core.untrackedCache
core.warnAmbiguousRefs core.warnAmbiguousRefs
core.whitespace core.whitespace
core.worktree core.worktree
credential.helper
credential.useHttpPath
credential.username
credentialCache.ignoreSIGHUP
diff.autorefreshindex diff.autorefreshindex
diff.external diff.external
diff.ignoreSubmodules diff.ignoreSubmodules
...@@ -2084,6 +2479,7 @@ _git_config () ...@@ -2084,6 +2479,7 @@ _git_config ()
format.attach format.attach
format.cc format.cc
format.coverLetter format.coverLetter
format.from
format.headers format.headers
format.numbered format.numbered
format.pretty format.pretty
...@@ -2094,15 +2490,19 @@ _git_config () ...@@ -2094,15 +2490,19 @@ _git_config ()
format.thread format.thread
format.to format.to
gc. gc.
gc.aggressiveDepth
gc.aggressiveWindow gc.aggressiveWindow
gc.auto gc.auto
gc.autoDetach
gc.autopacklimit gc.autopacklimit
gc.logExpiry
gc.packrefs gc.packrefs
gc.pruneexpire gc.pruneexpire
gc.reflogexpire gc.reflogexpire
gc.reflogexpireunreachable gc.reflogexpireunreachable
gc.rerereresolved gc.rerereresolved
gc.rerereunresolved gc.rerereunresolved
gc.worktreePruneExpire
gitcvs.allbinary gitcvs.allbinary
gitcvs.commitmsgannotation gitcvs.commitmsgannotation
gitcvs.dbTableNamePrefix gitcvs.dbTableNamePrefix
...@@ -2241,6 +2641,8 @@ _git_config () ...@@ -2241,6 +2641,8 @@ _git_config ()
sendemail.thread sendemail.thread
sendemail.to sendemail.to
sendemail.validate sendemail.validate
sendemail.smtpbatchsize
sendemail.smtprelogindelay
showbranch.default showbranch.default
status.relativePaths status.relativePaths
status.showUntrackedFiles status.showUntrackedFiles
...@@ -2259,31 +2661,79 @@ _git_config () ...@@ -2259,31 +2661,79 @@ _git_config ()
_git_remote () _git_remote ()
{ {
local subcommands="add rename remove set-head set-branches set-url show prune update" local subcommands="
add rename remove set-head set-branches
get-url set-url show prune update
"
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
__gitcomp "$subcommands" case "$cur" in
--*)
__gitcomp "--verbose"
;;
*)
__gitcomp "$subcommands"
;;
esac
return return
fi fi
case "$subcommand" in case "$subcommand,$cur" in
rename|remove|set-url|show|prune) add,--*)
__gitcomp_nl "$(__git_remotes)" __gitcomp "--track --master --fetch --tags --no-tags --mirror="
;;
add,*)
;;
set-head,--*)
__gitcomp "--auto --delete"
;;
set-branches,--*)
__gitcomp "--add"
;; ;;
set-head|set-branches) set-head,*|set-branches,*)
__git_complete_remote_or_refspec __git_complete_remote_or_refspec
;; ;;
update) update,--*)
__gitcomp "--prune"
;;
update,*)
__gitcomp "$(__git_get_config_variables "remotes")" __gitcomp "$(__git_get_config_variables "remotes")"
;; ;;
set-url,--*)
__gitcomp "--push --add --delete"
;;
get-url,--*)
__gitcomp "--push --all"
;;
prune,--*)
__gitcomp "--dry-run"
;;
*) *)
__gitcomp_nl "$(__git_remotes)"
;; ;;
esac esac
} }
_git_replace () _git_replace ()
{ {
__gitcomp_nl "$(__git_refs)" case "$cur" in
--*)
__gitcomp "--edit --graft --format= --list --delete"
return
;;
esac
__git_complete_refs
}
_git_rerere ()
{
local subcommands="clear forget diff remaining status gc"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if test -z "$subcommand"
then
__gitcomp "$subcommands"
return
fi
} }
_git_reset () _git_reset ()
...@@ -2292,27 +2742,30 @@ _git_reset () ...@@ -2292,27 +2742,30 @@ _git_reset ()
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--merge --mixed --hard --soft --patch" __gitcomp "--merge --mixed --hard --soft --patch --keep"
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_refs)" __git_complete_refs
} }
_git_revert () _git_revert ()
{ {
local dir="$(__gitdir)" __git_find_repo_path
if [ -f "$dir"/REVERT_HEAD ]; then if [ -f "$__git_repo_path"/REVERT_HEAD ]; then
__gitcomp "--continue --quit --abort" __gitcomp "--continue --quit --abort"
return return
fi fi
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--edit --mainline --no-edit --no-commit --signoff" __gitcomp "
--edit --mainline --no-edit --no-commit --signoff
--strategy= --strategy-option=
"
return return
;; ;;
esac esac
__gitcomp_nl "$(__git_refs)" __git_complete_refs
} }
_git_rm () _git_rm ()
...@@ -2336,7 +2789,7 @@ _git_shortlog () ...@@ -2336,7 +2789,7 @@ _git_shortlog ()
__gitcomp " __gitcomp "
$__git_log_common_options $__git_log_common_options
$__git_log_shortlog_options $__git_log_shortlog_options
--numbered --summary --numbered --summary --email
" "
return return
;; ;;
...@@ -2358,6 +2811,10 @@ _git_show () ...@@ -2358,6 +2811,10 @@ _git_show ()
__gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}" __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
return return
;; ;;
--submodule=*)
__gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
return
;;
--*) --*)
__gitcomp "--pretty= --format= --abbrev-commit --oneline __gitcomp "--pretty= --format= --abbrev-commit --oneline
--show-signature --show-signature
...@@ -2388,7 +2845,7 @@ _git_show_branch () ...@@ -2388,7 +2845,7 @@ _git_show_branch ()
_git_stash () _git_stash ()
{ {
local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked' local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
local subcommands='save list show apply clear drop pop create branch' local subcommands='push save list show apply clear drop pop create branch'
local subcommand="$(__git_find_on_cmdline "$subcommands")" local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then if [ -z "$subcommand" ]; then
case "$cur" in case "$cur" in
...@@ -2403,6 +2860,9 @@ _git_stash () ...@@ -2403,6 +2860,9 @@ _git_stash ()
esac esac
else else
case "$subcommand,$cur" in case "$subcommand,$cur" in
push,--*)
__gitcomp "$save_opts --message"
;;
save,--*) save,--*)
__gitcomp "$save_opts" __gitcomp "$save_opts"
;; ;;
...@@ -2416,14 +2876,14 @@ _git_stash () ...@@ -2416,14 +2876,14 @@ _git_stash ()
;; ;;
branch,*) branch,*)
if [ $cword -eq 3 ]; then if [ $cword -eq 3 ]; then
__gitcomp_nl "$(__git_refs)"; __git_complete_refs
else else
__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ __gitcomp_nl "$(__git stash list \
| sed -n -e 's/:.*//p')" | sed -n -e 's/:.*//p')"
fi fi
;; ;;
show,*|apply,*|drop,*|pop,*) show,*|apply,*|drop,*|pop,*)
__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ __gitcomp_nl "$(__git stash list \
| sed -n -e 's/:.*//p')" | sed -n -e 's/:.*//p')"
;; ;;
*) *)
...@@ -2437,10 +2897,11 @@ _git_submodule () ...@@ -2437,10 +2897,11 @@ _git_submodule ()
__git_has_doubledash && return __git_has_doubledash && return
local subcommands="add status init deinit update summary foreach sync" local subcommands="add status init deinit update summary foreach sync"
if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
case "$cur" in case "$cur" in
--*) --*)
__gitcomp "--quiet --cached" __gitcomp "--quiet"
;; ;;
*) *)
__gitcomp "$subcommands" __gitcomp "$subcommands"
...@@ -2448,6 +2909,33 @@ _git_submodule () ...@@ -2448,6 +2909,33 @@ _git_submodule ()
esac esac
return return
fi fi
case "$subcommand,$cur" in
add,--*)
__gitcomp "--branch --force --name --reference --depth"
;;
status,--*)
__gitcomp "--cached --recursive"
;;
deinit,--*)
__gitcomp "--force --all"
;;
update,--*)
__gitcomp "
--init --remote --no-fetch
--recommend-shallow --no-recommend-shallow
--force --rebase --merge --reference --depth --recursive --jobs
"
;;
summary,--*)
__gitcomp "--cached --files --summary-limit"
;;
foreach,--*|sync,--*)
__gitcomp "--recursive"
;;
*)
;;
esac
} }
_git_svn () _git_svn ()
...@@ -2468,14 +2956,14 @@ _git_svn () ...@@ -2468,14 +2956,14 @@ _git_svn ()
--no-metadata --use-svm-props --use-svnsync-props --no-metadata --use-svm-props --use-svnsync-props
--log-window-size= --no-checkout --quiet --log-window-size= --no-checkout --quiet
--repack-flags --use-log-author --localtime --repack-flags --use-log-author --localtime
--add-author-from
--ignore-paths= --include-paths= $remote_opts --ignore-paths= --include-paths= $remote_opts
" "
local init_opts=" local init_opts="
--template= --shared= --trunk= --tags= --template= --shared= --trunk= --tags=
--branches= --stdlayout --minimize-url --branches= --stdlayout --minimize-url
--no-metadata --use-svm-props --use-svnsync-props --no-metadata --use-svm-props --use-svnsync-props
--rewrite-root= --prefix= --use-log-author --rewrite-root= --prefix= $remote_opts
--add-author-from $remote_opts
" "
local cmt_opts=" local cmt_opts="
--edit --rmdir --find-copies-harder --copy-similarity= --edit --rmdir --find-copies-harder --copy-similarity=
...@@ -2555,7 +3043,7 @@ _git_tag () ...@@ -2555,7 +3043,7 @@ _git_tag ()
i="${words[c]}" i="${words[c]}"
case "$i" in case "$i" in
-d|-v) -d|-v)
__gitcomp_nl "$(__git_tags)" __gitcomp_direct "$(__git_tags "" "$cur" " ")"
return return
;; ;;
-f) -f)
...@@ -2570,11 +3058,11 @@ _git_tag () ...@@ -2570,11 +3058,11 @@ _git_tag ()
;; ;;
-*|tag) -*|tag)
if [ $f = 1 ]; then if [ $f = 1 ]; then
__gitcomp_nl "$(__git_tags)" __gitcomp_direct "$(__git_tags "" "$cur" " ")"
fi fi
;; ;;
*) *)
__gitcomp_nl "$(__git_refs)" __git_complete_refs
;; ;;
esac esac
...@@ -2582,8 +3070,8 @@ _git_tag () ...@@ -2582,8 +3070,8 @@ _git_tag ()
--*) --*)
__gitcomp " __gitcomp "
--list --delete --verify --annotate --message --file --list --delete --verify --annotate --message --file
--sign --cleanup --local-user --force --column --sort --sign --cleanup --local-user --force --column --sort=
--contains --points-at --contains --no-contains --points-at --merged --no-merged --create-reflog
" "
;; ;;
esac esac
...@@ -2594,9 +3082,36 @@ _git_whatchanged () ...@@ -2594,9 +3082,36 @@ _git_whatchanged ()
_git_log _git_log
} }
_git_worktree ()
{
local subcommands="add list lock prune unlock"
local subcommand="$(__git_find_on_cmdline "$subcommands")"
if [ -z "$subcommand" ]; then
__gitcomp "$subcommands"
else
case "$subcommand,$cur" in
add,--*)
__gitcomp "--detach"
;;
list,--*)
__gitcomp "--porcelain"
;;
lock,--*)
__gitcomp "--reason"
;;
prune,--*)
__gitcomp "--dry-run --expire --verbose"
;;
*)
;;
esac
fi
}
__git_main () __git_main ()
{ {
local i c=1 command __git_dir local i c=1 command __git_dir __git_repo_path
local __git_C_args C_args_count=0
while [ $c -lt $cword ]; do while [ $c -lt $cword ]; do
i="${words[c]}" i="${words[c]}"
...@@ -2606,6 +3121,10 @@ __git_main () ...@@ -2606,6 +3121,10 @@ __git_main ()
--bare) __git_dir="." ;; --bare) __git_dir="." ;;
--help) command="help"; break ;; --help) command="help"; break ;;
-c|--work-tree|--namespace) ((c++)) ;; -c|--work-tree|--namespace) ((c++)) ;;
-C) __git_C_args[C_args_count++]=-C
((c++))
__git_C_args[C_args_count++]="${words[c]}"
;;
-*) ;; -*) ;;
*) command="$i"; break ;; *) command="$i"; break ;;
esac esac
...@@ -2613,6 +3132,17 @@ __git_main () ...@@ -2613,6 +3132,17 @@ __git_main ()
done done
if [ -z "$command" ]; then if [ -z "$command" ]; then
case "$prev" in
--git-dir|-C|--work-tree)
# these need a path argument, let's fall back to
# Bash filename completion
return
;;
-c|--namespace)
# we don't support completing these options' arguments
return
;;
esac
case "$cur" in case "$cur" in
--*) __gitcomp " --*) __gitcomp "
--paginate --paginate
...@@ -2638,13 +3168,13 @@ __git_main () ...@@ -2638,13 +3168,13 @@ __git_main ()
fi fi
local completion_func="_git_${command//-/_}" local completion_func="_git_${command//-/_}"
declare -f $completion_func >/dev/null && $completion_func && return declare -f $completion_func >/dev/null 2>/dev/null && $completion_func && return
local expansion=$(__git_aliased_command "$command") local expansion=$(__git_aliased_command "$command")
if [ -n "$expansion" ]; then if [ -n "$expansion" ]; then
words[1]=$expansion words[1]=$expansion
completion_func="_git_${expansion//-/_}" completion_func="_git_${expansion//-/_}"
declare -f $completion_func >/dev/null && $completion_func declare -f $completion_func >/dev/null 2>/dev/null && $completion_func
fi fi
} }
...@@ -2652,9 +3182,11 @@ __gitk_main () ...@@ -2652,9 +3182,11 @@ __gitk_main ()
{ {
__git_has_doubledash && return __git_has_doubledash && return
local g="$(__gitdir)" local __git_repo_path
__git_find_repo_path
local merge="" local merge=""
if [ -f "$g/MERGE_HEAD" ]; then if [ -f "$__git_repo_path/MERGE_HEAD" ]; then
merge="--merge" merge="--merge"
fi fi
case "$cur" in case "$cur" in
...@@ -2701,6 +3233,15 @@ if [[ -n ${ZSH_VERSION-} ]]; then ...@@ -2701,6 +3233,15 @@ if [[ -n ${ZSH_VERSION-} ]]; then
esac esac
} }
__gitcomp_direct ()
{
emulate -L zsh
local IFS=$'\n'
compset -P '*[=:]'
compadd -Q -- ${=1} && _ret=0
}
__gitcomp_nl () __gitcomp_nl ()
{ {
emulate -L zsh emulate -L zsh
...@@ -2771,6 +3312,6 @@ __git_complete gitk __gitk_main ...@@ -2771,6 +3312,6 @@ __git_complete gitk __gitk_main
# when the user has tab-completed the executable name and consequently # when the user has tab-completed the executable name and consequently
# included the '.exe' suffix. # included the '.exe' suffix.
# #
if [[ "$OSTYPE" = cygwin* ]]; then if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
__git_complete git.exe __git_main __git_complete git.exe __git_main
fi fi
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
# contains relative to newer annotated tag (v1.6.3.2~35) # contains relative to newer annotated tag (v1.6.3.2~35)
# branch relative to newer tag or branch (master~4) # branch relative to newer tag or branch (master~4)
# describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f) # describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f)
# tag relative to any older tag (v1.6.3.1-13-gdd42c2f)
# default exactly matching tag # default exactly matching tag
# #
# If you would like a colored hint about the current dirty state, set # If you would like a colored hint about the current dirty state, set
...@@ -355,8 +356,8 @@ __git_ps1 () ...@@ -355,8 +356,8 @@ __git_ps1 ()
# incorrect.) # incorrect.)
# #
local ps1_expanded=yes local ps1_expanded=yes
[ -z "$ZSH_VERSION" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no [ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
[ -z "$BASH_VERSION" ] || shopt -q promptvars || ps1_expanded=no [ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no
local repo_info rev_parse_exit_code local repo_info rev_parse_exit_code
repo_info="$(git rev-parse --git-dir --is-inside-git-dir \ repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
...@@ -368,7 +369,7 @@ __git_ps1 () ...@@ -368,7 +369,7 @@ __git_ps1 ()
return $exit return $exit
fi fi
local short_sha local short_sha=""
if [ "$rev_parse_exit_code" = "0" ]; then if [ "$rev_parse_exit_code" = "0" ]; then
short_sha="${repo_info##*$'\n'}" short_sha="${repo_info##*$'\n'}"
repo_info="${repo_info%$'\n'*}" repo_info="${repo_info%$'\n'*}"
...@@ -443,6 +444,8 @@ __git_ps1 () ...@@ -443,6 +444,8 @@ __git_ps1 ()
git describe --contains HEAD ;; git describe --contains HEAD ;;
(branch) (branch)
git describe --contains --all HEAD ;; git describe --contains --all HEAD ;;
(tag)
git describe --tags HEAD ;;
(describe) (describe)
git describe HEAD ;; git describe HEAD ;;
(* | default) (* | default)
......
dir=$(dirname $0) dir="${0:A:h}"
source $dir/../git/git.plugin.zsh source "$dir/git-prompt.sh"
source $dir/git-prompt.sh
function git_prompt_info() { function git_prompt_info() {
dirty="$(parse_git_dirty)" dirty="$(parse_git_dirty)"
__git_ps1 "${ZSH_THEME_GIT_PROMPT_PREFIX//\%/%%}%s${dirty//\%/%%}${ZSH_THEME_GIT_PROMPT_SUFFIX//\%/%%}" __git_ps1 "${ZSH_THEME_GIT_PROMPT_PREFIX//\%/%%}%s${dirty//\%/%%}${ZSH_THEME_GIT_PROMPT_SUFFIX//\%/%%}"
} }
unset dir
...@@ -11,14 +11,14 @@ This plugin supports working with GitHub from the command line. It provides a fe ...@@ -11,14 +11,14 @@ This plugin supports working with GitHub from the command line. It provides a fe
* `empty_gh` - Creates a new empty repo (with a `README.md`) and pushes it to GitHub * `empty_gh` - Creates a new empty repo (with a `README.md`) and pushes it to GitHub
* `new_gh` - Initializes an existing directory as a repo and pushes it to GitHub * `new_gh` - Initializes an existing directory as a repo and pushes it to GitHub
* `exist_gh` - Takes an existing repo and pushes it to GitHub * `exist_gh` - Takes an existing repo and pushes it to GitHub
* `git.io` - Shortens a URL using [git.io](http://git.io) * `git.io` - Shortens a URL using [git.io](https://git.io)
## Installation ## Installation
[Hub](http://github.com/github/hub) needs to be installed if you want to use it. On OS X with Homebrew, this can be done with `brew install hub`. The `hub` completion definition needs to be added to your `$FPATH` before initializing OMZ. [Hub](https://github.com/github/hub) needs to be installed if you want to use it. On OS X with Homebrew, this can be done with `brew install hub`. The `hub` completion definition needs to be added to your `$FPATH` before initializing OMZ.
The [`github` Ruby gem](http://github.com/defunkt/github-gem) needs to be installed if you want to use it. The [`github` Ruby gem](https://github.com/defunkt/github-gem) needs to be installed if you want to use it.
### Configuration ### Configuration
......
...@@ -58,6 +58,7 @@ __hub_setup_zsh_fns () { ...@@ -58,6 +58,7 @@ __hub_setup_zsh_fns () {
- set1 \ - set1 \
'-m[message]' \ '-m[message]' \
'-F[file]' \ '-F[file]' \
'--no-edit[use first commit message for pull request title/description]' \
'-a[user]' \ '-a[user]' \
'-M[milestone]' \ '-M[milestone]' \
'-l[labels]' \ '-l[labels]' \
...@@ -84,11 +85,16 @@ __hub_setup_zsh_fns () { ...@@ -84,11 +85,16 @@ __hub_setup_zsh_fns () {
hub_commands=( hub_commands=(
alias:'show shell instructions for wrapping git' alias:'show shell instructions for wrapping git'
pull-request:'open a pull request on GitHub' pull-request:'open a pull request on GitHub'
pr:'list or checkout a GitHub pull request'
issue:'list or create a GitHub issue'
release:'list or create a GitHub release'
fork:'fork origin repo on GitHub' fork:'fork origin repo on GitHub'
create:'create new repo on GitHub for the current project' create:'create new repo on GitHub for the current project'
delete:'delete a GitHub repo'
browse:'browse the project on GitHub' browse:'browse the project on GitHub'
compare:'open GitHub compare view' compare:'open GitHub compare view'
ci-status:'lookup commit in GitHub Status API' ci-status:'show status of GitHub checks for a commit'
sync:'update local branches from upstream'
) )
_describe -t hub-commands 'hub command' hub_commands && ret=0 _describe -t hub-commands 'hub command' hub_commands && ret=0
...@@ -110,11 +116,16 @@ __hub_setup_bash_fns () { ...@@ -110,11 +116,16 @@ __hub_setup_bash_fns () {
cat <<-EOF cat <<-EOF
alias alias
pull-request pull-request
pr
issue
release
fork fork
create create
delete
browse browse
compare compare
ci-status ci-status
sync
EOF EOF
__git_list_all_commands_without_hub __git_list_all_commands_without_hub
} }
......
# Set up hub wrapper for git, if it is available; http://github.com/github/hub # Set up hub wrapper for git, if it is available; https://github.com/github/hub
if [ "$commands[(I)hub]" ]; then if (( $+commands[hub] )); then
if hub --version &>/dev/null; then alias git=hub
eval $(hub alias -s zsh)
fi
fi fi
# Functions ################################################################# # Functions #################################################################
...@@ -38,7 +36,7 @@ new_gh() { # [DIRECTORY] ...@@ -38,7 +36,7 @@ new_gh() { # [DIRECTORY]
print '.*'"\n"'*~' >> .gitignore print '.*'"\n"'*~' >> .gitignore
git add [^.]* \ git add [^.]* \
|| return || return
git add .gitignore \ git add -f .gitignore \
|| return || return
git commit -m 'Initial commit.' \ git commit -m 'Initial commit.' \
|| return || return
...@@ -65,7 +63,7 @@ exist_gh() { # [DIRECTORY] ...@@ -65,7 +63,7 @@ exist_gh() { # [DIRECTORY]
# git.io "GitHub URL" # git.io "GitHub URL"
# #
# Shorten GitHub url, example: # Shorten GitHub url, example:
# https://github.com/nvogel/dotzsh > http://git.io/8nU25w # https://github.com/nvogel/dotzsh > https://git.io/8nU25w
# source: https://github.com/nvogel/dotzsh # source: https://github.com/nvogel/dotzsh
# documentation: https://github.com/blog/985-git-io-github-url-shortener # documentation: https://github.com/blog/985-git-io-github-url-shortener
# #
......
# gitignore
This plugin enables you the use of [gitignore.io](https://www.gitignore.io/) from the command line. You need an active internet connection.
To use it, add `gitignore` to the plugins array in your zshrc file:
```zsh
plugins=(... gitignore)
```
## Plugin commands
* `gi list`: List all the currently supported gitignore.io templates.
* `gi [TEMPLATENAME]`: Show git-ignore output on the command line, e.g. `gi java` to exclude class and package files.
* `gi [TEMPLATENAME] >> .gitignore`: Appending programming language settings to your projects .gitignore.
function gi() { curl -sL https://www.gitignore.io/api/${(j:,:)@} } function gi() { curl -fL https://www.gitignore.io/api/${(j:,:)@} }
_gitignoreio_get_command_list() { _gitignoreio_get_command_list() {
curl -sL https://www.gitignore.io/api/list | tr "," "\n" curl -sfL https://www.gitignore.io/api/list | tr "," "\n"
} }
_gitignoreio () { _gitignoreio () {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Expands all glob expressions, subcommands and aliases (including global). Expands all glob expressions, subcommands and aliases (including global).
Idea from: http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html. Idea from: https://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html.
## Usage ## Usage
......
The go plugin is deprecated. Use the [golang plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/golang) instead.
# Golang plugin
This plugin adds completion for the [Go Programming Language](https://golang.org/),
as well as some aliases for common Golang commands.
To use it, add `golang` to the plugins array in your zshrc file:
```zsh
plugins=(... golang)
```
## Aliases
| Alias | Command | Description |
| ------- | ----------------------- | ------------------------------------------------------------- |
| gob | `go build` | Build your code |
| goc | `go clean` | Removes object files from package source directories |
| god | `go doc` | Prints documentation comments |
| gof | `go fmt` | Gofmt formats (aligns and indents) Go programs. |
| gofa | `go fmt ./...` | Run go fmt for all packages in current directory, recursively |
| gog | `go get` | Downloads packages and then installs them to $GOPATH |
| goi | `go install` | Compiles and installs packages to $GOPATH |
| gol | `go list` | Lists Go packages |
| gop | `cd $GOPATH` | Takes you to $GOPATH |
| gopb | `cd $GOPATH/bin` | Takes you to $GOPATH/bin |
| gops | `cd $GOPATH/src` | Takes you to $GOPATH/src |
| gor | `go run` | Compiles and runs your code |
| got | `go test` | Runs tests |
| gov | `go vet` | Vet examines Go source code and reports suspicious constructs |
...@@ -28,6 +28,7 @@ __go_tool_complete() { ...@@ -28,6 +28,7 @@ __go_tool_complete() {
'help[display help]' 'help[display help]'
'install[compile and install packages and dependencies]' 'install[compile and install packages and dependencies]'
'list[list packages]' 'list[list packages]'
'mod[modules maintenance]'
'run[compile and run Go program]' 'run[compile and run Go program]'
'test[test packages]' 'test[test packages]'
'tool[run specified go tool]' 'tool[run specified go tool]'
...@@ -83,7 +84,7 @@ __go_tool_complete() { ...@@ -83,7 +84,7 @@ __go_tool_complete() {
"-x[print remove commands as it executes them]" \ "-x[print remove commands as it executes them]" \
"*:importpaths:__go_packages" "*:importpaths:__go_packages"
;; ;;
fix|fmt|list|vet) fix|fmt|vet)
_alternative ':importpaths:__go_packages' ':files:_path_files -g "*.go"' _alternative ':importpaths:__go_packages' ':files:_path_files -g "*.go"'
;; ;;
install) install)
...@@ -124,8 +125,84 @@ __go_tool_complete() { ...@@ -124,8 +125,84 @@ __go_tool_complete() {
"-memprofilerate[set heap profiling rate]:number" \ "-memprofilerate[set heap profiling rate]:number" \
"*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }" "*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
;; ;;
list)
_arguments -s -w : \
"-f[alternative format for the list]:format" \
"-json[print data in json format]" \
"-compiled[set CompiledGoFiles to the Go source files presented to the compiler]" \
"-deps[iterate over not just the named packages but also all their dependencies]" \
"-e[change the handling of erroneous packages]" \
"-export[set the Export field to the name of a file containing up-to-date export information for the given package]" \
"-find[identify the named packages but not resolve their dependencies]" \
"-test[report not only the named packages but also their test binaries]" \
"-m[list modules instead of packages]" \
"-u[adds information about available upgrades]" \
"-versions[set the Module's Versions field to a list of all known versions of that module]:number" \
"*:importpaths:__go_packages"
;;
mod)
typeset -a mod_commands
mod_commands+=(
'download[download modules to local cache]'
'edit[edit go.mod from tools or scripts]'
'graph[print module requirement graph]'
'init[initialize new module in current directory]'
'tidy[add missing and remove unused modules]'
'vendor[make vendored copy of dependencies]'
'verify[verify dependencies have expected content]'
'why[explain why packages or modules are needed]'
)
if (( CURRENT == 3 )); then
_values 'go mod commands' ${mod_commands[@]} "help[display help]"
return
fi
case ${words[3]} in
help)
_values 'go mod commands' ${mod_commands[@]}
;;
download)
_arguments -s -w : \
"-json[print a sequence of JSON objects standard output]" \
"*:flags"
;;
edit)
_arguments -s -w : \
"-fmt[reformat the go.mod file]" \
"-module[change the module's path]" \
"-replace[=old{@v}=new{@v} add a replacement of the given module path and version pair]:name" \
"-dropreplace[=old{@v}=new{@v} drop a replacement of the given module path and version pair]:name" \
"-go[={version} set the expected Go language version]:number" \
"-print[print the final go.mod in its text format]" \
"-json[print the final go.mod file in JSON format]" \
"*:flags"
;;
graph)
;;
init)
;;
tidy)
_arguments -s -w : \
"-v[print information about removed modules]" \
"*:flags"
;;
vendor)
_arguments -s -w : \
"-v[print the names of vendored]" \
"*:flags"
;;
verify)
;;
why)
_arguments -s -w : \
"-m[treats the arguments as a list of modules and finds a path to any package in each of the modules]" \
"-vendor[exclude tests of dependencies]" \
"*:importpaths:__go_packages"
;;
esac
;;
help) help)
_values "${commands[@]}" \ _values "${commands[@]}" \
'environment[show Go environment variables available]' \
'gopath[GOPATH environment variable]' \ 'gopath[GOPATH environment variable]' \
'packages[description of package lists]' \ 'packages[description of package lists]' \
'remote[remote import path syntax]' \ 'remote[remote import path syntax]' \
...@@ -135,7 +212,7 @@ __go_tool_complete() { ...@@ -135,7 +212,7 @@ __go_tool_complete() {
run) run)
_arguments -s -w : \ _arguments -s -w : \
${build_flags[@]} \ ${build_flags[@]} \
'*:file:_path_files -g "*.go"' '*:file:_files -g "*.go"'
;; ;;
tool) tool)
if (( CURRENT == 3 )); then if (( CURRENT == 3 )); then
...@@ -184,10 +261,14 @@ alias gob='go build' ...@@ -184,10 +261,14 @@ alias gob='go build'
alias goc='go clean' alias goc='go clean'
alias god='go doc' alias god='go doc'
alias gof='go fmt' alias gof='go fmt'
alias gofa='go fmt . ./...' alias gofa='go fmt ./...'
alias gog='go get' alias gog='go get'
alias goi='go install' alias goi='go install'
alias gol='go list' alias gol='go list'
alias gom='go mod'
alias gop='cd $GOPATH'
alias gopb='cd $GOPATH/bin'
alias gops='cd $GOPATH/src'
alias gor='go run' alias gor='go run'
alias got='go test' alias got='go test'
alias gov='go vet' alias gov='go vet'
# gpg-agent
Enables [GPG's gpg-agent](https://www.gnupg.org/documentation/manuals/gnupg/) if it is not running.
To use it, add gpg-agent to the plugins array of your zshrc file:
```
plugins=(... gpg-agent)
```
# Enable gpg-agent if it is not running # Enable gpg-agent if it is not running-
GPG_AGENT_SOCKET="${XDG_RUNTIME_DIR}/gnupg/S.gpg-agent.ssh" # --use-standard-socket will work from version 2 upwards
if [ ! -S $GPG_AGENT_SOCKET ]; then
gpg-agent --daemon >/dev/null 2>&1 AGENT_SOCK=$(gpgconf --list-dirs | grep agent-socket | cut -d : -f 2)
export GPG_TTY=$(tty)
if [[ ! -S $AGENT_SOCK ]]; then
gpg-agent --daemon --use-standard-socket &>/dev/null
fi fi
export GPG_TTY=$TTY
# Set SSH to use gpg-agent if it is configured to do so # Set SSH to use gpg-agent if it's enabled
GNUPGCONFIG="${GNUPGHOME:-"$HOME/.gnupg"}/gpg-agent.conf" GNUPGCONFIG="${GNUPGHOME:-"$HOME/.gnupg"}/gpg-agent.conf"
if [ -r "$GNUPGCONFIG" ] && grep -q enable-ssh-support "$GNUPGCONFIG"; then if [[ -r $GNUPGCONFIG ]] && command grep -q enable-ssh-support "$GNUPGCONFIG"; then
export SSH_AUTH_SOCK="$AGENT_SOCK.ssh"
unset SSH_AGENT_PID unset SSH_AGENT_PID
export SSH_AUTH_SOCK=$GPG_AGENT_SOCKET
fi fi
## Gradle Plugin
This plugin adds completions and aliases for [Gradle](https://gradle.org/).
To use it, add `gradle` to the plugins array in your zshrc file:
```zsh
plugins=(... gradle)
```
## Usage
This plugin creates an alias `gradle` which is used to determine whether the current working directory has a gradlew file. If gradlew is present it will be used otherwise `gradle` is used directly. Gradle tasks can be executed directly without regard for whether it is `gradle` or `gradlew`
Examples:
```zsh
gradle test
gradle build
```
## Completion
The completion provided for this plugin caches the parsed tasks into a file named `.gradletasknamecache` in the current working directory, so you might want to add that to your `.gitignore` file so that it's not accidentally committed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment