-
-
Save tjt263/e71a890a091e628bc5519743a9bb07aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__expand_tilde_by_ref () | |
{ | |
if [[ ${!1} == \~* ]]; then | |
if [[ ${!1} == */* ]]; then | |
eval $1="${!1/%\/*}"/'${!1#*/}'; | |
else | |
eval $1="${!1}"; | |
fi; | |
fi | |
} | |
__get_cword_at_cursor_by_ref () | |
{ | |
local cword words=(); | |
__reassemble_comp_words_by_ref "$1" words cword; | |
local i cur index=$COMP_POINT lead=${COMP_LINE:0:$COMP_POINT}; | |
if [[ $index -gt 0 && ( -n $lead && -n ${lead//[[:space:]]} ) ]]; then | |
cur=$COMP_LINE; | |
for ((i = 0; i <= cword; ++i )) | |
do | |
while [[ ${#cur} -ge ${#words[i]} && "${cur:0:${#words[i]}}" != "${words[i]}" ]]; do | |
cur="${cur:1}"; | |
((index--)); | |
done; | |
if [[ $i -lt $cword ]]; then | |
local old_size=${#cur}; | |
cur="${cur#"${words[i]}"}"; | |
local new_size=${#cur}; | |
index=$(( index - old_size + new_size )); | |
fi; | |
done; | |
[[ -n $cur && ! -n ${cur//[[:space:]]} ]] && cur=; | |
[[ $index -lt 0 ]] && index=0; | |
fi; | |
local "$2" "$3" "$4" && _upvars -a${#words[@]} $2 "${words[@]}" -v $3 "$cword" -v $4 "${cur:0:$index}" | |
} | |
__git_aliased_command () | |
{ | |
local word cmdline=$(git --git-dir="$(__gitdir)" config --get "alias.$1"); | |
for word in $cmdline; | |
do | |
case "$word" in | |
\!gitk | gitk) | |
echo "gitk"; | |
return | |
;; | |
\!*) | |
: shell command alias | |
;; | |
-*) | |
: option | |
;; | |
*=*) | |
: setting env | |
;; | |
git) | |
: git itself | |
;; | |
*) | |
echo "$word"; | |
return | |
;; | |
esac; | |
done | |
} | |
__git_aliases () | |
{ | |
local i IFS=' | |
'; | |
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "alias\..*" 2>/dev/null); | |
do | |
case "$i" in | |
alias.*) | |
i="${i#alias.}"; | |
echo "${i/ */}" | |
;; | |
esac; | |
done | |
} | |
__git_complete_file () | |
{ | |
__git_complete_revlist_file | |
} | |
__git_complete_remote_or_refspec () | |
{ | |
local cur_="$cur" cmd="${words[1]}"; | |
local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0; | |
if [ "$cmd" = "remote" ]; then | |
((c++)); | |
fi; | |
while [ $c -lt $cword ]; do | |
i="${words[c]}"; | |
case "$i" in | |
--mirror) | |
[ "$cmd" = "push" ] && no_complete_refspec=1 | |
;; | |
--all) | |
case "$cmd" in | |
push) | |
no_complete_refspec=1 | |
;; | |
fetch) | |
COMPREPLY=(); | |
return | |
;; | |
*) | |
;; | |
esac | |
;; | |
-*) | |
;; | |
*) | |
remote="$i"; | |
break | |
;; | |
esac; | |
((c++)); | |
done; | |
if [ -z "$remote" ]; then | |
__gitcomp_nl "$(__git_remotes)"; | |
return; | |
fi; | |
if [ $no_complete_refspec = 1 ]; then | |
COMPREPLY=(); | |
return; | |
fi; | |
[ "$remote" = "." ] && remote=; | |
case "$cur_" in | |
*:*) | |
case "$COMP_WORDBREAKS" in | |
*:*) | |
: great | |
;; | |
*) | |
pfx="${cur_%%:*}:" | |
;; | |
esac; | |
cur_="${cur_#*:}"; | |
lhs=0 | |
;; | |
+*) | |
pfx="+"; | |
cur_="${cur_#+}" | |
;; | |
esac; | |
case "$cmd" in | |
fetch) | |
if [ $lhs = 1 ]; then | |
__gitcomp_nl "$(__git_refs2 "$remote")" "$pfx" "$cur_"; | |
else | |
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; | |
fi | |
;; | |
pull | remote) | |
if [ $lhs = 1 ]; then | |
__gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"; | |
else | |
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; | |
fi | |
;; | |
push) | |
if [ $lhs = 1 ]; then | |
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_"; | |
else | |
__gitcomp_nl "$(__git_refs "$remote")" "$pfx" "$cur_"; | |
fi | |
;; | |
esac | |
} | |
__git_complete_revlist () | |
{ | |
__git_complete_revlist_file | |
} | |
__git_complete_revlist_file () | |
{ | |
local pfx ls ref cur_="$cur"; | |
case "$cur_" in | |
*..?*:*) | |
return | |
;; | |
?*:*) | |
ref="${cur_%%:*}"; | |
cur_="${cur_#*:}"; | |
case "$cur_" in | |
?*/*) | |
pfx="${cur_%/*}"; | |
cur_="${cur_##*/}"; | |
ls="$ref:$pfx"; | |
pfx="$pfx/" | |
;; | |
*) | |
ls="$ref" | |
;; | |
esac; | |
case "$COMP_WORDBREAKS" in | |
*:*) | |
: great | |
;; | |
*) | |
pfx="$ref:$pfx" | |
;; | |
esac; | |
local IFS=' | |
'; | |
COMPREPLY=($(compgen -P "$pfx" -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" | sed '/^100... blob /{ | |
s,^.* ,, | |
s,$, , | |
} | |
/^120000 blob /{ | |
s,^.* ,, | |
s,$, , | |
} | |
/^040000 tree /{ | |
s,^.* ,, | |
s,$,/, | |
} | |
s/^.* //')" -- "$cur_")) | |
;; | |
*...*) | |
pfx="${cur_%...*}..."; | |
cur_="${cur_#*...}"; | |
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" | |
;; | |
*..*) | |
pfx="${cur_%..*}.."; | |
cur_="${cur_#*..}"; | |
__gitcomp_nl "$(__git_refs)" "$pfx" "$cur_" | |
;; | |
*) | |
__gitcomp_nl "$(__git_refs)" | |
;; | |
esac | |
} | |
__git_complete_strategy () | |
{ | |
__git_compute_merge_strategies; | |
case "$prev" in | |
-s | --strategy) | |
__gitcomp "$__git_merge_strategies"; | |
return 0 | |
;; | |
esac; | |
case "$cur" in | |
--strategy=*) | |
__gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"; | |
return 0 | |
;; | |
esac; | |
return 1 | |
} | |
__git_compute_all_commands () | |
{ | |
test -n "$__git_all_commands" || __git_all_commands=$(__git_list_all_commands) | |
} | |
__git_compute_merge_strategies () | |
{ | |
test -n "$__git_merge_strategies" || __git_merge_strategies=$(__git_list_merge_strategies) | |
} | |
__git_compute_porcelain_commands () | |
{ | |
__git_compute_all_commands; | |
test -n "$__git_porcelain_commands" || __git_porcelain_commands=$(__git_list_porcelain_commands) | |
} | |
__git_config_get_set_variables () | |
{ | |
local prevword word config_file= c=$cword; | |
while [ $c -gt 1 ]; do | |
word="${words[c]}"; | |
case "$word" in | |
--global | --system | --file=*) | |
config_file="$word"; | |
break | |
;; | |
-f | --file) | |
config_file="$word $prevword"; | |
break | |
;; | |
esac; | |
prevword=$word; | |
c=$((--c)); | |
done; | |
git --git-dir="$(__gitdir)" config $config_file --list 2> /dev/null | while read -r line; do | |
case "$line" in | |
*.*=*) | |
echo "${line/=*/}" | |
;; | |
esac; | |
done | |
} | |
__git_find_on_cmdline () | |
{ | |
local word subcommand c=1; | |
while [ $c -lt $cword ]; do | |
word="${words[c]}"; | |
for subcommand in $1; | |
do | |
if [ "$subcommand" = "$word" ]; then | |
echo "$subcommand"; | |
return; | |
fi; | |
done; | |
((c++)); | |
done | |
} | |
__git_has_doubledash () | |
{ | |
local c=1; | |
while [ $c -lt $cword ]; do | |
if [ "--" = "${words[c]}" ]; then | |
return 0; | |
fi; | |
((c++)); | |
done; | |
return 1 | |
} | |
__git_heads () | |
{ | |
local dir="$(__gitdir)"; | |
if [ -d "$dir" ]; then | |
git --git-dir="$dir" for-each-ref --format='%(refname:short)' refs/heads; | |
return; | |
fi | |
} | |
__git_list_all_commands () | |
{ | |
local i IFS=" "' | |
'; | |
for i in $(git help -a|egrep '^ [a-zA-Z0-9]'); | |
do | |
case $i in | |
*--*) | |
: helper pattern | |
;; | |
*) | |
echo $i | |
;; | |
esac; | |
done | |
} | |
__git_list_merge_strategies () | |
{ | |
git merge -s help 2>&1 | sed -n -e '/[Aa]vailable strategies are: /,/^$/{ | |
s/\.$// | |
s/.*:// | |
s/^[ ]*// | |
s/[ ]*$// | |
p | |
}' | |
} | |
__git_list_porcelain_commands () | |
{ | |
local i IFS=" "' | |
'; | |
__git_compute_all_commands; | |
for i in "help" $__git_all_commands; | |
do | |
case $i in | |
*--*) | |
: helper pattern | |
;; | |
applymbox) | |
: ask gittus | |
;; | |
applypatch) | |
: ask gittus | |
;; | |
archimport) | |
: import | |
;; | |
cat-file) | |
: plumbing | |
;; | |
check-attr) | |
: plumbing | |
;; | |
check-ref-format) | |
: plumbing | |
;; | |
checkout-index) | |
: plumbing | |
;; | |
commit-tree) | |
: plumbing | |
;; | |
count-objects) | |
: infrequent | |
;; | |
cvsexportcommit) | |
: export | |
;; | |
cvsimport) | |
: import | |
;; | |
cvsserver) | |
: daemon | |
;; | |
daemon) | |
: daemon | |
;; | |
diff-files) | |
: plumbing | |
;; | |
diff-index) | |
: plumbing | |
;; | |
diff-tree) | |
: plumbing | |
;; | |
fast-import) | |
: import | |
;; | |
fast-export) | |
: export | |
;; | |
fsck-objects) | |
: plumbing | |
;; | |
fetch-pack) | |
: plumbing | |
;; | |
fmt-merge-msg) | |
: plumbing | |
;; | |
for-each-ref) | |
: plumbing | |
;; | |
hash-object) | |
: plumbing | |
;; | |
http-*) | |
: transport | |
;; | |
index-pack) | |
: plumbing | |
;; | |
init-db) | |
: deprecated | |
;; | |
local-fetch) | |
: plumbing | |
;; | |
lost-found) | |
: infrequent | |
;; | |
ls-files) | |
: plumbing | |
;; | |
ls-remote) | |
: plumbing | |
;; | |
ls-tree) | |
: plumbing | |
;; | |
mailinfo) | |
: plumbing | |
;; | |
mailsplit) | |
: plumbing | |
;; | |
merge-*) | |
: plumbing | |
;; | |
mktree) | |
: plumbing | |
;; | |
mktag) | |
: plumbing | |
;; | |
pack-objects) | |
: plumbing | |
;; | |
pack-redundant) | |
: plumbing | |
;; | |
pack-refs) | |
: plumbing | |
;; | |
parse-remote) | |
: plumbing | |
;; | |
patch-id) | |
: plumbing | |
;; | |
peek-remote) | |
: plumbing | |
;; | |
prune) | |
: plumbing | |
;; | |
prune-packed) | |
: plumbing | |
;; | |
quiltimport) | |
: import | |
;; | |
read-tree) | |
: plumbing | |
;; | |
receive-pack) | |
: plumbing | |
;; | |
remote-*) | |
: transport | |
;; | |
repo-config) | |
: deprecated | |
;; | |
rerere) | |
: plumbing | |
;; | |
rev-list) | |
: plumbing | |
;; | |
rev-parse) | |
: plumbing | |
;; | |
runstatus) | |
: plumbing | |
;; | |
sh-setup) | |
: internal | |
;; | |
shell) | |
: daemon | |
;; | |
show-ref) | |
: plumbing | |
;; | |
send-pack) | |
: plumbing | |
;; | |
show-index) | |
: plumbing | |
;; | |
ssh-*) | |
: transport | |
;; | |
stripspace) | |
: plumbing | |
;; | |
symbolic-ref) | |
: plumbing | |
;; | |
tar-tree) | |
: deprecated | |
;; | |
unpack-file) | |
: plumbing | |
;; | |
unpack-objects) | |
: plumbing | |
;; | |
update-index) | |
: plumbing | |
;; | |
update-ref) | |
: plumbing | |
;; | |
update-server-info) | |
: daemon | |
;; | |
upload-archive) | |
: plumbing | |
;; | |
upload-pack) | |
: plumbing | |
;; | |
write-tree) | |
: plumbing | |
;; | |
var) | |
: infrequent | |
;; | |
verify-pack) | |
: infrequent | |
;; | |
verify-tag) | |
: plumbing | |
;; | |
*) | |
echo $i | |
;; | |
esac; | |
done | |
} | |
__git_match_ctag () | |
{ | |
awk "/^${1////\\/}/ { print \$1 }" "$2" | |
} | |
__git_pretty_aliases () | |
{ | |
local i IFS=' | |
'; | |
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "pretty\..*" 2>/dev/null); | |
do | |
case "$i" in | |
pretty.*) | |
i="${i#pretty.}"; | |
echo "${i/ */}" | |
;; | |
esac; | |
done | |
} | |
__git_ps1 () | |
{ | |
local g="$(__gitdir)"; | |
if [ -n "$g" ]; then | |
local r=""; | |
local b=""; | |
if [ -f "$g/rebase-merge/interactive" ]; then | |
r="|REBASE-i"; | |
b="$(cat "$g/rebase-merge/head-name")"; | |
else | |
if [ -d "$g/rebase-merge" ]; then | |
r="|REBASE-m"; | |
b="$(cat "$g/rebase-merge/head-name")"; | |
else | |
if [ -d "$g/rebase-apply" ]; then | |
if [ -f "$g/rebase-apply/rebasing" ]; then | |
r="|REBASE"; | |
else | |
if [ -f "$g/rebase-apply/applying" ]; then | |
r="|AM"; | |
else | |
r="|AM/REBASE"; | |
fi; | |
fi; | |
else | |
if [ -f "$g/MERGE_HEAD" ]; then | |
r="|MERGING"; | |
else | |
if [ -f "$g/CHERRY_PICK_HEAD" ]; then | |
r="|CHERRY-PICKING"; | |
else | |
if [ -f "$g/BISECT_LOG" ]; then | |
r="|BISECTING"; | |
fi; | |
fi; | |
fi; | |
fi; | |
b="$(git symbolic-ref HEAD 2>/dev/null)" || { | |
b="$( | |
case "${GIT_PS1_DESCRIBE_STYLE-}" in | |
(contains) | |
git describe --contains HEAD ;; | |
(branch) | |
git describe --contains --all HEAD ;; | |
(describe) | |
git describe HEAD ;; | |
(* | default) | |
git describe --tags --exact-match HEAD ;; | |
esac 2>/dev/null)" || b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." || b="unknown"; | |
b="($b)" | |
}; | |
fi; | |
fi; | |
local w=""; | |
local i=""; | |
local s=""; | |
local u=""; | |
local c=""; | |
local p=""; | |
if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then | |
if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then | |
c="BARE:"; | |
else | |
b="GIT_DIR!"; | |
fi; | |
else | |
if [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then | |
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then | |
if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then | |
git diff --no-ext-diff --quiet --exit-code || w="*"; | |
if git rev-parse --quiet --verify HEAD > /dev/null; then | |
git diff-index --cached --quiet HEAD -- || i="+"; | |
else | |
i="#"; | |
fi; | |
fi; | |
fi; | |
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then | |
git rev-parse --verify refs/stash > /dev/null 2>&1 && s="$"; | |
fi; | |
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then | |
if [ -n "$(git ls-files --others --exclude-standard)" ]; then | |
u="%"; | |
fi; | |
fi; | |
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then | |
__git_ps1_show_upstream; | |
fi; | |
fi; | |
fi; | |
local f="$w$i$s$u"; | |
printf -- "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"; | |
fi | |
} | |
__git_ps1_show_upstream () | |
{ | |
local key value; | |
local svn_remote svn_url_pattern count n; | |
local upstream=git legacy="" verbose=""; | |
svn_remote=(); | |
local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"; | |
while read -r key value; do | |
case "$key" in | |
bash.showupstream) | |
GIT_PS1_SHOWUPSTREAM="$value"; | |
if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then | |
p=""; | |
return; | |
fi | |
;; | |
svn-remote.*.url) | |
svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value"; | |
svn_url_pattern+="\\|$value"; | |
upstream=svn+git | |
;; | |
esac; | |
done <<< "$output"; | |
for option in ${GIT_PS1_SHOWUPSTREAM}; | |
do | |
case "$option" in | |
git | svn) | |
upstream="$option" | |
;; | |
verbose) | |
verbose=1 | |
;; | |
legacy) | |
legacy=1 | |
;; | |
esac; | |
done; | |
case "$upstream" in | |
git) | |
upstream="@{upstream}" | |
;; | |
svn*) | |
local svn_upstream=($(git log --first-parent -1 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)); | |
if [[ 0 -ne ${#svn_upstream[@]} ]]; then | |
svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}; | |
svn_upstream=${svn_upstream%@*}; | |
local n_stop="${#svn_remote[@]}"; | |
for ((n=1; n <= n_stop; n++)) | |
do | |
svn_upstream=${svn_upstream#${svn_remote[$n]}}; | |
done; | |
if [[ -z "$svn_upstream" ]]; then | |
upstream=${GIT_SVN_ID:-git-svn}; | |
else | |
upstream=${svn_upstream#/}; | |
fi; | |
else | |
if [[ "svn+git" = "$upstream" ]]; then | |
upstream="@{upstream}"; | |
fi; | |
fi | |
;; | |
esac; | |
if [[ -z "$legacy" ]]; then | |
count="$(git rev-list --count --left-right "$upstream"...HEAD 2>/dev/null)"; | |
else | |
local commits; | |
if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)"; then | |
local commit behind=0 ahead=0; | |
for commit in $commits; | |
do | |
case "$commit" in | |
"<"*) | |
((behind++)) | |
;; | |
*) | |
((ahead++)) | |
;; | |
esac; | |
done; | |
count="$behind $ahead"; | |
else | |
count=""; | |
fi; | |
fi; | |
if [[ -z "$verbose" ]]; then | |
case "$count" in | |
"") | |
p="" | |
;; | |
"0 0") | |
p="=" | |
;; | |
"0 "*) | |
p=">" | |
;; | |
*" 0") | |
p="<" | |
;; | |
*) | |
p="<>" | |
;; | |
esac; | |
else | |
case "$count" in | |
"") | |
p="" | |
;; | |
"0 0") | |
p=" u=" | |
;; | |
"0 "*) | |
p=" u+${count#0 }" | |
;; | |
*" 0") | |
p=" u-${count% 0}" | |
;; | |
*) | |
p=" u+${count#* }-${count% *}" | |
;; | |
esac; | |
fi | |
} | |
__git_reassemble_comp_words_by_ref () | |
{ | |
local exclude i j first; | |
exclude="${1//[^$COMP_WORDBREAKS]}"; | |
cword_=$COMP_CWORD; | |
if [ -z "$exclude" ]; then | |
words_=("${COMP_WORDS[@]}"); | |
return; | |
fi; | |
for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)) | |
do | |
first=t; | |
while [ $i -gt 0 ] && [ -n "${COMP_WORDS[$i]}" ] && [ "${COMP_WORDS[$i]//[^$exclude]}" = "${COMP_WORDS[$i]}" ]; do | |
if [ $j -ge 2 ] && [ -n "$first" ]; then | |
((j--)); | |
fi; | |
first=; | |
words_[$j]=${words_[j]}${COMP_WORDS[i]}; | |
if [ $i = $COMP_CWORD ]; then | |
cword_=$j; | |
fi; | |
if (($i < ${#COMP_WORDS[@]} - 1)); then | |
((i++)); | |
else | |
return; | |
fi; | |
done; | |
words_[$j]=${words_[j]}${COMP_WORDS[i]}; | |
if [ $i = $COMP_CWORD ]; then | |
cword_=$j; | |
fi; | |
done | |
} | |
__git_refs () | |
{ | |
local i hash dir="$(__gitdir "${1-}")" track="${2-}"; | |
local format refs; | |
if [ -d "$dir" ]; then | |
case "$cur" in | |
refs | refs/*) | |
format="refname"; | |
refs="${cur%/*}"; | |
track="" | |
;; | |
*) | |
for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; | |
do | |
if [ -e "$dir/$i" ]; then | |
echo $i; | |
fi; | |
done; | |
format="refname:short"; | |
refs="refs/tags refs/heads refs/remotes" | |
;; | |
esac; | |
git --git-dir="$dir" for-each-ref --format="%($format)" $refs; | |
if [ -n "$track" ]; then | |
local ref entry; | |
git --git-dir="$dir" for-each-ref --shell --format="ref=%(refname:short)" "refs/remotes/" | while read -r entry; do | |
eval "$entry"; | |
ref="${ref#*/}"; | |
if [[ "$ref" == "$cur"* ]]; then | |
echo "$ref"; | |
fi; | |
done | uniq -u; | |
fi; | |
return; | |
fi; | |
case "$cur" in | |
refs | refs/*) | |
git ls-remote "$dir" "$cur*" 2> /dev/null | while read -r hash i; do | |
case "$i" in | |
*^{}) | |
;; | |
*) | |
echo "$i" | |
;; | |
esac; | |
done | |
;; | |
*) | |
git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2> /dev/null | while read -r hash i; do | |
case "$i" in | |
*^{}) | |
;; | |
refs/*) | |
echo "${i#refs/*/}" | |
;; | |
*) | |
echo "$i" | |
;; | |
esac; | |
done | |
;; | |
esac | |
} | |
__git_refs2 () | |
{ | |
local i; | |
for i in $(__git_refs "$1"); | |
do | |
echo "$i:$i"; | |
done | |
} | |
__git_refs_remotes () | |
{ | |
local i hash; | |
git ls-remote "$1" 'refs/heads/*' 2> /dev/null | while read -r hash i; do | |
echo "$i:refs/remotes/$1/${i#refs/heads/}"; | |
done | |
} | |
__git_remotes () | |
{ | |
local i IFS=' | |
' d="$(__gitdir)"; | |
test -d "$d/remotes" && ls -1 "$d/remotes"; | |
for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); | |
do | |
i="${i#remote.}"; | |
echo "${i/.url*/}"; | |
done | |
} | |
__git_tags () | |
{ | |
local dir="$(__gitdir)"; | |
if [ -d "$dir" ]; then | |
git --git-dir="$dir" for-each-ref --format='%(refname:short)' refs/tags; | |
return; | |
fi | |
} | |
__gitcomp () | |
{ | |
local cur_="${3-$cur}"; | |
case "$cur_" in | |
--*=) | |
COMPREPLY=() | |
;; | |
*) | |
local IFS=' | |
'; | |
COMPREPLY=($(compgen -P "${2-}" -W "$(__gitcomp_1 "${1-}" "${4-}")" -- "$cur_")) | |
;; | |
esac | |
} | |
__gitcomp_1 () | |
{ | |
local c IFS=' '' '' | |
'; | |
for c in $1; | |
do | |
case "$c$2" in | |
--*=*) | |
printf %s' | |
' "$c$2" | |
;; | |
*.) | |
printf %s' | |
' "$c$2" | |
;; | |
*) | |
printf %s' | |
' "$c$2 " | |
;; | |
esac; | |
done | |
} | |
__gitcomp_nl () | |
{ | |
local IFS=' | |
'; | |
COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}")) | |
} | |
__gitdir () | |
{ | |
if [ -z "${1-}" ]; then | |
if [ -n "${__git_dir-}" ]; then | |
echo "$__git_dir"; | |
else | |
if [ -d .git ]; then | |
echo .git; | |
else | |
git rev-parse --git-dir 2> /dev/null; | |
fi; | |
fi; | |
else | |
if [ -d "$1/.git" ]; then | |
echo "$1/.git"; | |
else | |
echo "$1"; | |
fi; | |
fi | |
} | |
__ltrim_colon_completions () | |
{ | |
if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then | |
local colon_word=${1%${1##*:}}; | |
local i=${#COMPREPLY[*]}; | |
while [[ $((--i)) -ge 0 ]]; do | |
COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"}; | |
done; | |
fi | |
} | |
__parse_options () | |
{ | |
local option option2 i IFS=' | |
,/|'; | |
option=; | |
for i in $1; | |
do | |
case $i in | |
---*) | |
break | |
;; | |
--?*) | |
option=$i; | |
break | |
;; | |
-?*) | |
[[ -n $option ]] || option=$i | |
;; | |
*) | |
break | |
;; | |
esac; | |
done; | |
[[ -n $option ]] || return 0; | |
IFS=' | |
'; | |
if [[ $option =~ (\[((no|dont)-?)\]). ]]; then | |
option2=${option/"${BASH_REMATCH[1]}"/}; | |
option2=${option2%%[<{().[]*}; | |
printf '%s\n' "${option2/=*/=}"; | |
option=${option/"${BASH_REMATCH[1]}"/"${BASH_REMATCH[2]}"}; | |
fi; | |
option=${option%%[<{().[]*}; | |
printf '%s\n' "${option/=*/=}" | |
} | |
__reassemble_comp_words_by_ref () | |
{ | |
local exclude i j line ref; | |
if [[ -n $1 ]]; then | |
exclude="${1//[^$COMP_WORDBREAKS]}"; | |
fi; | |
eval $3=$COMP_CWORD; | |
if [[ -n $exclude ]]; then | |
line=$COMP_LINE; | |
for ((i=0, j=0; i < ${#COMP_WORDS[@]}; i++, j++)) | |
do | |
while [[ $i -gt 0 && ${COMP_WORDS[$i]} == +([$exclude]) ]]; do | |
[[ $line != [' ']* ]] && (( j >= 2 )) && ((j--)); | |
ref="$2[$j]"; | |
eval $2[$j]=\${!ref}\${COMP_WORDS[i]}; | |
[[ $i == $COMP_CWORD ]] && eval $3=$j; | |
line=${line#*"${COMP_WORDS[$i]}"}; | |
[[ $line == [' ']* ]] && ((j++)); | |
(( $i < ${#COMP_WORDS[@]} - 1)) && ((i++)) || break 2; | |
done; | |
ref="$2[$j]"; | |
eval $2[$j]=\${!ref}\${COMP_WORDS[i]}; | |
line=${line#*"${COMP_WORDS[i]}"}; | |
[[ $i == $COMP_CWORD ]] && eval $3=$j; | |
done; | |
else | |
eval $2=\( \"\${COMP_WORDS[@]}\" \); | |
fi | |
} | |
_a2dismod () | |
{ | |
local cur; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
_apache2_modsites mods-enabled | |
} | |
_a2dissite () | |
{ | |
local cur; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
_apache2_modsites sites-enabled | |
} | |
_a2enmod () | |
{ | |
local cur; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
_apache2_modsites mods-available | |
} | |
_a2ensite () | |
{ | |
local cur; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
_apache2_modsites sites-available | |
} | |
_allowed_groups () | |
{ | |
if _complete_as_root; then | |
local IFS=' | |
'; | |
COMPREPLY=($( compgen -g -- "$1" )); | |
else | |
local IFS=' | |
'; | |
COMPREPLY=($( compgen -W "$( id -Gn 2>/dev/null || groups 2>/dev/null )" -- "$1" )); | |
fi | |
} | |
_allowed_users () | |
{ | |
if _complete_as_root; then | |
local IFS=' | |
'; | |
COMPREPLY=($( compgen -u -- "${1:-$cur}" )); | |
else | |
local IFS=' | |
'; | |
COMPREPLY=($( compgen -W "$( id -un 2>/dev/null || whoami 2>/dev/null )" -- "${1:-$cur}" )); | |
fi | |
} | |
_apache2_modsites () | |
{ | |
COMPREPLY=($( compgen -W '$( command ls /etc/apache2/$1 2>/dev/null \ | |
| sed -e 's/[.]load$//' -e 's/[.]conf$//' )' -- $cur )) | |
} | |
_available_interfaces () | |
{ | |
local cmd; | |
if [[ ${1:-} == -w ]]; then | |
cmd="iwconfig"; | |
else | |
if [[ ${1:-} == -a ]]; then | |
cmd="ifconfig"; | |
else | |
cmd="ifconfig -a"; | |
fi; | |
fi; | |
COMPREPLY=($( eval PATH="$PATH:/sbin" $cmd 2>/dev/null | awk '/^[^ \t]/ { print $1 }' )); | |
COMPREPLY=($( compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur" )) | |
} | |
_cd () | |
{ | |
local cur prev words cword; | |
_init_completion || return; | |
local IFS=' | |
' i j k; | |
compopt -o filenames; | |
if [[ -z "${CDPATH:-}" || "$cur" == ?(.)?(.)/* ]]; then | |
_filedir -d; | |
return 0; | |
fi; | |
local -r mark_dirs=$(_rl_enabled mark-directories && echo y); | |
local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y); | |
for i in ${CDPATH//:/' | |
'}; | |
do | |
k="${#COMPREPLY[@]}"; | |
for j in $( compgen -d $i/$cur ); | |
do | |
if [[ ( -n $mark_symdirs && -h $j || -n $mark_dirs && ! -h $j ) && ! -d ${j#$i/} ]]; then | |
j+="/"; | |
fi; | |
COMPREPLY[k++]=${j#$i/}; | |
done; | |
done; | |
_filedir -d; | |
if [[ ${#COMPREPLY[@]} -eq 1 ]]; then | |
i=${COMPREPLY[0]}; | |
if [[ "$i" == "$cur" && $i != "*/" ]]; then | |
COMPREPLY[0]="${i}/"; | |
fi; | |
fi; | |
return 0 | |
} | |
_cd_devices () | |
{ | |
COMPREPLY+=($( compgen -f -d -X "!*/?([amrs])cd*" -- "${cur:-/dev/}" )) | |
} | |
_command () | |
{ | |
local offset i; | |
offset=1; | |
for ((i=1; i <= COMP_CWORD; i++ )) | |
do | |
if [[ "${COMP_WORDS[i]}" != -* ]]; then | |
offset=$i; | |
break; | |
fi; | |
done; | |
_command_offset $offset | |
} | |
_command_offset () | |
{ | |
local word_offset=$1 i j; | |
for ((i=0; i < $word_offset; i++ )) | |
do | |
for ((j=0; j <= ${#COMP_LINE}; j++ )) | |
do | |
[[ "$COMP_LINE" == "${COMP_WORDS[i]}"* ]] && break; | |
COMP_LINE=${COMP_LINE:1}; | |
((COMP_POINT--)); | |
done; | |
COMP_LINE=${COMP_LINE#"${COMP_WORDS[i]}"}; | |
((COMP_POINT-=${#COMP_WORDS[i]})); | |
done; | |
for ((i=0; i <= COMP_CWORD - $word_offset; i++ )) | |
do | |
COMP_WORDS[i]=${COMP_WORDS[i+$word_offset]}; | |
done; | |
for ((i; i <= COMP_CWORD; i++ )) | |
do | |
unset COMP_WORDS[i]; | |
done; | |
((COMP_CWORD -= $word_offset)); | |
COMPREPLY=(); | |
local cur; | |
_get_comp_words_by_ref cur; | |
if [[ $COMP_CWORD -eq 0 ]]; then | |
local IFS=' | |
'; | |
compopt -o filenames; | |
COMPREPLY=($( compgen -d -c -- "$cur" )); | |
else | |
local cmd=${COMP_WORDS[0]} compcmd=${COMP_WORDS[0]}; | |
local cspec=$( complete -p $cmd 2>/dev/null ); | |
if [[ ! -n $cspec && $cmd == */* ]]; then | |
cspec=$( complete -p ${cmd##*/} 2>/dev/null ); | |
[[ -n $cspec ]] && compcmd=${cmd##*/}; | |
fi; | |
if [[ ! -n $cspec ]]; then | |
compcmd=${cmd##*/}; | |
_completion_loader $compcmd; | |
cspec=$( complete -p $compcmd 2>/dev/null ); | |
fi; | |
if [[ -n $cspec ]]; then | |
if [[ ${cspec#* -F } != $cspec ]]; then | |
local func=${cspec#*-F }; | |
func=${func%% *}; | |
if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then | |
$func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}"; | |
else | |
$func $cmd "${COMP_WORDS[${#COMP_WORDS[@]}-1]}"; | |
fi; | |
local opt t; | |
while true; do | |
t=${cspec#*-o }; | |
if [[ $t == $cspec ]]; then | |
break; | |
fi; | |
opt=${t%% *}; | |
compopt -o $opt; | |
cspec=${t#$opt}; | |
done; | |
else | |
cspec=${cspec#complete}; | |
cspec=${cspec%%$compcmd}; | |
COMPREPLY=($( eval compgen "$cspec" -- '$cur' )); | |
fi; | |
else | |
if [[ ${#COMPREPLY[@]} -eq 0 ]]; then | |
_minimal; | |
fi; | |
fi; | |
fi | |
} | |
_complete_as_root () | |
{ | |
[[ $EUID -eq 0 || -n ${root_command:-} ]] | |
} | |
_completion_loader () | |
{ | |
local compdir=./completions; | |
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"; | |
. "$compdir/${1##*/}" &>/dev/null && return 124; | |
complete -F _minimal "$1" && return 124 | |
} | |
_configured_interfaces () | |
{ | |
if [[ -f /etc/debian_version ]]; then | |
COMPREPLY=($( compgen -W "$( sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces )" -- "$cur" )); | |
else | |
if [[ -f /etc/SuSE-release ]]; then | |
COMPREPLY=($( compgen -W "$( printf '%s\n' /etc/sysconfig/network/ifcfg-* | sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" )); | |
else | |
if [[ -f /etc/pld-release ]]; then | |
COMPREPLY=($( compgen -W "$( command ls -B /etc/sysconfig/interfaces | sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" )); | |
else | |
COMPREPLY=($( compgen -W "$( printf '%s\n' /etc/sysconfig/network-scripts/ifcfg-* | sed -ne 's|.*ifcfg-\(.*\)|\1|p' )" -- "$cur" )); | |
fi; | |
fi; | |
fi | |
} | |
_count_args () | |
{ | |
local i cword words; | |
__reassemble_comp_words_by_ref "$1" words cword; | |
args=1; | |
for i in "${words[@]:1:cword-1}"; | |
do | |
[[ "$i" != -* ]] && args=$(($args+1)); | |
done | |
} | |
_debconf_show () | |
{ | |
local cur; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
COMPREPLY=($( compgen -W '--listowners --listdbs --db=' -- $cur ) $( apt-cache pkgnames -- $cur )) | |
} | |
_dkms () | |
{ | |
local cur prev command module i; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
if [[ $COMP_CWORD -eq 1 ]]; then | |
COMPREPLY=($( compgen -W "add autoinstall remove build install uninstall match mkdriverdisk mktarball ldtarball mkrpm mkdeb mkdsc mkkmp status" -- $cur )); | |
else | |
prev=${COMP_WORDS[COMP_CWORD-1]}; | |
command=${COMP_WORDS[1]}; | |
case $prev in | |
-m) | |
if [ "$command" = 'add' ]; then | |
_filename_parts '.*-.*' 1; | |
else | |
_subdirectories /var/lib/dkms; | |
fi; | |
return 0 | |
;; | |
-v) | |
for ((i=1; i < COMP_CWORD; i++ )) | |
do | |
if [[ "${COMP_WORDS[i]}" == -m ]]; then | |
module=${COMP_WORDS[i+1]}; | |
break; | |
fi; | |
done; | |
if [ -n "$module" ]; then | |
if [ "$command" = 'add' ]; then | |
_filename_parts "$module-.*" 2; | |
else | |
_subdirectories /var/lib/dkms/$module; | |
fi; | |
return 0; | |
fi | |
;; | |
-k) | |
_kernels; | |
return 0 | |
;; | |
-@\(c | -spec | -archive | -config\)) | |
_filedir; | |
return 0 | |
;; | |
--kernelsourcedir) | |
_filedir -d; | |
return 0 | |
;; | |
esac; | |
if [[ "$cur" == -* ]]; then | |
case $command in | |
add) | |
options='-c --rpm_safe_upgrade' | |
;; | |
remove) | |
options='--rpm_safe_upgrade' | |
;; | |
build) | |
options='--config' | |
;; | |
mkdriverdisk) | |
options='-d --distro -r --release --size' | |
;; | |
ldtarball) | |
options='--archive --force' | |
;; | |
mktarball) | |
options='--source-only --binaries-only' | |
;; | |
mkrpm) | |
options='--source-only' | |
;; | |
mkkmp) | |
options='--spec' | |
;; | |
match) | |
options='--templatekernel' | |
;; | |
esac; | |
options="$options -m -v -k -a --arch -q --quiet -V --version --all --no-prepare-kernel --no-clean-kernel --kernelsourcedir --directive"; | |
COMPREPLY=($( compgen -W "$options" -- $cur )); | |
fi; | |
fi | |
} | |
_dvd_devices () | |
{ | |
COMPREPLY+=($( compgen -f -d -X "!*/?(r)dvd*" -- "${cur:-/dev/}" )) | |
} | |
_expand () | |
{ | |
if [[ "$cur" == \~*/* ]]; then | |
eval cur=$cur 2> /dev/null; | |
else | |
if [[ "$cur" == \~* ]]; then | |
cur=${cur#\~}; | |
COMPREPLY=($( compgen -P '~' -u "$cur" )); | |
[[ ${#COMPREPLY[@]} -eq 1 ]] && eval COMPREPLY[0]=${COMPREPLY[0]}; | |
return ${#COMPREPLY[@]}; | |
fi; | |
fi | |
} | |
_filedir () | |
{ | |
local i IFS=' | |
' xspec; | |
_tilde "$cur" || return 0; | |
local -a toks; | |
local quoted x tmp; | |
_quote_readline_by_ref "$cur" quoted; | |
x=$( compgen -d -- "$quoted" ) && while read -r tmp; do | |
toks+=("$tmp"); | |
done <<< "$x"; | |
if [[ "$1" != -d ]]; then | |
xspec=${1:+"!*.@($1|${1^^})"}; | |
x=$( compgen -f -X "$xspec" -- $quoted ) && while read -r tmp; do | |
toks+=("$tmp"); | |
done <<< "$x"; | |
fi; | |
[[ -n ${COMP_FILEDIR_FALLBACK:-} && -n "$1" && "$1" != -d && ${#toks[@]} -lt 1 ]] && x=$( compgen -f -- $quoted ) && while read -r tmp; do | |
toks+=("$tmp"); | |
done <<< "$x"; | |
if [[ ${#toks[@]} -ne 0 ]]; then | |
compopt -o filenames 2> /dev/null; | |
COMPREPLY+=("${toks[@]}"); | |
fi | |
} | |
_filedir_xspec () | |
{ | |
local cur prev words cword; | |
_init_completion || return; | |
_expand || return 0; | |
local IFS=' | |
' xspec=${_xspecs[${1##*/}]} tmp; | |
local -a toks; | |
toks=($( | |
compgen -d -- "$(quote_readline "$cur")" | { | |
while read -r tmp; do | |
printf '%s\n' $tmp | |
done | |
} | |
)); | |
eval xspec="${xspec}"; | |
local matchop=!; | |
if [[ $xspec == !* ]]; then | |
xspec=${xspec#!}; | |
matchop=@; | |
fi; | |
xspec="$matchop($xspec|${xspec^^})"; | |
toks+=($( | |
eval compgen -f -X "!$xspec" -- "\$(quote_readline "\$cur")" | { | |
while read -r tmp; do | |
[[ -n $tmp ]] && printf '%s\n' $tmp | |
done | |
} | |
)); | |
if [[ ${#toks[@]} -ne 0 ]]; then | |
compopt -o filenames; | |
COMPREPLY=("${toks[@]}"); | |
fi | |
} | |
_filename_parts () | |
{ | |
COMPREPLY=($( command ls -F /usr/src/ 2>/dev/null | grep -E '^'$1'/$' | sed -r -e 's/^([^-]+)-(.+)\/$/\'$2'/' | grep "^$cur" )) | |
} | |
_fstypes () | |
{ | |
local fss; | |
if [[ -e /proc/filesystems ]]; then | |
fss="$( cut -d' ' -f2 /proc/filesystems ) | |
$( awk '! /\*/ { print $NF }' /etc/filesystems 2>/dev/null )"; | |
else | |
fss="$( awk '/^[ \t]*[^#]/ { print $3 }' /etc/fstab 2>/dev/null ) | |
$( awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2>/dev/null ) | |
$( awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2>/dev/null ) | |
$( awk '{ print $1 }' /etc/dfs/fstypes 2>/dev/null ) | |
$( [[ -d /etc/fs ]] && command ls /etc/fs )"; | |
fi; | |
[[ -n $fss ]] && COMPREPLY+=($( compgen -W "$fss" -- "$cur" )) | |
} | |
_gem191 () | |
{ | |
local cur prev completions; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
prev=${COMP_WORDS[COMP_CWORD-1]}; | |
COMMANDS='build cert check cleanup contents dependency\ | |
environment fetch generate_index help install list\ | |
lock mirror outdated pristine query rdoc search server\ | |
sources specification uninstall unpack update which'; | |
GEM_OPTIONS='\ | |
-h --help\ | |
-v --version'; | |
COMMON_OPTIONS='\ | |
-h --help\ | |
-V --verbose --no-verbose\ | |
-q --quiet\ | |
--config-file\ | |
--backtrace\ | |
--debug'; | |
CERT_OPTIONS='\ | |
-a -add\ | |
-l --list\ | |
-r --remove\ | |
-b --build\ | |
-C --certificate\ | |
-K --private-key\ | |
-s --sign'; | |
CHECK_OPTIONS='\ | |
--verify\ | |
-a --alien\ | |
-t --test\ | |
-v --version'; | |
CLEANUP_OPTIONS='\ | |
-d --dry-run'; | |
CONTENTS_OPTIONS='\ | |
-v --version\ | |
-s --spec-dir\ | |
-l --lib-only --no-lib-only'; | |
DEPENDENCY_OPTIONS='\ | |
-v --version\ | |
--platform\ | |
-R --reverse-dependencies --no-reverse-dependencies\ | |
-p --pipe'; | |
ENVIRONMENT_OPTIONS=''; | |
FETCH_OPTIONS='\ | |
-v --version\ | |
--platform\ | |
-B --bulk-threshold\ | |
-p --http-proxy --no-http-proxy\ | |
--source'; | |
GENERATE_INDEX_OPTIONS='\ | |
-d --directory'; | |
HELP_OPTIONS=$COMMANDS; | |
INSTALL_OPTIONS='\ | |
--platform\ | |
-v --version\ | |
-i --install-dir\ | |
-d --rdoc --no-rdoc\ | |
--ri --no-ri\ | |
-E --env-shebang\ | |
-f --force --no-force\ | |
-t --test --no-test\ | |
-w --wrappers --no-wrappers\ | |
-P --trust-policy\ | |
--ignore-dependencies\ | |
-y --include-dependencies\ | |
--format-executable --no-format-executable\ | |
-l --local\ | |
-r --remote\ | |
-b --both\ | |
-B --bulk-threshold\ | |
--source\ | |
-p --http-proxy --no-http-proxy\ | |
-u --update-sources --no-update-sources'; | |
LIST_OPTIONS='\ | |
-d --details --no-details\ | |
--versions --no-versions\ | |
-l --local\ | |
-r --remote\ | |
-b --both\ | |
-B --bulk-threshold\ | |
--source\ | |
-p --http-proxy --no-http-proxy\ | |
-u --update-sources --no-update-sources'; | |
LOCK_OPTIONS='\ | |
-s --strict --no-strict'; | |
MIRROR_OPTIONS=''; | |
OUTDATED_OPTIONS='\ | |
--platform'; | |
PRISTINE_OPTIONS='\ | |
--all\ | |
-v --version'; | |
QUERY_OPTIONS='\ | |
-n --name-matches\ | |
-d --details --no-details\ | |
--versions --no-versions\ | |
-l --local\ | |
-r --remote\ | |
-b --both\ | |
-B --bulk-threshold\ | |
--source\ | |
-p --http-proxy --no-http-proxy\ | |
-u --update-sources --no-update-sources'; | |
RDOC_OPTIONS='\ | |
--all\ | |
--rdoc --no-rdoc\ | |
--ri --no-ri\ | |
-v --version'; | |
SEARCH_OPTIONS='\ | |
-d --details --no-details\ | |
--versions --no-versions\ | |
-l --local\ | |
-r --remote\ | |
-b --both\ | |
-B --bulk-threshold\ | |
--source\ | |
-p --http-proxy --no-http-proxy\ | |
-u --update-sources --no-update-sources'; | |
SERVER_OPTIONS='\ | |
-p --port\ | |
-d --dir\ | |
--daemon --no-daemon'; | |
SOURCES_OPTIONS='\ | |
-a --add\ | |
-l --list\ | |
-r --remove\ | |
-u --update\ | |
-c --clear-all'; | |
SPECIFICATION_OPTIONS='\ | |
-v --version\ | |
--platform\ | |
--all\ | |
-l --local\ | |
-r --remote\ | |
-b --both\ | |
-B --bulk-threshold\ | |
--source\ | |
-p --http-proxy --no-http-proxy\ | |
-u --update-sources --no-update-sources'; | |
UNINSTALL_OPTIONS='\ | |
-a --all --no-all\ | |
-i --ignore-dependencies --no-ignore-dependencies\ | |
-x --executables --no-executables\ | |
-v --version\ | |
--platform'; | |
UNPACK_OPTIONS='\ | |
--target\ | |
-v --version'; | |
UPDATE_OPTIONS='\ | |
--system\ | |
--platform\ | |
-i --install-dir\ | |
-d --rdoc --no-rdoc\ | |
--ri --no-ri\ | |
-E --env-shebang\ | |
-f --force --no-force\ | |
-t --test --no-test\ | |
-w --wrappers --no-wrappers\ | |
-P --trust-policy\ | |
--ignore-dependencies\ | |
-y --include-dependencies\ | |
--format-executable --no-format-executable\ | |
-l --local\ | |
-r --remote\ | |
-b --both\ | |
-B --bulk-threshold\ | |
--source\ | |
-p --http-proxy --no-http-proxy\ | |
-u --update-sources --no-update-sources'; | |
WHICH_OPTIONS='\ | |
-a --all --no-all\ | |
-g --gems-first --no-gems-first'; | |
case "${prev}" in | |
build) | |
completions="$COMMON_OPTIONS $BUILD_OPTIONS" | |
;; | |
cert) | |
completions="$COMMON_OPTIONS $CERT_OPTIONS" | |
;; | |
check) | |
completions="$COMMON_OPTIONS $CHECK_OPTIONS" | |
;; | |
cleanup) | |
completions="$COMMON_OPTIONS $CLEANUP_OPTIONS" | |
;; | |
contents) | |
completions="$COMMON_OPTIONS $CONTENTS_OPTIONS" | |
;; | |
dependency) | |
completions="$COMMON_OPTIONS $DEPENDENCY_OPTIONS" | |
;; | |
environment) | |
completions="$COMMON_OPTIONS $ENVIRONMENT_OPTIONS" | |
;; | |
fetch) | |
completions="$COMMON_OPTIONS $FETCH_OPTIONS" | |
;; | |
generate_index) | |
completions="$COMMON_OPTIONS $GENERATE_INDEX_OPTIONS" | |
;; | |
help) | |
completions="$COMMON_OPTIONS $HELP_OPTIONS" | |
;; | |
install) | |
completions="$COMMON_OPTIONS $INSTALL_OPTIONS" | |
;; | |
list) | |
completions="$COMMON_OPTIONS $LIST_OPTIONS" | |
;; | |
lock) | |
completions="$COMMON_OPTIONS $LOCK_OPTIONS" | |
;; | |
mirror) | |
completions="$COMMON_OPTIONS $MIRROR_OPTIONS" | |
;; | |
outdated) | |
completions="$COMMON_OPTIONS $OUTDATED_OPTIONS" | |
;; | |
pristine) | |
completions="$COMMON_OPTIONS $PRISTINE_OPTIONS" | |
;; | |
query) | |
completions="$COMMON_OPTIONS $QUERY_OPTIONS" | |
;; | |
rdoc) | |
completions="$COMMON_OPTIONS $RDOC_OPTIONS" | |
;; | |
search) | |
completions="$COMMON_OPTIONS $SEARCH_OPTIONS" | |
;; | |
server) | |
completions="$COMMON_OPTIONS $SERVER_OPTIONS" | |
;; | |
sources) | |
completions="$COMMON_OPTIONS $SOURCES_OPTIONS" | |
;; | |
specification) | |
completions="$COMMON_OPTIONS $SPECIFICATION_OPTIONS" | |
;; | |
uninstall) | |
completions="$COMMON_OPTIONS $UNINSTALL_OPTIONS" | |
;; | |
unpack) | |
completions="$COMMON_OPTIONS $UNPACK_OPTIONS" | |
;; | |
update) | |
completions="$COMMON_OPTIONS $UPDATE_OPTIONS" | |
;; | |
which) | |
completions="$COMMON_OPTIONS $WHICH_OPTIONS" | |
;; | |
*) | |
completions="$COMMANDS $GEM_OPTIONS" | |
;; | |
esac; | |
COMPREPLY=($( compgen -W "$completions" -- $cur )); | |
return 0 | |
} | |
_get_comp_words_by_ref () | |
{ | |
local exclude flag i OPTIND=1; | |
local cur cword words=(); | |
local upargs=() upvars=() vcur vcword vprev vwords; | |
while getopts "c:i:n:p:w:" flag "$@"; do | |
case $flag in | |
c) | |
vcur=$OPTARG | |
;; | |
i) | |
vcword=$OPTARG | |
;; | |
n) | |
exclude=$OPTARG | |
;; | |
p) | |
vprev=$OPTARG | |
;; | |
w) | |
vwords=$OPTARG | |
;; | |
esac; | |
done; | |
while [[ $# -ge $OPTIND ]]; do | |
case ${!OPTIND} in | |
cur) | |
vcur=cur | |
;; | |
prev) | |
vprev=prev | |
;; | |
cword) | |
vcword=cword | |
;; | |
words) | |
vwords=words | |
;; | |
*) | |
echo "bash: $FUNCNAME(): \`${!OPTIND}': unknown argument" 1>&2; | |
return 1 | |
;; | |
esac; | |
let "OPTIND += 1"; | |
done; | |
__get_cword_at_cursor_by_ref "$exclude" words cword cur; | |
[[ -n $vcur ]] && { | |
upvars+=("$vcur"); | |
upargs+=(-v $vcur "$cur") | |
}; | |
[[ -n $vcword ]] && { | |
upvars+=("$vcword"); | |
upargs+=(-v $vcword "$cword") | |
}; | |
[[ -n $vprev && $cword -ge 1 ]] && { | |
upvars+=("$vprev"); | |
upargs+=(-v $vprev "${words[cword - 1]}") | |
}; | |
[[ -n $vwords ]] && { | |
upvars+=("$vwords"); | |
upargs+=(-a${#words[@]} $vwords "${words[@]}") | |
}; | |
(( ${#upvars[@]} )) && local "${upvars[@]}" && _upvars "${upargs[@]}" | |
} | |
_get_cword () | |
{ | |
local LC_CTYPE=C; | |
local cword words; | |
__reassemble_comp_words_by_ref "$1" words cword; | |
if [[ -n ${2//[^0-9]/} ]]; then | |
printf "%s" "${words[cword-$2]}"; | |
else | |
if [[ "${#words[cword]}" -eq 0 || "$COMP_POINT" == "${#COMP_LINE}" ]]; then | |
printf "%s" "${words[cword]}"; | |
else | |
local i; | |
local cur="$COMP_LINE"; | |
local index="$COMP_POINT"; | |
for ((i = 0; i <= cword; ++i )) | |
do | |
while [[ "${#cur}" -ge ${#words[i]} && "${cur:0:${#words[i]}}" != "${words[i]}" ]]; do | |
cur="${cur:1}"; | |
((index--)); | |
done; | |
if [[ "$i" -lt "$cword" ]]; then | |
local old_size="${#cur}"; | |
cur="${cur#${words[i]}}"; | |
local new_size="${#cur}"; | |
index=$(( index - old_size + new_size )); | |
fi; | |
done; | |
if [[ "${words[cword]:0:${#cur}}" != "$cur" ]]; then | |
printf "%s" "${words[cword]}"; | |
else | |
printf "%s" "${cur:0:$index}"; | |
fi; | |
fi; | |
fi | |
} | |
_get_first_arg () | |
{ | |
local i; | |
arg=; | |
for ((i=1; i < COMP_CWORD; i++ )) | |
do | |
if [[ "${COMP_WORDS[i]}" != -* ]]; then | |
arg=${COMP_WORDS[i]}; | |
break; | |
fi; | |
done | |
} | |
_get_pword () | |
{ | |
if [[ $COMP_CWORD -ge 1 ]]; then | |
_get_cword "${@:-}" 1; | |
fi | |
} | |
_gids () | |
{ | |
if type getent &>/dev/null; then | |
COMPREPLY=($( compgen -W '$( getent group | cut -d: -f3 )' -- "$cur" )); | |
else | |
if type perl &>/dev/null; then | |
COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"' )' -- "$cur" )); | |
else | |
COMPREPLY=($( compgen -W '$( cut -d: -f3 /etc/group )' -- "$cur" )); | |
fi; | |
fi | |
} | |
_git () | |
{ | |
local i c=1 command __git_dir; | |
if [[ -n ${ZSH_VERSION-} ]]; then | |
emulate -L bash; | |
setopt KSH_TYPESET; | |
typeset -h words; | |
typeset -h IFS; | |
fi; | |
local cur words cword prev; | |
_get_comp_words_by_ref -n =: cur words cword prev; | |
while [ $c -lt $cword ]; do | |
i="${words[c]}"; | |
case "$i" in | |
--git-dir=*) | |
__git_dir="${i#--git-dir=}" | |
;; | |
--bare) | |
__git_dir="." | |
;; | |
--version | -p | --paginate) | |
;; | |
--help) | |
command="help"; | |
break | |
;; | |
*) | |
command="$i"; | |
break | |
;; | |
esac; | |
((c++)); | |
done; | |
if [ -z "$command" ]; then | |
case "$cur" in | |
--*) | |
__gitcomp " | |
--paginate | |
--no-pager | |
--git-dir= | |
--bare | |
--version | |
--exec-path | |
--html-path | |
--work-tree= | |
--namespace= | |
--help | |
" | |
;; | |
*) | |
__git_compute_porcelain_commands; | |
__gitcomp "$__git_porcelain_commands $(__git_aliases)" | |
;; | |
esac; | |
return; | |
fi; | |
local completion_func="_git_${command//-/_}"; | |
declare -f $completion_func > /dev/null && $completion_func && return; | |
local expansion=$(__git_aliased_command "$command"); | |
if [ -n "$expansion" ]; then | |
completion_func="_git_${expansion//-/_}"; | |
declare -f $completion_func > /dev/null && $completion_func; | |
fi | |
} | |
_git_add () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--*) | |
__gitcomp " | |
--interactive --refresh --patch --update --dry-run | |
--ignore-errors --intent-to-add | |
"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_am () | |
{ | |
local dir="$(__gitdir)"; | |
if [ -d "$dir"/rebase-apply ]; then | |
__gitcomp "--skip --continue --resolved --abort"; | |
return; | |
fi; | |
case "$cur" in | |
--whitespace=*) | |
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; | |
return | |
;; | |
--*) | |
__gitcomp " | |
--3way --committer-date-is-author-date --ignore-date | |
--ignore-whitespace --ignore-space-change | |
--interactive --keep --no-utf8 --signoff --utf8 | |
--whitespace= --scissors | |
"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_apply () | |
{ | |
case "$cur" in | |
--whitespace=*) | |
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; | |
return | |
;; | |
--*) | |
__gitcomp " | |
--stat --numstat --summary --check --index | |
--cached --index-info --reverse --reject --unidiff-zero | |
--apply --no-add --exclude= | |
--ignore-whitespace --ignore-space-change | |
--whitespace= --inaccurate-eof --verbose | |
"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_archive () | |
{ | |
case "$cur" in | |
--format=*) | |
__gitcomp "$(git archive --list)" "" "${cur##--format=}"; | |
return | |
;; | |
--remote=*) | |
__gitcomp_nl "$(__git_remotes)" "" "${cur##--remote=}"; | |
return | |
;; | |
--*) | |
__gitcomp " | |
--format= --list --verbose | |
--prefix= --remote= --exec= | |
"; | |
return | |
;; | |
esac; | |
__git_complete_file | |
} | |
_git_bisect () | |
{ | |
__git_has_doubledash && return; | |
local subcommands="start bad good skip reset visualize replay log run"; | |
local subcommand="$(__git_find_on_cmdline "$subcommands")"; | |
if [ -z "$subcommand" ]; then | |
if [ -f "$(__gitdir)"/BISECT_START ]; then | |
__gitcomp "$subcommands"; | |
else | |
__gitcomp "replay start"; | |
fi; | |
return; | |
fi; | |
case "$subcommand" in | |
bad | good | reset | skip | start) | |
__gitcomp_nl "$(__git_refs)" | |
;; | |
*) | |
COMPREPLY=() | |
;; | |
esac | |
} | |
_git_branch () | |
{ | |
local i c=1 only_local_ref="n" has_r="n"; | |
while [ $c -lt $cword ]; do | |
i="${words[c]}"; | |
case "$i" in | |
-d | -m) | |
only_local_ref="y" | |
;; | |
-r) | |
has_r="y" | |
;; | |
esac; | |
((c++)); | |
done; | |
case "$cur" in | |
--*) | |
__gitcomp " | |
--color --no-color --verbose --abbrev= --no-abbrev | |
--track --no-track --contains --merged --no-merged | |
--set-upstream --edit-description --list | |
" | |
;; | |
*) | |
if [ $only_local_ref = "y" -a $has_r = "n" ]; then | |
__gitcomp_nl "$(__git_heads)"; | |
else | |
__gitcomp_nl "$(__git_refs)"; | |
fi | |
;; | |
esac | |
} | |
_git_bundle () | |
{ | |
local cmd="${words[2]}"; | |
case "$cword" in | |
2) | |
__gitcomp "create list-heads verify unbundle" | |
;; | |
3) | |
;; | |
*) | |
case "$cmd" in | |
create) | |
__git_complete_revlist | |
;; | |
esac | |
;; | |
esac | |
} | |
_git_checkout () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--conflict=*) | |
__gitcomp "diff3 merge" "" "${cur##--conflict=}" | |
;; | |
--*) | |
__gitcomp " | |
--quiet --ours --theirs --track --no-track --merge | |
--conflict= --orphan --patch | |
" | |
;; | |
*) | |
local flags="--track --no-track --no-guess" track=1; | |
if [ -n "$(__git_find_on_cmdline "$flags")" ]; then | |
track=''; | |
fi; | |
__gitcomp_nl "$(__git_refs '' $track)" | |
;; | |
esac | |
} | |
_git_cherry () | |
{ | |
__gitcomp "$(__git_refs)" | |
} | |
_git_cherry_pick () | |
{ | |
case "$cur" in | |
--*) | |
__gitcomp "--edit --no-commit" | |
;; | |
*) | |
__gitcomp_nl "$(__git_refs)" | |
;; | |
esac | |
} | |
_git_clean () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--*) | |
__gitcomp "--dry-run --quiet"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_clone () | |
{ | |
case "$cur" in | |
--*) | |
__gitcomp " | |
--local | |
--no-hardlinks | |
--shared | |
--reference | |
--quiet | |
--no-checkout | |
--bare | |
--mirror | |
--origin | |
--upload-pack | |
--template= | |
--depth | |
"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_commit () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--cleanup=*) | |
__gitcomp "default strip verbatim whitespace | |
" "" "${cur##--cleanup=}"; | |
return | |
;; | |
--reuse-message=* | --reedit-message=* | --fixup=* | --squash=*) | |
__gitcomp_nl "$(__git_refs)" "" "${cur#*=}"; | |
return | |
;; | |
--untracked-files=*) | |
__gitcomp "all no normal" "" "${cur##--untracked-files=}"; | |
return | |
;; | |
--*) | |
__gitcomp " | |
--all --author= --signoff --verify --no-verify | |
--edit --amend --include --only --interactive | |
--dry-run --reuse-message= --reedit-message= | |
--reset-author --file= --message= --template= | |
--cleanup= --untracked-files --untracked-files= | |
--verbose --quiet --fixup= --squash= | |
"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_config () | |
{ | |
case "$prev" in | |
branch.*.remote) | |
__gitcomp_nl "$(__git_remotes)"; | |
return | |
;; | |
branch.*.merge) | |
__gitcomp_nl "$(__git_refs)"; | |
return | |
;; | |
remote.*.fetch) | |
local remote="${prev#remote.}"; | |
remote="${remote%.fetch}"; | |
if [ -z "$cur" ]; then | |
COMPREPLY=("refs/heads/"); | |
return; | |
fi; | |
__gitcomp_nl "$(__git_refs_remotes "$remote")"; | |
return | |
;; | |
remote.*.push) | |
local remote="${prev#remote.}"; | |
remote="${remote%.push}"; | |
__gitcomp_nl "$(git --git-dir="$(__gitdir)" for-each-ref --format='%(refname):%(refname)' refs/heads)"; | |
return | |
;; | |
pull.twohead | pull.octopus) | |
__git_compute_merge_strategies; | |
__gitcomp "$__git_merge_strategies"; | |
return | |
;; | |
color.branch | color.diff | color.interactive | color.showbranch | color.status | color.ui) | |
__gitcomp "always never auto"; | |
return | |
;; | |
color.pager) | |
__gitcomp "false true"; | |
return | |
;; | |
color.*.*) | |
__gitcomp " | |
normal black red green yellow blue magenta cyan white | |
bold dim ul blink reverse | |
"; | |
return | |
;; | |
help.format) | |
__gitcomp "man info web html"; | |
return | |
;; | |
log.date) | |
__gitcomp "$__git_log_date_formats"; | |
return | |
;; | |
sendemail.aliasesfiletype) | |
__gitcomp "mutt mailrc pine elm gnus"; | |
return | |
;; | |
sendemail.confirm) | |
__gitcomp "$__git_send_email_confirm_options"; | |
return | |
;; | |
sendemail.suppresscc) | |
__gitcomp "$__git_send_email_suppresscc_options"; | |
return | |
;; | |
--get | --get-all | --unset | --unset-all) | |
__gitcomp_nl "$(__git_config_get_set_variables)"; | |
return | |
;; | |
*.*) | |
COMPREPLY=(); | |
return | |
;; | |
esac; | |
case "$cur" in | |
--*) | |
__gitcomp " | |
--global --system --file= | |
--list --replace-all | |
--get --get-all --get-regexp | |
--add --unset --unset-all | |
--remove-section --rename-section | |
"; | |
return | |
;; | |
branch.*.*) | |
local pfx="${cur%.*}." cur_="${cur##*.}"; | |
__gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"; | |
return | |
;; | |
branch.*) | |
local pfx="${cur%.*}." cur_="${cur#*.}"; | |
__gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."; | |
return | |
;; | |
guitool.*.*) | |
local pfx="${cur%.*}." cur_="${cur##*.}"; | |
__gitcomp " | |
argprompt cmd confirm needsfile noconsole norescan | |
prompt revprompt revunmerged title | |
" "$pfx" "$cur_"; | |
return | |
;; | |
difftool.*.*) | |
local pfx="${cur%.*}." cur_="${cur##*.}"; | |
__gitcomp "cmd path" "$pfx" "$cur_"; | |
return | |
;; | |
man.*.*) | |
local pfx="${cur%.*}." cur_="${cur##*.}"; | |
__gitcomp "cmd path" "$pfx" "$cur_"; | |
return | |
;; | |
mergetool.*.*) | |
local pfx="${cur%.*}." cur_="${cur##*.}"; | |
__gitcomp "cmd path trustExitCode" "$pfx" "$cur_"; | |
return | |
;; | |
pager.*) | |
local pfx="${cur%.*}." cur_="${cur#*.}"; | |
__git_compute_all_commands; | |
__gitcomp_nl "$__git_all_commands" "$pfx" "$cur_"; | |
return | |
;; | |
remote.*.*) | |
local pfx="${cur%.*}." cur_="${cur##*.}"; | |
__gitcomp " | |
url proxy fetch push mirror skipDefaultUpdate | |
receivepack uploadpack tagopt pushurl | |
" "$pfx" "$cur_"; | |
return | |
;; | |
remote.*) | |
local pfx="${cur%.*}." cur_="${cur#*.}"; | |
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."; | |
return | |
;; | |
url.*.*) | |
local pfx="${cur%.*}." cur_="${cur##*.}"; | |
__gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"; | |
return | |
;; | |
esac; | |
__gitcomp " | |
add.ignoreErrors | |
advice.commitBeforeMerge | |
advice.detachedHead | |
advice.implicitIdentity | |
advice.pushNonFastForward | |
advice.resolveConflict | |
advice.statusHints | |
alias. | |
am.keepcr | |
apply.ignorewhitespace | |
apply.whitespace | |
branch.autosetupmerge | |
branch.autosetuprebase | |
browser. | |
clean.requireForce | |
color.branch | |
color.branch.current | |
color.branch.local | |
color.branch.plain | |
color.branch.remote | |
color.decorate.HEAD | |
color.decorate.branch | |
color.decorate.remoteBranch | |
color.decorate.stash | |
color.decorate.tag | |
color.diff | |
color.diff.commit | |
color.diff.frag | |
color.diff.func | |
color.diff.meta | |
color.diff.new | |
color.diff.old | |
color.diff.plain | |
color.diff.whitespace | |
color.grep | |
color.grep.context | |
color.grep.filename | |
color.grep.function | |
color.grep.linenumber | |
color.grep.match | |
color.grep.selected | |
color.grep.separator | |
color.interactive | |
color.interactive.error | |
color.interactive.header | |
color.interactive.help | |
color.interactive.prompt | |
color.pager | |
color.showbranch | |
color.status | |
color.status.added | |
color.status.changed | |
color.status.header | |
color.status.nobranch | |
color.status.untracked | |
color.status.updated | |
color.ui | |
commit.status | |
commit.template | |
core.abbrev | |
core.askpass | |
core.attributesfile | |
core.autocrlf | |
core.bare | |
core.bigFileThreshold | |
core.compression | |
core.createObject | |
core.deltaBaseCacheLimit | |
core.editor | |
core.eol | |
core.excludesfile | |
core.fileMode | |
core.fsyncobjectfiles | |
core.gitProxy | |
core.ignoreCygwinFSTricks | |
core.ignoreStat | |
core.ignorecase | |
core.logAllRefUpdates | |
core.loosecompression | |
core.notesRef | |
core.packedGitLimit | |
core.packedGitWindowSize | |
core.pager | |
core.preferSymlinkRefs | |
core.preloadindex | |
core.quotepath | |
core.repositoryFormatVersion | |
core.safecrlf | |
core.sharedRepository | |
core.sparseCheckout | |
core.symlinks | |
core.trustctime | |
core.warnAmbiguousRefs | |
core.whitespace | |
core.worktree | |
diff.autorefreshindex | |
diff.statGraphWidth | |
diff.external | |
diff.ignoreSubmodules | |
diff.mnemonicprefix | |
diff.noprefix | |
diff.renameLimit | |
diff.renames | |
diff.suppressBlankEmpty | |
diff.tool | |
diff.wordRegex | |
difftool. | |
difftool.prompt | |
fetch.recurseSubmodules | |
fetch.unpackLimit | |
format.attach | |
format.cc | |
format.headers | |
format.numbered | |
format.pretty | |
format.signature | |
format.signoff | |
format.subjectprefix | |
format.suffix | |
format.thread | |
format.to | |
gc. | |
gc.aggressiveWindow | |
gc.auto | |
gc.autopacklimit | |
gc.packrefs | |
gc.pruneexpire | |
gc.reflogexpire | |
gc.reflogexpireunreachable | |
gc.rerereresolved | |
gc.rerereunresolved | |
gitcvs.allbinary | |
gitcvs.commitmsgannotation | |
gitcvs.dbTableNamePrefix | |
gitcvs.dbdriver | |
gitcvs.dbname | |
gitcvs.dbpass | |
gitcvs.dbuser | |
gitcvs.enabled | |
gitcvs.logfile | |
gitcvs.usecrlfattr | |
guitool. | |
gui.blamehistoryctx | |
gui.commitmsgwidth | |
gui.copyblamethreshold | |
gui.diffcontext | |
gui.encoding | |
gui.fastcopyblame | |
gui.matchtrackingbranch | |
gui.newbranchtemplate | |
gui.pruneduringfetch | |
gui.spellingdictionary | |
gui.trustmtime | |
help.autocorrect | |
help.browser | |
help.format | |
http.lowSpeedLimit | |
http.lowSpeedTime | |
http.maxRequests | |
http.minSessions | |
http.noEPSV | |
http.postBuffer | |
http.proxy | |
http.sslCAInfo | |
http.sslCAPath | |
http.sslCert | |
http.sslCertPasswordProtected | |
http.sslKey | |
http.sslVerify | |
http.useragent | |
i18n.commitEncoding | |
i18n.logOutputEncoding | |
imap.authMethod | |
imap.folder | |
imap.host | |
imap.pass | |
imap.port | |
imap.preformattedHTML | |
imap.sslverify | |
imap.tunnel | |
imap.user | |
init.templatedir | |
instaweb.browser | |
instaweb.httpd | |
instaweb.local | |
instaweb.modulepath | |
instaweb.port | |
interactive.singlekey | |
log.date | |
log.decorate | |
log.showroot | |
mailmap.file | |
man. | |
man.viewer | |
merge. | |
merge.conflictstyle | |
merge.log | |
merge.renameLimit | |
merge.renormalize | |
merge.stat | |
merge.tool | |
merge.verbosity | |
mergetool. | |
mergetool.keepBackup | |
mergetool.keepTemporaries | |
mergetool.prompt | |
notes.displayRef | |
notes.rewrite. | |
notes.rewrite.amend | |
notes.rewrite.rebase | |
notes.rewriteMode | |
notes.rewriteRef | |
pack.compression | |
pack.deltaCacheLimit | |
pack.deltaCacheSize | |
pack.depth | |
pack.indexVersion | |
pack.packSizeLimit | |
pack.threads | |
pack.window | |
pack.windowMemory | |
pager. | |
pretty. | |
pull.octopus | |
pull.twohead | |
push.default | |
rebase.autosquash | |
rebase.stat | |
receive.autogc | |
receive.denyCurrentBranch | |
receive.denyDeleteCurrent | |
receive.denyDeletes | |
receive.denyNonFastForwards | |
receive.fsckObjects | |
receive.unpackLimit | |
receive.updateserverinfo | |
remotes. | |
repack.usedeltabaseoffset | |
rerere.autoupdate | |
rerere.enabled | |
sendemail. | |
sendemail.aliasesfile | |
sendemail.aliasfiletype | |
sendemail.bcc | |
sendemail.cc | |
sendemail.cccmd | |
sendemail.chainreplyto | |
sendemail.confirm | |
sendemail.envelopesender | |
sendemail.from | |
sendemail.identity | |
sendemail.multiedit | |
sendemail.signedoffbycc | |
sendemail.smtpdomain | |
sendemail.smtpencryption | |
sendemail.smtppass | |
sendemail.smtpserver | |
sendemail.smtpserveroption | |
sendemail.smtpserverport | |
sendemail.smtpuser | |
sendemail.suppresscc | |
sendemail.suppressfrom | |
sendemail.thread | |
sendemail.to | |
sendemail.validate | |
showbranch.default | |
status.relativePaths | |
status.showUntrackedFiles | |
status.submodulesummary | |
submodule. | |
tar.umask | |
transfer.unpackLimit | |
url. | |
user.email | |
user.name | |
user.signingkey | |
web.browser | |
branch. remote. | |
" | |
} | |
_git_describe () | |
{ | |
case "$cur" in | |
--*) | |
__gitcomp " | |
--all --tags --contains --abbrev= --candidates= | |
--exact-match --debug --long --match --always | |
"; | |
return | |
;; | |
esac; | |
__gitcomp_nl "$(__git_refs)" | |
} | |
_git_diff () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--*) | |
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex | |
--base --ours --theirs --no-index | |
$__git_diff_common_options | |
"; | |
return | |
;; | |
esac; | |
__git_complete_revlist_file | |
} | |
_git_difftool () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--tool=*) | |
__gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"; | |
return | |
;; | |
--*) | |
__gitcomp "--cached --staged --pickaxe-all --pickaxe-regex | |
--base --ours --theirs | |
--no-renames --diff-filter= --find-copies-harder | |
--relative --ignore-submodules | |
--tool="; | |
return | |
;; | |
esac; | |
__git_complete_file | |
} | |
_git_fetch () | |
{ | |
case "$cur" in | |
--*) | |
__gitcomp "$__git_fetch_options"; | |
return | |
;; | |
esac; | |
__git_complete_remote_or_refspec | |
} | |
_git_format_patch () | |
{ | |
case "$cur" in | |
--thread=*) | |
__gitcomp " | |
deep shallow | |
" "" "${cur##--thread=}"; | |
return | |
;; | |
--*) | |
__gitcomp " | |
--stdout --attach --no-attach --thread --thread= | |
--output-directory | |
--numbered --start-number | |
--numbered-files | |
--keep-subject | |
--signoff --signature --no-signature | |
--in-reply-to= --cc= | |
--full-index --binary | |
--not --all | |
--cover-letter | |
--no-prefix --src-prefix= --dst-prefix= | |
--inline --suffix= --ignore-if-in-upstream | |
--subject-prefix= | |
"; | |
return | |
;; | |
esac; | |
__git_complete_revlist | |
} | |
_git_fsck () | |
{ | |
case "$cur" in | |
--*) | |
__gitcomp " | |
--tags --root --unreachable --cache --no-reflogs --full | |
--strict --verbose --lost-found | |
"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_gc () | |
{ | |
case "$cur" in | |
--*) | |
__gitcomp "--prune --aggressive"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_gitk () | |
{ | |
_gitk | |
} | |
_git_grep () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--*) | |
__gitcomp " | |
--cached | |
--text --ignore-case --word-regexp --invert-match | |
--full-name --line-number | |
--extended-regexp --basic-regexp --fixed-strings | |
--perl-regexp | |
--files-with-matches --name-only | |
--files-without-match | |
--max-depth | |
--count | |
--and --or --not --all-match | |
"; | |
return | |
;; | |
esac; | |
case "$cword,$prev" in | |
2,* | *,-*) | |
if test -r tags; then | |
__gitcomp_nl "$(__git_match_ctag "$cur" tags)"; | |
return; | |
fi | |
;; | |
esac; | |
__gitcomp_nl "$(__git_refs)" | |
} | |
_git_help () | |
{ | |
case "$cur" in | |
--*) | |
__gitcomp "--all --info --man --web"; | |
return | |
;; | |
esac; | |
__git_compute_all_commands; | |
__gitcomp "$__git_all_commands $(__git_aliases) | |
attributes cli core-tutorial cvs-migration | |
diffcore gitk glossary hooks ignore modules | |
namespaces repository-layout tutorial tutorial-2 | |
workflows | |
" | |
} | |
_git_init () | |
{ | |
case "$cur" in | |
--shared=*) | |
__gitcomp " | |
false true umask group all world everybody | |
" "" "${cur##--shared=}"; | |
return | |
;; | |
--*) | |
__gitcomp "--quiet --bare --template= --shared --shared="; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_log () | |
{ | |
__git_has_doubledash && return; | |
local g="$(git rev-parse --git-dir 2>/dev/null)"; | |
local merge=""; | |
if [ -f "$g/MERGE_HEAD" ]; then | |
merge="--merge"; | |
fi; | |
case "$cur" in | |
--pretty=* | --format=*) | |
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) | |
" "" "${cur#*=}"; | |
return | |
;; | |
--date=*) | |
__gitcomp "$__git_log_date_formats" "" "${cur##--date=}"; | |
return | |
;; | |
--decorate=*) | |
__gitcomp "long short" "" "${cur##--decorate=}"; | |
return | |
;; | |
--*) | |
__gitcomp " | |
$__git_log_common_options | |
$__git_log_shortlog_options | |
$__git_log_gitk_options | |
--root --topo-order --date-order --reverse | |
--follow --full-diff | |
--abbrev-commit --abbrev= | |
--relative-date --date= | |
--pretty= --format= --oneline | |
--cherry-pick | |
--graph | |
--decorate --decorate= | |
--walk-reflogs | |
--parents --children | |
$merge | |
$__git_diff_common_options | |
--pickaxe-all --pickaxe-regex | |
"; | |
return | |
;; | |
esac; | |
__git_complete_revlist | |
} | |
_git_ls_files () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--*) | |
__gitcomp "--cached --deleted --modified --others --ignored | |
--stage --directory --no-empty-directory --unmerged | |
--killed --exclude= --exclude-from= | |
--exclude-per-directory= --exclude-standard | |
--error-unmatch --with-tree= --full-name | |
--abbrev --ignored --exclude-per-directory | |
"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_ls_remote () | |
{ | |
__gitcomp_nl "$(__git_remotes)" | |
} | |
_git_ls_tree () | |
{ | |
__git_complete_file | |
} | |
_git_merge () | |
{ | |
__git_complete_strategy && return; | |
case "$cur" in | |
--*) | |
__gitcomp "$__git_merge_options"; | |
return | |
;; | |
esac; | |
__gitcomp_nl "$(__git_refs)" | |
} | |
_git_merge_base () | |
{ | |
__gitcomp_nl "$(__git_refs)" | |
} | |
_git_mergetool () | |
{ | |
case "$cur" in | |
--tool=*) | |
__gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"; | |
return | |
;; | |
--*) | |
__gitcomp "--tool="; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_mv () | |
{ | |
case "$cur" in | |
--*) | |
__gitcomp "--dry-run"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_name_rev () | |
{ | |
__gitcomp "--tags --all --stdin" | |
} | |
_git_notes () | |
{ | |
local subcommands='add append copy edit list prune remove show'; | |
local subcommand="$(__git_find_on_cmdline "$subcommands")"; | |
case "$subcommand,$cur" in | |
,--*) | |
__gitcomp '--ref' | |
;; | |
,*) | |
case "${words[cword-1]}" in | |
--ref) | |
__gitcomp_nl "$(__git_refs)" | |
;; | |
*) | |
__gitcomp "$subcommands --ref" | |
;; | |
esac | |
;; | |
add,--reuse-message=* | append,--reuse-message=* | add,--reedit-message=* | append,--reedit-message=*) | |
__gitcomp_nl "$(__git_refs)" "" "${cur#*=}" | |
;; | |
add,--* | append,--*) | |
__gitcomp '--file= --message= --reedit-message= | |
--reuse-message=' | |
;; | |
copy,--*) | |
__gitcomp '--stdin' | |
;; | |
prune,--*) | |
__gitcomp '--dry-run --verbose' | |
;; | |
prune,*) | |
;; | |
*) | |
case "${words[cword-1]}" in | |
-m | -F) | |
;; | |
*) | |
__gitcomp_nl "$(__git_refs)" | |
;; | |
esac | |
;; | |
esac | |
} | |
_git_pull () | |
{ | |
__git_complete_strategy && return; | |
case "$cur" in | |
--*) | |
__gitcomp " | |
--rebase --no-rebase | |
$__git_merge_options | |
$__git_fetch_options | |
"; | |
return | |
;; | |
esac; | |
__git_complete_remote_or_refspec | |
} | |
_git_push () | |
{ | |
case "$prev" in | |
--repo) | |
__gitcomp_nl "$(__git_remotes)"; | |
return | |
;; | |
esac; | |
case "$cur" in | |
--repo=*) | |
__gitcomp_nl "$(__git_remotes)" "" "${cur##--repo=}"; | |
return | |
;; | |
--*) | |
__gitcomp " | |
--all --mirror --tags --dry-run --force --verbose | |
--receive-pack= --repo= --set-upstream | |
"; | |
return | |
;; | |
esac; | |
__git_complete_remote_or_refspec | |
} | |
_git_rebase () | |
{ | |
local dir="$(__gitdir)"; | |
if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then | |
__gitcomp "--continue --skip --abort"; | |
return; | |
fi; | |
__git_complete_strategy && return; | |
case "$cur" in | |
--whitespace=*) | |
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"; | |
return | |
;; | |
--*) | |
__gitcomp " | |
--onto --merge --strategy --interactive | |
--preserve-merges --stat --no-stat | |
--committer-date-is-author-date --ignore-date | |
--ignore-whitespace --whitespace= | |
--autosquash | |
"; | |
return | |
;; | |
esac; | |
__gitcomp_nl "$(__git_refs)" | |
} | |
_git_reflog () | |
{ | |
local subcommands="show delete expire"; | |
local subcommand="$(__git_find_on_cmdline "$subcommands")"; | |
if [ -z "$subcommand" ]; then | |
__gitcomp "$subcommands"; | |
else | |
__gitcomp_nl "$(__git_refs)"; | |
fi | |
} | |
_git_remote () | |
{ | |
local subcommands="add rename rm set-head set-branches set-url show prune update"; | |
local subcommand="$(__git_find_on_cmdline "$subcommands")"; | |
if [ -z "$subcommand" ]; then | |
__gitcomp "$subcommands"; | |
return; | |
fi; | |
case "$subcommand" in | |
rename | rm | set-url | show | prune) | |
__gitcomp_nl "$(__git_remotes)" | |
;; | |
set-head | set-branches) | |
__git_complete_remote_or_refspec | |
;; | |
update) | |
local i c='' IFS=' | |
'; | |
for i in $(git --git-dir="$(__gitdir)" config --get-regexp "remotes\..*" 2>/dev/null); | |
do | |
i="${i#remotes.}"; | |
c="$c ${i/ */}"; | |
done; | |
__gitcomp "$c" | |
;; | |
*) | |
COMPREPLY=() | |
;; | |
esac | |
} | |
_git_replace () | |
{ | |
__gitcomp_nl "$(__git_refs)" | |
} | |
_git_reset () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--*) | |
__gitcomp "--merge --mixed --hard --soft --patch"; | |
return | |
;; | |
esac; | |
__gitcomp_nl "$(__git_refs)" | |
} | |
_git_revert () | |
{ | |
case "$cur" in | |
--*) | |
__gitcomp "--edit --mainline --no-edit --no-commit --signoff"; | |
return | |
;; | |
esac; | |
__gitcomp_nl "$(__git_refs)" | |
} | |
_git_rm () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--*) | |
__gitcomp "--cached --dry-run --ignore-unmatch --quiet"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_send_email () | |
{ | |
case "$cur" in | |
--confirm=*) | |
__gitcomp " | |
$__git_send_email_confirm_options | |
" "" "${cur##--confirm=}"; | |
return | |
;; | |
--suppress-cc=*) | |
__gitcomp " | |
$__git_send_email_suppresscc_options | |
" "" "${cur##--suppress-cc=}"; | |
return | |
;; | |
--smtp-encryption=*) | |
__gitcomp "ssl tls" "" "${cur##--smtp-encryption=}"; | |
return | |
;; | |
--*) | |
__gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to | |
--compose --confirm= --dry-run --envelope-sender | |
--from --identity | |
--in-reply-to --no-chain-reply-to --no-signed-off-by-cc | |
--no-suppress-from --no-thread --quiet | |
--signed-off-by-cc --smtp-pass --smtp-server | |
--smtp-server-port --smtp-encryption= --smtp-user | |
--subject --suppress-cc= --suppress-from --thread --to | |
--validate --no-validate"; | |
return | |
;; | |
esac; | |
COMPREPLY=() | |
} | |
_git_shortlog () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--*) | |
__gitcomp " | |
$__git_log_common_options | |
$__git_log_shortlog_options | |
--numbered --summary | |
"; | |
return | |
;; | |
esac; | |
__git_complete_revlist | |
} | |
_git_show () | |
{ | |
__git_has_doubledash && return; | |
case "$cur" in | |
--pretty=* | --format=*) | |
__gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases) | |
" "" "${cur#*=}"; | |
return | |
;; | |
--*) | |
__gitcomp "--pretty= --format= --abbrev-commit --oneline | |
$__git_diff_common_options | |
"; | |
return | |
;; | |
esac; | |
__git_complete_file | |
} | |
_git_show_branch () | |
{ | |
case "$cur" in | |
--*) | |
__gitcomp " | |
--all --remotes --topo-order --current --more= | |
--list --independent --merge-base --no-name | |
--color --no-color | |
--sha1-name --sparse --topics --reflog | |
"; | |
return | |
;; | |
esac; | |
__git_complete_revlist | |
} | |
_git_stage () | |
{ | |
_git_add | |
} | |
_git_stash () | |
{ | |
local save_opts='--keep-index --no-keep-index --quiet --patch'; | |
local subcommands='save list show apply clear drop pop create branch'; | |
local subcommand="$(__git_find_on_cmdline "$subcommands")"; | |
if [ -z "$subcommand" ]; then | |
case "$cur" in | |
--*) | |
__gitcomp "$save_opts" | |
;; | |
*) | |
if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then | |
__gitcomp "$subcommands"; | |
else | |
COMPREPLY=(); | |
fi | |
;; | |
esac; | |
else | |
case "$subcommand,$cur" in | |
save,--*) | |
__gitcomp "$save_opts" | |
;; | |
apply,--* | pop,--*) | |
__gitcomp "--index --quiet" | |
;; | |
show,--* | drop,--* | branch,--*) | |
COMPREPLY=() | |
;; | |
show,* | apply,* | drop,* | pop,* | branch,*) | |
__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list | sed -n -e 's/:.*//p')" | |
;; | |
*) | |
COMPREPLY=() | |
;; | |
esac; | |
fi | |
} | |
_git_submodule () | |
{ | |
__git_has_doubledash && return; | |
local subcommands="add status init update summary foreach sync"; | |
if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then | |
case "$cur" in | |
--*) | |
__gitcomp "--quiet --cached" | |
;; | |
*) | |
__gitcomp "$subcommands" | |
;; | |
esac; | |
return; | |
fi | |
} | |
_git_svn () | |
{ | |
local subcommands=" | |
init fetch clone rebase dcommit log find-rev | |
set-tree commit-diff info create-ignore propget | |
proplist show-ignore show-externals branch tag blame | |
migrate mkdirs reset gc | |
"; | |
local subcommand="$(__git_find_on_cmdline "$subcommands")"; | |
if [ -z "$subcommand" ]; then | |
__gitcomp "$subcommands"; | |
else | |
local remote_opts="--username= --config-dir= --no-auth-cache"; | |
local fc_opts=" | |
--follow-parent --authors-file= --repack= | |
--no-metadata --use-svm-props --use-svnsync-props | |
--log-window-size= --no-checkout --quiet | |
--repack-flags --use-log-author --localtime | |
--ignore-paths= $remote_opts | |
"; | |
local init_opts=" | |
--template= --shared= --trunk= --tags= | |
--branches= --stdlayout --minimize-url | |
--no-metadata --use-svm-props --use-svnsync-props | |
--rewrite-root= --prefix= --use-log-author | |
--add-author-from $remote_opts | |
"; | |
local cmt_opts=" | |
--edit --rmdir --find-copies-harder --copy-similarity= | |
"; | |
case "$subcommand,$cur" in | |
fetch,--*) | |
__gitcomp "--revision= --fetch-all $fc_opts" | |
;; | |
clone,--*) | |
__gitcomp "--revision= $fc_opts $init_opts" | |
;; | |
init,--*) | |
__gitcomp "$init_opts" | |
;; | |
dcommit,--*) | |
__gitcomp " | |
--merge --strategy= --verbose --dry-run | |
--fetch-all --no-rebase --commit-url | |
--revision --interactive $cmt_opts $fc_opts | |
" | |
;; | |
set-tree,--*) | |
__gitcomp "--stdin $cmt_opts $fc_opts" | |
;; | |
create-ignore,--* | propget,--* | proplist,--* | show-ignore,--* | show-externals,--* | mkdirs,--*) | |
__gitcomp "--revision=" | |
;; | |
log,--*) | |
__gitcomp " | |
--limit= --revision= --verbose --incremental | |
--oneline --show-commit --non-recursive | |
--authors-file= --color | |
" | |
;; | |
rebase,--*) | |
__gitcomp " | |
--merge --verbose --strategy= --local | |
--fetch-all --dry-run $fc_opts | |
" | |
;; | |
commit-diff,--*) | |
__gitcomp "--message= --file= --revision= $cmt_opts" | |
;; | |
info,--*) | |
__gitcomp "--url" | |
;; | |
branch,--*) | |
__gitcomp "--dry-run --message --tag" | |
;; | |
tag,--*) | |
__gitcomp "--dry-run --message" | |
;; | |
blame,--*) | |
__gitcomp "--git-format" | |
;; | |
migrate,--*) | |
__gitcomp " | |
--config-dir= --ignore-paths= --minimize | |
--no-auth-cache --username= | |
" | |
;; | |
reset,--*) | |
__gitcomp "--revision= --parent" | |
;; | |
*) | |
COMPREPLY=() | |
;; | |
esac; | |
fi | |
} | |
_git_tag () | |
{ | |
local i c=1 f=0; | |
while [ $c -lt $cword ]; do | |
i="${words[c]}"; | |
case "$i" in | |
-d | -v) | |
__gitcomp_nl "$(__git_tags)"; | |
return | |
;; | |
-f) | |
f=1 | |
;; | |
esac; | |
((c++)); | |
done; | |
case "$prev" in | |
-m | -F) | |
COMPREPLY=() | |
;; | |
-* | tag) | |
if [ $f = 1 ]; then | |
__gitcomp_nl "$(__git_tags)"; | |
else | |
COMPREPLY=(); | |
fi | |
;; | |
*) | |
__gitcomp_nl "$(__git_refs)" | |
;; | |
esac | |
} | |
_git_whatchanged () | |
{ | |
_git_log | |
} | |
_gitk () | |
{ | |
if [[ -n ${ZSH_VERSION-} ]]; then | |
emulate -L bash; | |
setopt KSH_TYPESET; | |
typeset -h words; | |
typeset -h IFS; | |
fi; | |
local cur words cword prev; | |
_get_comp_words_by_ref -n =: cur words cword prev; | |
__git_has_doubledash && return; | |
local g="$(__gitdir)"; | |
local merge=""; | |
if [ -f "$g/MERGE_HEAD" ]; then | |
merge="--merge"; | |
fi; | |
case "$cur" in | |
--*) | |
__gitcomp " | |
$__git_log_common_options | |
$__git_log_gitk_options | |
$merge | |
"; | |
return | |
;; | |
esac; | |
__git_complete_revlist | |
} | |
_have () | |
{ | |
PATH=$PATH:/usr/sbin:/sbin:/usr/local/sbin type $1 &>/dev/null | |
} | |
_init_completion () | |
{ | |
local exclude= flag outx errx inx OPTIND=1; | |
while getopts "n:e:o:i:s" flag "$@"; do | |
case $flag in | |
n) | |
exclude+=$OPTARG | |
;; | |
e) | |
errx=$OPTARG | |
;; | |
o) | |
outx=$OPTARG | |
;; | |
i) | |
inx=$OPTARG | |
;; | |
s) | |
split=false; | |
exclude+== | |
;; | |
esac; | |
done; | |
COMPREPLY=(); | |
local redir="@(?([0-9])<|?([0-9&])>?(>)|>&)"; | |
_get_comp_words_by_ref -n "$exclude<>&" cur prev words cword; | |
_variables && return 1; | |
if [[ $cur == $redir* || $prev == $redir ]]; then | |
local xspec; | |
case $cur in | |
2'>'*) | |
xspec=$errx | |
;; | |
*'>'*) | |
xspec=$outx | |
;; | |
*'<'*) | |
xspec=$inx | |
;; | |
*) | |
case $prev in | |
2'>'*) | |
xspec=$errx | |
;; | |
*'>'*) | |
xspec=$outx | |
;; | |
*'<'*) | |
xspec=$inx | |
;; | |
esac | |
;; | |
esac; | |
cur="${cur##$redir}"; | |
_filedir $xspec; | |
return 1; | |
fi; | |
local i skip; | |
for ((i=1; i < ${#words[@]}; 1)) | |
do | |
if [[ ${words[i]} == $redir* ]]; then | |
[[ ${words[i]} == $redir ]] && skip=2 || skip=1; | |
words=("${words[@]:0:i}" "${words[@]:i+skip}"); | |
[[ $i -le $cword ]] && cword=$(( cword - skip )); | |
else | |
i=$(( ++i )); | |
fi; | |
done; | |
[[ $cword -eq 0 ]] && return 1; | |
prev=${words[cword-1]}; | |
[[ -n ${split-} ]] && _split_longopt && split=true; | |
return 0 | |
} | |
_insserv () | |
{ | |
local cur prev sysvdir services options; | |
cur=`_get_cword`; | |
prev=${COMP_WORDS[COMP_CWORD-1]}; | |
[ -d /etc/rc.d/init.d ] && sysvdir=/etc/rc.d/init.d || sysvdir=/etc/init.d; | |
services=($(echo $sysvdir/!(README*|*.dpkg*|*.rpm@(orig|new|save)))); | |
services=(${services[@]#$sysvdir/}); | |
options=(-c --config -d -f -n -o --override -p --path -r -v); | |
case "$prev" in | |
-c | --config) | |
_filedir | |
;; | |
-o | --override | -p | --path) | |
_filedir -d | |
;; | |
*) | |
COMPREPLY=($( compgen -W '${options[@]} ${services[@]}' -- $cur )) | |
;; | |
esac; | |
return 0 | |
} | |
_installed_modules () | |
{ | |
COMPREPLY=($( compgen -W "$( PATH="$PATH:/sbin" lsmod | awk '{if (NR != 1) print $1}' )" -- "$1" )) | |
} | |
_ip_addresses () | |
{ | |
COMPREPLY+=($( compgen -W "$( PATH="$PATH:/sbin" LC_ALL=C ifconfig -a | | |
sed -ne 's/.*addr:\([^[:space:]]*\).*/\1/p' -ne 's/.*inet[[:space:]]\{1,\}\([^[:space:]]*\).*/\1/p' )" -- "$cur" )) | |
} | |
_kernel_versions () | |
{ | |
COMPREPLY=($( compgen -W '$( command ls /lib/modules )' -- "$cur" )) | |
} | |
_kernels () | |
{ | |
COMPREPLY=($( cd /lib/modules && compgen -d -- "$cur" )) | |
} | |
_known_hosts () | |
{ | |
local cur prev words cword; | |
_init_completion -n : || return; | |
local options; | |
[[ "$1" == -a || "$2" == -a ]] && options=-a; | |
[[ "$1" == -c || "$2" == -c ]] && options+=" -c"; | |
_known_hosts_real $options -- "$cur" | |
} | |
_known_hosts_real () | |
{ | |
local configfile flag prefix; | |
local cur curd awkcur user suffix aliases i host; | |
local -a kh khd config; | |
local OPTIND=1; | |
while getopts "acF:p:" flag "$@"; do | |
case $flag in | |
a) | |
aliases='yes' | |
;; | |
c) | |
suffix=':' | |
;; | |
F) | |
configfile=$OPTARG | |
;; | |
p) | |
prefix=$OPTARG | |
;; | |
esac; | |
done; | |
[[ $# -lt $OPTIND ]] && echo "error: $FUNCNAME: missing mandatory argument CWORD"; | |
cur=${!OPTIND}; | |
let "OPTIND += 1"; | |
[[ $# -ge $OPTIND ]] && echo "error: $FUNCNAME("$@"): unprocessed arguments:" $(while [[ $# -ge $OPTIND ]]; do printf '%s\n' ${!OPTIND}; shift; done); | |
[[ $cur == *@* ]] && user=${cur%@*}@ && cur=${cur#*@}; | |
kh=(); | |
if [[ -n $configfile ]]; then | |
[[ -r $configfile ]] && config+=("$configfile"); | |
else | |
for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; | |
do | |
[[ -r $i ]] && config+=("$i"); | |
done; | |
fi; | |
if [[ ${#config[@]} -gt 0 ]]; then | |
local OIFS=$IFS IFS=' | |
' j; | |
local -a tmpkh; | |
tmpkh=($( awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t]+", "") { print $0 }' "${config[@]}" | sort -u )); | |
IFS=$OIFS; | |
for i in "${tmpkh[@]}"; | |
do | |
while [[ $i =~ ^([^\"]*)\"([^\"]*)\"(.*)$ ]]; do | |
i=${BASH_REMATCH[1]}${BASH_REMATCH[3]}; | |
j=${BASH_REMATCH[2]}; | |
__expand_tilde_by_ref j; | |
[[ -r $j ]] && kh+=("$j"); | |
done; | |
for j in $i; | |
do | |
__expand_tilde_by_ref j; | |
[[ -r $j ]] && kh+=("$j"); | |
done; | |
done; | |
fi; | |
if [[ -z $configfile ]]; then | |
for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts ~/.ssh/known_hosts2; | |
do | |
[[ -r $i ]] && kh+=("$i"); | |
done; | |
for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; | |
do | |
[[ -d $i ]] && khd+=("$i"/*pub); | |
done; | |
fi; | |
if [[ ${#kh[@]} -gt 0 || ${#khd[@]} -gt 0 ]]; then | |
awkcur=${cur//\//\\\/}; | |
awkcur=${awkcur//\./\\\.}; | |
curd=$awkcur; | |
if [[ "$awkcur" == [0-9]*[.:]* ]]; then | |
awkcur="^$awkcur[.:]*"; | |
else | |
if [[ "$awkcur" == [0-9]* ]]; then | |
awkcur="^$awkcur.*[.:]"; | |
else | |
if [[ -z $awkcur ]]; then | |
awkcur="[a-z.:]"; | |
else | |
awkcur="^$awkcur"; | |
fi; | |
fi; | |
fi; | |
if [[ ${#kh[@]} -gt 0 ]]; then | |
COMPREPLY+=($( awk 'BEGIN {FS=","} | |
/^\s*[^|\#]/ { | |
sub("^@[^ ]+ +", ""); \ | |
sub(" .*$", ""); \ | |
for (i=1; i<=NF; ++i) { \ | |
sub("^\\[", "", $i); sub("\\](:[0-9]+)?$", "", $i); \ | |
if ($i !~ /[*?]/ && $i ~ /'"$awkcur"'/) {print $i} \ | |
}}' "${kh[@]}" 2>/dev/null )); | |
fi; | |
if [[ ${#khd[@]} -gt 0 ]]; then | |
for i in "${khd[@]}"; | |
do | |
if [[ "$i" == *key_22_$curd*.pub && -r "$i" ]]; then | |
host=${i/#*key_22_/}; | |
host=${host/%.pub/}; | |
COMPREPLY+=($host); | |
fi; | |
done; | |
fi; | |
for ((i=0; i < ${#COMPREPLY[@]}; i++ )) | |
do | |
COMPREPLY[i]=$prefix$user${COMPREPLY[i]}$suffix; | |
done; | |
fi; | |
if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then | |
local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" ); | |
COMPREPLY+=($( compgen -P "$prefix$user" -S "$suffix" -W "$hosts" -- "$cur" )); | |
fi; | |
if [[ -n ${COMP_KNOWN_HOSTS_WITH_AVAHI:-} ]] && type avahi-browse &>/dev/null; then | |
COMPREPLY+=($( compgen -P "$prefix$user" -S "$suffix" -W "$( avahi-browse -cpr _workstation._tcp 2>/dev/null | awk -F';' '/^=/ { print $7 }' | sort -u )" -- "$cur" )); | |
fi; | |
COMPREPLY+=($( compgen -W "$( ruptime 2>/dev/null | awk '{ print $1 }' )" -- "$cur" )); | |
if [[ -n ${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1} ]]; then | |
COMPREPLY+=($( compgen -A hostname -P "$prefix$user" -S "$suffix" -- "$cur" )); | |
fi; | |
__ltrim_colon_completions "$prefix$user$cur"; | |
return 0 | |
} | |
_longopt () | |
{ | |
local cur prev words cword split; | |
_init_completion -s || return; | |
case "${prev,,}" in | |
--help | --usage | --version) | |
return 0 | |
;; | |
--*dir*) | |
_filedir -d; | |
return 0 | |
;; | |
--*file* | --*path*) | |
_filedir; | |
return 0 | |
;; | |
--+([-a-z0-9_])) | |
local argtype=$( $1 --help 2>&1 | sed -ne "s|.*$prev\[\{0,1\}=[<[]\{0,1\}\([-A-Za-z0-9_]\{1,\}\).*|\1|p" ); | |
case ${argtype,,} in | |
*dir*) | |
_filedir -d; | |
return 0 | |
;; | |
*file* | *path*) | |
_filedir; | |
return 0 | |
;; | |
esac | |
;; | |
esac; | |
$split && return 0; | |
if [[ "$cur" == -* ]]; then | |
COMPREPLY=($( compgen -W "$( $1 --help 2>&1 | sed -ne 's/.*\(--[-A-Za-z0-9]\{1,\}=\{0,1\}\).*/\1/p' | sort -u )" -- "$cur" )); | |
[[ $COMPREPLY == *= ]] && compopt -o nospace; | |
else | |
if [[ "$1" == @(mk|rm)dir ]]; then | |
_filedir -d; | |
else | |
_filedir; | |
fi; | |
fi | |
} | |
_mac_addresses () | |
{ | |
local re='\([A-Fa-f0-9]\{2\}:\)\{5\}[A-Fa-f0-9]\{2\}'; | |
local PATH="$PATH:/sbin:/usr/sbin"; | |
COMPREPLY+=($( ifconfig -a 2>/dev/null | sed -ne "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" -ne "s/^[[:space:]]\{1,\}ether[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" )); | |
COMPREPLY+=($( arp -an 2>/dev/null | sed -ne "s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p" )); | |
COMPREPLY+=($( sed -ne "s/^[[:space:]]*\($re\)[[:space:]].*/\1/p" /etc/ethers 2>/dev/null )); | |
COMPREPLY=($( compgen -W '${COMPREPLY[@]}' -- "$cur" )); | |
__ltrim_colon_completions "$cur" | |
} | |
_minimal () | |
{ | |
local cur prev words cword split; | |
_init_completion -s || return; | |
$split && return; | |
_filedir | |
} | |
_modules () | |
{ | |
local modpath; | |
modpath=/lib/modules/$1; | |
COMPREPLY=($( compgen -W "$( command ls -RL $modpath 2>/dev/null | sed -ne 's/^\(.*\)\.k\{0,1\}o\(\.[gx]z\)\{0,1\}$/\1/p' )" -- "$cur" )) | |
} | |
_ncpus () | |
{ | |
local var=NPROCESSORS_ONLN; | |
[[ $OSTYPE == *linux* ]] && var=_$var; | |
local n=$( getconf $var 2>/dev/null ); | |
printf %s ${n:-1} | |
} | |
_openvpn () | |
{ | |
local cur; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
if [ $COMP_CWORD -eq 1 ]; then | |
COMPREPLY=($( compgen -W '$( /etc/init.d/openvpn 2>&1 \ | |
| cut -d"{" -f2 | tr -d "}" | tr "|" " " )' -- $cur )); | |
else | |
COMPREPLY=($( compgen -W '$( command ls /etc/openvpn/*.conf 2>/dev/null \ | |
| sed -e 's%/etc/openvpn/%%' -e 's/\.conf//' )' -- $cur )); | |
fi | |
} | |
_parse_help () | |
{ | |
eval local cmd=$( quote "$1" ); | |
local line; | |
{ | |
case $cmd in | |
-) | |
cat | |
;; | |
*) | |
"$( dequote "$cmd" )" ${2:---help} 2>&1 | |
;; | |
esac | |
} | while read -r line; do | |
[[ $line == *([ ' '])-* ]] || continue; | |
while [[ $line =~ ((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+\]? ]]; do | |
line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"}; | |
done; | |
__parse_options "${line// or /, }"; | |
done | |
} | |
_parse_usage () | |
{ | |
eval local cmd=$( quote "$1" ); | |
local line match option i char; | |
{ | |
case $cmd in | |
-) | |
cat | |
;; | |
*) | |
"$( dequote "$cmd" )" ${2:---usage} 2>&1 | |
;; | |
esac | |
} | while read -r line; do | |
while [[ $line =~ \[[[:space:]]*(-[^]]+)[[:space:]]*\] ]]; do | |
match=${BASH_REMATCH[0]}; | |
option=${BASH_REMATCH[1]}; | |
case $option in | |
-?(\[)+([a-zA-Z0-9?])) | |
for ((i=1; i < ${#option}; i++ )) | |
do | |
char=${option:i:1}; | |
[[ $char != '[' ]] && printf '%s\n' -$char; | |
done | |
;; | |
*) | |
__parse_options "$option" | |
;; | |
esac; | |
line=${line#*"$match"}; | |
done; | |
done | |
} | |
_pci_ids () | |
{ | |
COMPREPLY+=($( compgen -W "$( PATH="$PATH:/sbin" lspci -n | awk '{print $3}')" -- "$cur" )) | |
} | |
_pgids () | |
{ | |
COMPREPLY=($( compgen -W '$( command ps axo pgid= )' -- "$cur" )) | |
} | |
_pids () | |
{ | |
COMPREPLY=($( compgen -W '$( command ps axo pid= )' -- "$cur" )) | |
} | |
_pnames () | |
{ | |
COMPREPLY=($( compgen -X '<defunct>' -W '$( command ps axo command= | \ | |
sed -e "s/ .*//" -e "s:.*/::" -e "s/:$//" -e "s/^[[(-]//" \ | |
-e "s/[])]$//" | sort -u )' -- "$cur" )) | |
} | |
_poff () | |
{ | |
local prev cur conns; | |
[ -r /etc/ppp/peers/ ] || return 0; | |
COMPREPLY=(); | |
prev=${COMP_WORDS[COMP_CWORD-1]}; | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
conns=$(\ls --color=none /etc/ppp/peers | egrep -v '(\.bak|~)$'); | |
if [[ "$cur" == -* ]]; then | |
COMPREPLY=($(compgen -W '-r -d -c -a -h -v' -- $cur)); | |
return 0; | |
fi; | |
if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]] || [[ "$prev" == -* ]]; then | |
COMPREPLY=($(compgen -o filenames -W "$conns" $cur)); | |
fi; | |
return 0 | |
} | |
_pon () | |
{ | |
local cur conns; | |
[ -r /etc/ppp/peers/ ] || return 0; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
conns=$(\ls --color=none /etc/ppp/peers | egrep -v '(\.bak|~)$'); | |
if [ $COMP_CWORD -eq 1 ]; then | |
COMPREPLY=($(compgen -o filenames -W "$conns" $cur)); | |
fi; | |
return 0 | |
} | |
_quote_readline_by_ref () | |
{ | |
if [[ $1 == \'* ]]; then | |
printf -v $2 %s "${1:1}"; | |
else | |
printf -v $2 %q "$1"; | |
fi; | |
[[ ${!2} == \$* ]] && eval $2=${!2} | |
} | |
_realcommand () | |
{ | |
type -P "$1" > /dev/null && { | |
if type -p realpath > /dev/null; then | |
realpath "$(type -P "$1")"; | |
else | |
if type -p greadlink > /dev/null; then | |
greadlink -f "$(type -P "$1")"; | |
else | |
if type -p readlink > /dev/null; then | |
readlink -f "$(type -P "$1")"; | |
else | |
type -P "$1"; | |
fi; | |
fi; | |
fi | |
} | |
} | |
_rl_enabled () | |
{ | |
[[ "$( bind -v )" = *$1+([[:space:]])on* ]] | |
} | |
_root_command () | |
{ | |
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin; | |
local root_command=$1; | |
_command | |
} | |
_service () | |
{ | |
local cur prev words cword; | |
_init_completion || return; | |
[[ $cword -gt 2 ]] && return 0; | |
if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then | |
_services; | |
[[ -e /etc/mandrake-release ]] && _xinetd_services; | |
else | |
local sysvdirs; | |
_sysvdirs; | |
COMPREPLY=($( compgen -W '`sed -e "y/|/ /" \ | |
-ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \ | |
${sysvdirs[0]}/${prev##*/} 2>/dev/null` start stop' -- "$cur" )); | |
fi | |
} | |
_services () | |
{ | |
local sysvdirs; | |
_sysvdirs; | |
local restore_nullglob=$(shopt -p nullglob); | |
shopt -s nullglob; | |
COMPREPLY=($( printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions) )); | |
$restore_nullglob; | |
COMPREPLY+=($( systemctl list-units --full --all 2>/dev/null | awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }' )); | |
COMPREPLY=($( compgen -W '${COMPREPLY[@]#${sysvdirs[0]}/}' -- "$cur" )) | |
} | |
_shells () | |
{ | |
local shell rest; | |
while read -r shell rest; do | |
[[ $shell == /* && $shell == "$cur"* ]] && COMPREPLY+=($shell); | |
done 2> /dev/null < /etc/shells | |
} | |
_signals () | |
{ | |
local -a sigs=($( compgen -P "$1" -A signal "SIG${cur#$1}" )); | |
COMPREPLY+=("${sigs[@]/#${1}SIG/${1}}") | |
} | |
_split_longopt () | |
{ | |
if [[ "$cur" == --?*=* ]]; then | |
prev="${cur%%?(\\)=*}"; | |
cur="${cur#*=}"; | |
return 0; | |
fi; | |
return 1 | |
} | |
_subdirectories () | |
{ | |
COMPREPLY=($( cd $1 && compgen -d -- "$cur" )) | |
} | |
_svn () | |
{ | |
local cur cmds cmdOpts pOpts mOpts rOpts qOpts nOpts optsParam opt; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
cmds='add blame annotate praise cat changelist cl checkout co cleanup'; | |
cmds="$cmds commit ci copy cp delete remove rm diff export help import"; | |
cmds="$cmds info list ls lock log merge mergeinfo mkdir move mv rename"; | |
cmds="$cmds propdel pdel propedit pedit propget pget proplist plist"; | |
cmds="$cmds propset pset resolve resolved revert status switch unlock"; | |
cmds="$cmds update"; | |
local helpOpts='--help -h'; | |
local specOpts="--version $helpOpts"; | |
optsParam="-r|--revision|--username|--password|--targets"; | |
optsParam="$optsParam|-x|--extensions|-m|--message|-F|--file"; | |
optsParam="$optsParam|--encoding|--diff-cmd|--diff3-cmd|--editor-cmd"; | |
optsParam="$optsParam|--old|--new|--config-dir|--config-option"; | |
optsParam="$optsParam|--native-eol|-l|--limit|-c|--change"; | |
optsParam="$optsParam|--depth|--set-depth|--with-revprop"; | |
optsParam="$optsParam|--changelist|--accept|--show-revs"; | |
local svnProps revProps allProps psCmds propCmds; | |
svnProps="svn:keywords svn:executable svn:needs-lock svn:externals | |
svn:ignore svn:eol-style svn:mime-type $SVN_BASH_FILE_PROPS"; | |
revProps="svn:author svn:log svn:date $SVN_BASH_REV_PROPS"; | |
allProps=($svnProps $revProps); | |
psCmds='propset|pset|ps'; | |
propCmds="$psCmds|propget|pget|pg|propedit|pedit|pe|propdel|pdel|pd"; | |
local cmd= isPropCmd= isPsCmd= isHelpCmd= nExpectArgs= isCur= i=0; | |
local prev= help= prop= val= isRevProp= last='none' nargs=0 stat=; | |
local options= hasRevPropOpt= hasRevisionOpt= hasRelocateOpt=; | |
local acceptOpt= URL= hasReintegrateOpt=; | |
for opt in "${COMP_WORDS[@]}"; | |
do | |
[[ -n $isCur ]] && stat=$last; | |
isCur=; | |
[[ $i -eq $COMP_CWORD ]] && isCur=1; | |
let i++; | |
[ $last = 'none' ] && { | |
last='first'; | |
continue | |
}; | |
if [[ $prev == @($optsParam) ]]; then | |
[[ $prev = '--accept' ]] && acceptOpt=$opt; | |
prev=''; | |
last='skip'; | |
continue; | |
fi; | |
if [[ $prev == @(<|>|>>|[12]>|[12]>>) ]]; then | |
prev=''; | |
last='skip'; | |
continue; | |
fi; | |
prev=$opt; | |
if [[ ! -n $cmd && -n $opt && ( $opt != -* || $opt == @(${specOpts// /|}) ) ]]; then | |
cmd=$opt; | |
[[ $cmd == @($propCmds) ]] && isPropCmd=1; | |
[[ $cmd == @($psCmds) ]] && isPsCmd=1; | |
[[ $cmd == @(${helpOpts// /|}) ]] && cmd='help'; | |
[[ $cmd = 'help' ]] && isHelpCmd=1; | |
if [[ -n $isHelpCmd && -n $cmd && $cmd != 'help' && ! -n $help ]]; then | |
help=$cmd; | |
cmd='help'; | |
fi; | |
last='cmd'; | |
continue; | |
fi; | |
if [[ -n $isHelpCmd && ! -n $help && -n $opt && $opt != -* ]]; then | |
help=$opt; | |
last='help'; | |
continue; | |
fi; | |
if [[ -n $isPropCmd && ! -n $prop && -n $opt && $opt != -* ]]; then | |
prop=$opt; | |
[[ $prop == @(${revProps// /|}) ]] && isRevProp=1; | |
last='prop'; | |
continue; | |
fi; | |
if [[ -n $isPsCmd && -n $prop && ! -n $val && $opt != -* ]]; then | |
val=$opt; | |
last='val'; | |
continue; | |
fi; | |
if [[ $last != 'onlyarg' ]]; then | |
case $opt in | |
-r | --revision | --revision=*) | |
hasRevisionOpt=1 | |
;; | |
--revprop) | |
hasRevPropOpt=1; | |
allProps=($revProps); | |
nExpectArgs=1 | |
;; | |
-h | --help) | |
isHelpCmd=1 | |
;; | |
-F | --file) | |
val='-F' | |
;; | |
--relocate) | |
hasRelocateOpt=1 | |
;; | |
--reintegrate) | |
hasReintegrateOpt=1 | |
;; | |
esac; | |
if [[ $opt = '--' && ! -n $isCur ]]; then | |
last='onlyarg'; | |
continue; | |
fi; | |
if [[ $opt == -* ]]; then | |
[[ ! -n $isCur ]] && options="$options $opt "; | |
last='opt'; | |
continue; | |
fi; | |
else | |
let nargs++; | |
continue; | |
fi; | |
if [[ $cmd = 'merge' && ! -n $URL ]]; then | |
URL=$opt; | |
fi; | |
last='arg'; | |
let nargs++; | |
done; | |
[[ -n $stat ]] || stat=$last; | |
if [[ ! -n $cmd || $stat = 'cmd' ]]; then | |
COMPREPLY=($( compgen -W "$cmds $specOpts" -- $cur )); | |
return 0; | |
fi; | |
if [[ $stat = 'help' || ( -n $isHelpCmd && ! -n $help ) ]]; then | |
COMPREPLY=($( compgen -W "$cmds" -- $cur )); | |
return 0; | |
fi; | |
if [[ $cmd = 'merge' || $cmd = 'mergeinfo' ]]; then | |
local here=$(_svn_info URL); | |
if [[ ! -n $URL && $stat = 'arg' ]]; then | |
if [[ "$here" == */branches/* ]]; then | |
COMPREPLY=($(compgen -W ${here/\/branches\/*/\/trunk} -- $cur )); | |
return 0; | |
else | |
if [[ "$here" == */trunk* ]]; then | |
COMPREPLY=($(compgen -W ${here/\/trunk*/\/branches\/} -- $cur )); | |
return 0; | |
else | |
COMPREPLY=($(compgen -W $(_svn_info Root) -- $cur )); | |
return 0; | |
fi; | |
fi; | |
else | |
if [[ $URL == */branches/* && $here == */trunk* && ! -n $hasReintegrateOpt && $cur = '' && $stat = 'arg' ]]; then | |
COMPREPLY=($(compgen -W '--reintegrate' -- $cur )); | |
return 0; | |
fi; | |
fi; | |
fi; | |
if [[ $stat = 'skip' ]]; then | |
local previous=${COMP_WORDS[COMP_CWORD-1]}; | |
local values= dirs= beep= exes=; | |
[[ $previous = '--config-dir' ]] && dirs=1; | |
[[ $previous = --*-cmd ]] && exes=1; | |
[[ $previous = '--native-eol' ]] && values='LF CR CRLF'; | |
[[ $previous = '--limit' ]] && values='0 1 2 3 4 5 6 7 8 9'; | |
[[ $previous = '--revision' || $previous = '-r' ]] && values='HEAD BASE PREV COMMITTED 0 {'; | |
[[ $previous = '--encoding' ]] && values="latin1 utf8 $SVN_BASH_ENCODINGS"; | |
[[ $previous = '--extensions' || $previous = '-x' ]] && values="--unified --ignore-space-change --ignore-all-space --ignore-eol-style"; | |
[[ $previous = '--depth' ]] && values='empty files immediates infinity'; | |
[[ $previous = '--set-depth' ]] && values='empty exclude files immediates infinity'; | |
[[ $previous = '--accept' ]] && { | |
if [[ $cmd = 'resolve' ]]; then | |
values='base working mine-full theirs-full'; | |
else | |
values='postpone base mine-full theirs-full edit launch'; | |
fi | |
}; | |
[[ $previous = '--show-revs' ]] && values='merged eligible'; | |
if [[ $previous = '--username' ]]; then | |
values="$SVN_BASH_USERNAME"; | |
if [[ $SVN_BASH_COMPL_EXT == *username* ]]; then | |
local file=; | |
for file in ~/.subversion/auth/svn.simple/*; | |
do | |
if [ -r $file ]; then | |
values="$values $(_svn_read_hashfile username < $file)"; | |
fi; | |
done; | |
fi; | |
[[ ! -n "$values" ]] && beep=1; | |
fi; | |
[[ $previous = '--password' ]] && beep=1; | |
[[ -n $values ]] && COMPREPLY=($( compgen -W "$values" -- $cur )); | |
[[ -n $dirs ]] && COMPREPLY=($( compgen -o dirnames -- $cur )); | |
[[ -n $exes ]] && COMPREPLY=($( compgen -c -- $cur )); | |
[[ -n $beep ]] && { | |
echo -en "\a"; | |
COMPREPLY=('') | |
}; | |
return 0; | |
fi; | |
if [[ -n $isPropCmd && ( ! -n $prop || $stat = 'prop' ) && $cur != -* ]]; then | |
local choices=; | |
if [[ $cur == *:* ]]; then | |
local prefix=${cur%:*} suffix=${cur#*:} c=; | |
for c in ${allProps[@]}; | |
do | |
[[ $c == $prefix:* ]] && choices="$choices ${c#*:}"; | |
done; | |
cur=$suffix; | |
else | |
COMPREPLY=($( compgen -W "${allProps[*]}" -- $cur )); | |
[ ${#COMPREPLY[@]} -eq 1 ] && return 0; | |
local seen= n=0 last= c=; | |
for c in ${allProps[@]%:*}; | |
do | |
if [[ $c == $cur* && ( ! -n $seen || $c != @($seen) ) ]]; then | |
let n++; | |
last=$c; | |
choices="$choices $c:"; | |
if [[ -n $seen ]]; then | |
seen="$seen|$c*"; | |
else | |
seen="$c*"; | |
fi; | |
fi; | |
done; | |
[[ $n -eq 1 ]] && choices="$last:1 $last:2"; | |
fi; | |
COMPREPLY=($( compgen -W "$choices" -- $cur )); | |
return 0; | |
fi; | |
if [[ -n $isRevProp && ! -n $hasRevPropOpt ]]; then | |
COMPREPLY=($( compgen -W '--revprop' -- $cur )); | |
return 0; | |
fi; | |
if [[ -n $isRevProp && -n $hasRevPropOpt && ! -n $hasRevisionOpt ]]; then | |
COMPREPLY=($( compgen -W '--revision' -- $cur )); | |
return 0; | |
fi; | |
if [[ -n $isPsCmd && -n $prop && ( ! -n $val || $stat = 'val' ) ]]; then | |
local values="\' --file"; | |
case $prop in | |
svn:keywords) | |
values="Id Rev URL Date Author Header \' $SVN_BASH_KEYWORDS" | |
;; | |
svn:executable | svn:needs-lock) | |
values='\\*' | |
;; | |
svn:eol-style) | |
values='native LF CR CRLF' | |
;; | |
svn:mime-type) | |
values="text/ text/plain text/html text/xml text/rtf | |
image/ image/png image/gif image/jpeg image/tiff | |
audio/ audio/midi audio/mpeg | |
video/ video/mpeg video/mp4 | |
application/ application/octet-stream | |
$SVN_BASH_MIME_TYPE" | |
;; | |
esac; | |
COMPREPLY=($( compgen -W "$values" -- $cur )); | |
[[ -n ${COMPREPLY} ]] && return 0; | |
fi; | |
if [[ $cmd = 'resolve' && ! -n $acceptOpt ]]; then | |
COMPREPLY=($( compgen -W '--accept' -- $cur )); | |
return 0; | |
fi; | |
case $cmd in | |
merge) | |
nExpectArgs=3 | |
;; | |
mergeinfo) | |
nExpectArgs=1 | |
;; | |
copy | cp | move | mv | rename | ren | export | import) | |
nExpectArgs=2 | |
;; | |
switch | sw) | |
[[ ! -n $hasRelocateOpt ]] && nExpectArgs=2 | |
;; | |
help | h) | |
nExpectArgs=0 | |
;; | |
--version) | |
nExpectArgs=0 | |
;; | |
esac; | |
if [[ -n $nExpectArgs && $nargs -gt $nExpectArgs ]]; then | |
echo -en "\a"; | |
COMPREPLY=(''); | |
return 0; | |
fi; | |
if [[ $cur != -* || $stat = 'onlyarg' ]]; then | |
if [[ $SVN_BASH_COMPL_EXT == *svnstatus* ]]; then | |
local status='svn status --non-interactive'; | |
[[ $SVN_BASH_COMPL_EXT == *recurse* ]] || status="$status --non-recursive"; | |
[[ $SVN_BASH_COMPL_EXT == *externals* ]] || status="$status --ignore-externals"; | |
local cs= files=; | |
[[ -n $cur ]] && cs=$cur*; | |
case $cmd in | |
st*) | |
files=$cur* | |
;; | |
ci | commit | revert | di*) | |
files=$($status $cs| _svn_grcut '@([MADR!]*| M*|_M*)') | |
;; | |
add) | |
files=$($status $cs| _svn_grcut '\?*') | |
;; | |
unlock) | |
files=$($status $cs| _svn_grcut '@(??L*|?????[KOTB]*)') | |
;; | |
resolve*) | |
files=$($status $cs| _svn_grcut '@(?C*|C*)') | |
;; | |
praise | blame | ann*) | |
files=$( _svn_lls all $cur* ) | |
;; | |
p*) | |
if [[ $cmd == @($propCmds) && $prop == @(svn:ignore|svn:externals) ]]; then | |
files=$( _svn_lls dir . $cur* ); | |
else | |
files="$( _svn_lls all $cur* ) | |
$($status $cs | _svn_grcut 'A*' )"; | |
fi | |
;; | |
info) | |
files="$( _svn_lls all $cur* ) | |
$($status $cs | _svn_grcut 'A*' )" | |
;; | |
remove | rm | del* | move | mv | rename) | |
files=$( _svn_lls all $cur* ) | |
;; | |
mkdir) | |
files=$( _svn_lls dir $cur* ) | |
;; | |
log | lock | up* | cl* | switch) | |
files=$( _svn_lls all $cur* ) | |
;; | |
merge) | |
files=$( _svn_lls all $cur* ) | |
;; | |
ls | list) | |
files=$( _svn_lls all $cur* ) | |
;; | |
*) | |
local fallback=1 | |
;; | |
esac; | |
if [[ $SVN_BASH_COMPL_EXT != *recurse* ]]; then | |
files="$files $( _svn_lls dir $cur* )"; | |
fi; | |
if [[ -n $files ]]; then | |
COMPREPLY=($( compgen -W "$files" -- $cur )); | |
[[ -n "${COMPREPLY[*]}" ]] || COMPREPLY=(''); | |
else | |
if [[ ! -n $fallback ]]; then | |
echo -en "\a"; | |
COMPREPLY=(''); | |
fi; | |
fi; | |
fi; | |
return 0; | |
fi; | |
pOpts="--username --password --no-auth-cache --non-interactive"; | |
mOpts="-m --message -F --file --encoding --force-log --with-revprop"; | |
rOpts="-r --revision"; | |
qOpts="-q --quiet"; | |
nOpts="-N --non-recursive --depth"; | |
gOpts="-g --use-merge-history"; | |
cmdOpts=; | |
case $cmd in | |
--version) | |
cmdOpts="$qOpts" | |
;; | |
add) | |
cmdOpts="--auto-props --no-auto-props --force --targets --no-ignore --parents $nOpts $qOpts $pOpts" | |
;; | |
blame | annotate | ann | praise) | |
cmdOpts="$rOpts $pOpts -v --verbose --incremental --xml -x --extensions --force $gOpts" | |
;; | |
cat) | |
cmdOpts="$rOpts $pOpts" | |
;; | |
changelist | cl) | |
cmdOpts="--targets $pOpts $qOpts --changelist -R --recursive --depth --remove" | |
;; | |
checkout | co) | |
cmdOpts="$rOpts $qOpts $nOpts $pOpts --ignore-externals --force --accept" | |
;; | |
cleanup) | |
cmdOpts="--diff3-cmd $pOpts" | |
;; | |
commit | ci) | |
cmdOpts="$mOpts $qOpts $nOpts --targets --editor-cmd $pOpts --no-unlock --changelist --keep-changelists" | |
;; | |
copy | cp) | |
cmdOpts="$mOpts $rOpts $qOpts --editor-cmd $pOpts --parents" | |
;; | |
delete | del | remove | rm) | |
cmdOpts="--force $mOpts $qOpts --targets --editor-cmd $pOpts --keep-local" | |
;; | |
diff | di) | |
cmdOpts="$rOpts -x --extensions --diff-cmd --no-diff-deleted $nOpts $pOpts --force --old --new --notice-ancestry -c --change --summarize --changelist --xml" | |
;; | |
export) | |
cmdOpts="$rOpts $qOpts $pOpts $nOpts --force --native-eol --ignore-externals" | |
;; | |
help | h | \?) | |
cmdOpts= | |
;; | |
import) | |
cmdOpts="--auto-props --no-auto-props $mOpts $qOpts $nOpts --no-ignore --editor-cmd $pOpts --force" | |
;; | |
info) | |
cmdOpts="$pOpts $rOpts --targets -R --recursive --depth --incremental --xml --changelist" | |
;; | |
list | ls) | |
cmdOpts="$rOpts -v --verbose -R --recursive $pOpts --incremental --xml --depth" | |
;; | |
lock) | |
cmdOpts="-m --message -F --file --encoding --force-log --targets --force $pOpts" | |
;; | |
log) | |
cmdOpts="$rOpts -v --verbose --targets $pOpts --stop-on-copy --incremental --xml $qOpts -l --limit -c --change $gOpts --with-all-revprops --with-revprop" | |
;; | |
merge) | |
cmdOpts="$rOpts $nOpts $qOpts --force --dry-run --diff3-cmd $pOpts --ignore-ancestry -c --change -x --extensions --record-only --accept --reintegrate" | |
;; | |
mergeinfo) | |
cmdOpts="$rOpts $pOpts --show-revs" | |
;; | |
mkdir) | |
cmdOpts="$mOpts $qOpts --editor-cmd $pOpts --parents" | |
;; | |
move | mv | rename | ren) | |
cmdOpts="$mOpts $rOpts $qOpts --force --editor-cmd $pOpts --parents" | |
;; | |
propdel | pdel | pd) | |
cmdOpts="$qOpts -R --recursive $rOpts $pOpts --changelist --depth"; | |
[[ -n $isRevProp || ! -n $prop ]] && cmdOpts="$cmdOpts --revprop" | |
;; | |
propedit | pedit | pe) | |
cmdOpts="--editor-cmd $pOpts $mOpts --force"; | |
[[ -n $isRevProp || ! -n $prop ]] && cmdOpts="$cmdOpts --revprop $rOpts" | |
;; | |
propget | pget | pg) | |
cmdOpts="-v --verbose -R --recursive $rOpts --strict $pOpts --changelist --depth --xml"; | |
[[ -n $isRevProp || ! -n $prop ]] && cmdOpts="$cmdOpts --revprop" | |
;; | |
proplist | plist | pl) | |
cmdOpts="-v --verbose -R --recursive $rOpts --revprop $qOpts $pOpts --changelist --depth --xml" | |
;; | |
propset | pset | ps) | |
cmdOpts="$qOpts --targets -R --recursive --encoding $pOpts --force --changelist --depth"; | |
[[ -n $isRevProp || ! -n $prop ]] && cmdOpts="$cmdOpts --revprop $rOpts"; | |
[[ -n $val ]] || cmdOpts="$cmdOpts -F --file" | |
;; | |
resolve) | |
cmdOpts="--targets -R --recursive $qOpts $pOpts --accept --depth" | |
;; | |
resolved) | |
cmdOpts="--targets -R --recursive $qOpts $pOpts --depth" | |
;; | |
revert) | |
cmdOpts="--targets -R --recursive $qOpts --changelist --depth $pOpts" | |
;; | |
status | stat | st) | |
cmdOpts="-u --show-updates -v --verbose $nOpts $qOpts $pOpts --no-ignore --ignore-externals --incremental --xml --changelist" | |
;; | |
switch | sw) | |
cmdOpts="--relocate $rOpts $nOpts $qOpts $pOpts --diff3-cmd --force --accept --ignore-externals --set-depth" | |
;; | |
unlock) | |
cmdOpts="--targets --force $pOpts" | |
;; | |
update | up) | |
cmdOpts="$rOpts $nOpts $qOpts $pOpts --diff3-cmd --ignore-externals --force --accept --changelist --editor-cmd --set-depth" | |
;; | |
*) | |
;; | |
esac; | |
[[ "$cmd" != "--version" ]] && cmdOpts="$cmdOpts $helpOpts"; | |
cmdOpts="$cmdOpts --config-dir --config-option"; | |
if [[ $acceptOpt == @(edit|launch) ]]; then | |
cmdOpts=${cmdOpts/ --non-interactive / }; | |
fi; | |
for opt in $options; | |
do | |
local optBase; | |
case $opt in | |
--*) | |
optBase=${opt/=*/} | |
;; | |
-*) | |
optBase=${opt:0:2} | |
;; | |
esac; | |
cmdOpts=" $cmdOpts "; | |
cmdOpts=${cmdOpts/ ${optBase} / }; | |
case $optBase in | |
-v) | |
cmdOpts=${cmdOpts/ --verbose / } | |
;; | |
--verbose) | |
cmdOpts=${cmdOpts/ -v / } | |
;; | |
-N) | |
cmdOpts=${cmdOpts/ --non-recursive / } | |
;; | |
--non-recursive) | |
cmdOpts=${cmdOpts/ -N / } | |
;; | |
-R) | |
cmdOpts=${cmdOpts/ --recursive / } | |
;; | |
--recursive) | |
cmdOpts=${cmdOpts/ -R / } | |
;; | |
-x) | |
cmdOpts=${cmdOpts/ --extensions / } | |
;; | |
--extensions) | |
cmdOpts=${cmdOpts/ -x / } | |
;; | |
-q) | |
cmdOpts=${cmdOpts/ --quiet / } | |
;; | |
--quiet) | |
cmdOpts=${cmdOpts/ -q / } | |
;; | |
-h) | |
cmdOpts=${cmdOpts/ --help / } | |
;; | |
--help) | |
cmdOpts=${cmdOpts/ -h / } | |
;; | |
-l) | |
cmdOpts=${cmdOpts/ --limit / } | |
;; | |
--limit) | |
cmdOpts=${cmdOpts/ -l / } | |
;; | |
-r) | |
cmdOpts=${cmdOpts/ --revision / } | |
;; | |
--revision) | |
cmdOpts=${cmdOpts/ -r / } | |
;; | |
-c) | |
cmdOpts=${cmdOpts/ --change / } | |
;; | |
--change) | |
cmdOpts=${cmdOpts/ -c / } | |
;; | |
--auto-props) | |
cmdOpts=${cmdOpts/ --no-auto-props / } | |
;; | |
--no-auto-props) | |
cmdOpts=${cmdOpts/ --auto-props / } | |
;; | |
-g) | |
cmdOpts=${cmdOpts/ --use-merge-history / } | |
;; | |
--use-merge-history) | |
cmdOpts=${cmdOpts/ -g / } | |
;; | |
-m | --message | -F | --file) | |
cmdOpts=${cmdOpts/ --message / }; | |
cmdOpts=${cmdOpts/ -m / }; | |
cmdOpts=${cmdOpts/ --file / }; | |
cmdOpts=${cmdOpts/ -F / } | |
;; | |
esac; | |
if [ $isHelpCmd ]; then | |
cmdOpts=${cmdOpts/ -h / }; | |
cmdOpts=${cmdOpts/ --help / }; | |
fi; | |
done; | |
COMPREPLY=($( compgen -W "$cmdOpts" -- $cur )); | |
return 0 | |
} | |
_svn_grcut () | |
{ | |
local re=$1 line= old_IFS; | |
old_IFS="$IFS"; | |
IFS=' | |
'; | |
while read -r line; do | |
[[ ! -n $re || $line == $re ]] && echo "${line/????????/}"; | |
done; | |
IFS="$old_IFS" | |
} | |
_svn_info () | |
{ | |
local what=$1 line=; | |
LANG=C LC_MESSAGES=C svn info --non-interactive 2> /dev/null | while read line; do | |
[[ $line == *"$what: "* ]] && echo ${line#*: }; | |
done | |
} | |
_svn_lls () | |
{ | |
local opt=$1 f=; | |
shift; | |
for f in "$@"; | |
do | |
if [[ $opt == @(dir|all) && -d "$f" ]]; then | |
echo "$f/"; | |
else | |
if [[ $opt == @(file|all) ]]; then | |
local dn= fn="$f"; | |
[[ "$f" == */* ]] && dn=${f%\/*}/ fn=${f##*\/}; | |
[ -f "${dn}.svn/text-base/${fn}.svn-base" ] && echo "$f"; | |
fi; | |
fi; | |
done | |
} | |
_svn_read_hashfile () | |
{ | |
local tkey=$1 key= val=; | |
while true; do | |
read tag len; | |
[ $tag = 'END' ] && break; | |
[ $tag != 'K' ] && { | |
return | |
}; | |
read -r -n $len key; | |
read; | |
read tag len; | |
[ $tag != 'V' ] && { | |
return | |
}; | |
read -r -n $len val; | |
read; | |
if [[ $key = $tkey ]]; then | |
echo "$val"; | |
return; | |
fi; | |
done | |
} | |
_svnadmin () | |
{ | |
local cur cmds cmdOpts optsParam opt helpCmds optBase i; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
cmds='crashtest create deltify dump help hotcopy list-dblogs \ | |
list-unused-dblogs load lslocks lstxns pack recover rmlocks \ | |
rmtxns setlog setrevprop setuuid upgrade verify --version'; | |
if [[ $COMP_CWORD -eq 1 ]]; then | |
COMPREPLY=($( compgen -W "$cmds" -- $cur )); | |
return 0; | |
fi; | |
optsParam="-r|--revision|--parent-dir|--fs-type"; | |
helpCmds='help|--help|h|\?'; | |
if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && [[ "$cur" != -* ]] || [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]]; then | |
return 0; | |
fi; | |
cmdOpts=; | |
case ${COMP_WORDS[1]} in | |
create) | |
cmdOpts="--bdb-txn-nosync --bdb-log-keep --config-dir --fs-type --pre-1.4-compatible --pre-1.5-compatible" | |
;; | |
deltify) | |
cmdOpts="-r --revision -q --quiet" | |
;; | |
dump) | |
cmdOpts="-r --revision --incremental -q --quiet --deltas" | |
;; | |
help | h | \?) | |
cmdOpts="$cmds" | |
;; | |
hotcopy) | |
cmdOpts="--clean-logs" | |
;; | |
load) | |
cmdOpts="--ignore-uuid --force-uuid --parent-dir -q --quiet --use-pre-commit-hook --use-post-commit-hook" | |
;; | |
recover) | |
cmdOpts="--wait" | |
;; | |
rmtxns) | |
cmdOpts="-q --quiet" | |
;; | |
setlog) | |
cmdOpts="-r --revision --bypass-hooks" | |
;; | |
setrevprop) | |
cmdOpts="-r --revision --use-pre-revprop-change-hook --use-post-revprop-change-hook" | |
;; | |
verify) | |
cmdOpts="-r --revision -q --quiet" | |
;; | |
*) | |
;; | |
esac; | |
cmdOpts="$cmdOpts --help -h"; | |
for ((i=2; i<=$COMP_CWORD-1; ++i )) | |
do | |
opt=${COMP_WORDS[$i]}; | |
case $opt in | |
--*) | |
optBase=${opt/=*/} | |
;; | |
-*) | |
optBase=${opt:0:2} | |
;; | |
esac; | |
cmdOpts=" $cmdOpts "; | |
cmdOpts=${cmdOpts/ ${optBase} / }; | |
case $optBase in | |
-q) | |
cmdOpts=${cmdOpts/ --quiet / } | |
;; | |
--quiet) | |
cmdOpts=${cmdOpts/ -q / } | |
;; | |
-h) | |
cmdOpts=${cmdOpts/ --help / } | |
;; | |
--help) | |
cmdOpts=${cmdOpts/ -h / } | |
;; | |
-r) | |
cmdOpts=${cmdOpts/ --revision / } | |
;; | |
--revision) | |
cmdOpts=${cmdOpts/ -r / } | |
;; | |
esac; | |
if [[ $opt == @($optsParam) ]]; then | |
((++i)); | |
fi; | |
done; | |
COMPREPLY=($( compgen -W "$cmdOpts" -- $cur )); | |
return 0 | |
} | |
_svndumpfilter () | |
{ | |
local cur cmds cmdOpts optsParam opt helpCmds optBase i; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
cmds='exclude help include --version'; | |
if [[ $COMP_CWORD -eq 1 ]]; then | |
COMPREPLY=($( compgen -W "$cmds" -- $cur )); | |
return 0; | |
fi; | |
optsParam="--targets"; | |
helpCmds='help|--help|h|\?'; | |
if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && [[ "$cur" != -* ]] || [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]]; then | |
return 0; | |
fi; | |
cmdOpts=; | |
case ${COMP_WORDS[1]} in | |
exclude | include) | |
cmdOpts="--drop-empty-revs --renumber-revs | |
--skip-missing-merge-sources --targets | |
--preserve-revprops --quiet" | |
;; | |
help | h | \?) | |
cmdOpts="$cmds" | |
;; | |
*) | |
;; | |
esac; | |
cmdOpts="$cmdOpts --help -h"; | |
for ((i=2; i<=$COMP_CWORD-1; ++i )) | |
do | |
opt=${COMP_WORDS[$i]}; | |
case $opt in | |
--*) | |
optBase=${opt/=*/} | |
;; | |
-*) | |
optBase=${opt:0:2} | |
;; | |
esac; | |
cmdOpts=" $cmdOpts "; | |
cmdOpts=${cmdOpts/ ${optBase} / }; | |
case $optBase in | |
-h) | |
cmdOpts=${cmdOpts/ --help / } | |
;; | |
--help) | |
cmdOpts=${cmdOpts/ -h / } | |
;; | |
esac; | |
if [[ $opt == @($optsParam) ]]; then | |
((++i)); | |
fi; | |
done; | |
COMPREPLY=($( compgen -W "$cmdOpts" -- $cur )); | |
return 0 | |
} | |
_svnlook () | |
{ | |
local cur cmds cmdOpts optsParam opt helpCmds optBase i; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
cmds='author cat changed date diff dirs-changed help history info \ | |
lock log propget proplist tree uuid youngest --version'; | |
if [[ $COMP_CWORD -eq 1 ]]; then | |
COMPREPLY=($( compgen -W "$cmds" -- $cur )); | |
return 0; | |
fi; | |
optsParam="-r|--revision|-t|--transaction|-l|--limit|-x|--extensions"; | |
helpCmds='help|--help|h|\?'; | |
if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && [[ "$cur" != -* ]] || [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]]; then | |
return 0; | |
fi; | |
cmdOpts=; | |
case ${COMP_WORDS[1]} in | |
author) | |
cmdOpts="-r --revision -t --transaction" | |
;; | |
cat) | |
cmdOpts="-r --revision -t --transaction" | |
;; | |
changed) | |
cmdOpts="-r --revision -t --transaction --copy-info" | |
;; | |
date) | |
cmdOpts="-r --revision -t --transaction" | |
;; | |
diff) | |
cmdOpts="-r --revision -t --transaction --diff-copy-from --no-diff-added --no-diff-deleted -x --extensions" | |
;; | |
dirs-changed) | |
cmdOpts="-r --revision -t --transaction" | |
;; | |
help | h | \?) | |
cmdOpts="$cmds" | |
;; | |
history) | |
cmdOpts="-r --revision -l --limit --show-ids" | |
;; | |
info) | |
cmdOpts="-r --revision -t --transaction" | |
;; | |
lock) | |
cmdOpts= | |
;; | |
log) | |
cmdOpts="-r --revision -t --transaction" | |
;; | |
propget | pget | pg) | |
cmdOpts="-r --revision -t --transaction --revprop" | |
;; | |
proplist | plist | pl) | |
cmdOpts="-r --revision -t --transaction --revprop -v --verbose --xml" | |
;; | |
tree) | |
cmdOpts="-r --revision -t --transaction --full-paths -N --non-recursive --show-ids" | |
;; | |
uuid) | |
cmdOpts= | |
;; | |
youngest) | |
cmdOpts= | |
;; | |
*) | |
;; | |
esac; | |
cmdOpts="$cmdOpts --help -h"; | |
for ((i=2; i<=$COMP_CWORD-1; ++i )) | |
do | |
opt=${COMP_WORDS[$i]}; | |
case $opt in | |
--*) | |
optBase=${opt/=*/} | |
;; | |
-*) | |
optBase=${opt:0:2} | |
;; | |
esac; | |
cmdOpts=" $cmdOpts "; | |
cmdOpts=${cmdOpts/ ${optBase} / }; | |
case $optBase in | |
-N) | |
cmdOpts=${cmdOpts/ --non-recursive / } | |
;; | |
--non-recursive) | |
cmdOpts=${cmdOpts/ -N / } | |
;; | |
-h) | |
cmdOpts=${cmdOpts/ --help / } | |
;; | |
--help) | |
cmdOpts=${cmdOpts/ -h / } | |
;; | |
-l) | |
cmdOpts=${cmdOpts/ --limit / } | |
;; | |
--limit) | |
cmdOpts=${cmdOpts/ -l / } | |
;; | |
-r) | |
cmdOpts=${cmdOpts/ --revision / } | |
;; | |
--revision) | |
cmdOpts=${cmdOpts/ -r / } | |
;; | |
-t) | |
cmdOpts=${cmdOpts/ --transaction / } | |
;; | |
--transaction) | |
cmdOpts=${cmdOpts/ -t / } | |
;; | |
-v) | |
cmdOpts=${cmdOpts/ --verbose / } | |
;; | |
--verbose) | |
cmdOpts=${cmdOpts/ -v / } | |
;; | |
-x) | |
cmdOpts=${cmdOpts/ --extensions / } | |
;; | |
--extensions) | |
cmdOpts=${cmdOpts/ -x / } | |
;; | |
esac; | |
if [[ $opt == @($optsParam) ]]; then | |
((++i)); | |
fi; | |
done; | |
COMPREPLY=($( compgen -W "$cmdOpts" -- $cur )); | |
return 0 | |
} | |
_svnsync () | |
{ | |
local cur cmds cmdOpts optsParam opt helpCmds optBase i; | |
COMPREPLY=(); | |
cur=${COMP_WORDS[COMP_CWORD]}; | |
cmds='copy-revprops help info initialize synchronize --version'; | |
if [[ $COMP_CWORD -eq 1 ]]; then | |
COMPREPLY=($( compgen -W "$cmds" -- $cur )); | |
return 0; | |
fi; | |
optsParam="--config-dir|--config-option|--source-username|--source-password"; | |
optsParam="$optsParam|--sync-username|--sync-password"; | |
helpCmds='help|--help|h|\?'; | |
if [[ ${COMP_WORDS[1]} != @($helpCmds) ]] && [[ "$cur" != -* ]] || [[ ${COMP_WORDS[COMP_CWORD-1]} == @($optsParam) ]]; then | |
return 0; | |
fi; | |
cmdOpts=; | |
case ${COMP_WORDS[1]} in | |
copy-revprops | initialize | init | synchronize | sync) | |
cmdOpts="--non-interactive --no-auth-cache --trust-server-cert --source-username --source-password --sync-username --sync-password --config-dir --config-option -q --quiet" | |
;; | |
help | h | \?) | |
cmdOpts="$cmds" | |
;; | |
info) | |
cmdOpts="--non-interactive --no-auth-cache --trust-server-cert --source-username --source-password --sync-username --sync-password --config-dir --config-option" | |
;; | |
*) | |
;; | |
esac; | |
cmdOpts="$cmdOpts --help -h"; | |
for ((i=2; i<=$COMP_CWORD-1; ++i )) | |
do | |
opt=${COMP_WORDS[$i]}; | |
case $opt in | |
--*) | |
optBase=${opt/=*/} | |
;; | |
-*) | |
optBase=${opt:0:2} | |
;; | |
esac; | |
cmdOpts=" $cmdOpts "; | |
cmdOpts=${cmdOpts/ ${optBase} / }; | |
case $optBase in | |
-h) | |
cmdOpts=${cmdOpts/ --help / } | |
;; | |
--help) | |
cmdOpts=${cmdOpts/ -h / } | |
;; | |
-q) | |
cmdOpts=${cmdOpts/ --quiet / } | |
;; | |
--quiet) | |
cmdOpts=${cmdOpts/ -q / } | |
;; | |
esac; | |
if [[ $opt == @($optsParam) ]]; then | |
((++i)); | |
fi; | |
done; | |
COMPREPLY=($( compgen -W "$cmdOpts" -- $cur )); | |
return 0 | |
} | |
_sysvdirs () | |
{ | |
sysvdirs=(); | |
[[ -d /etc/rc.d/init.d ]] && sysvdirs+=(/etc/rc.d/init.d); | |
[[ -d /etc/init.d ]] && sysvdirs+=(/etc/init.d); | |
[[ -f /etc/slackware-version ]] && sysvdirs=(/etc/rc.d) | |
} | |
_terms () | |
{ | |
COMPREPLY+=($( compgen -W "$( sed -ne 's/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap 2>/dev/null )" -- "$cur" )); | |
COMPREPLY+=($( compgen -W "$( { toe -a 2>/dev/null || toe 2>/dev/null; } | awk '{ print $1 }' | sort -u )" -- "$cur" )) | |
} | |
_tilde () | |
{ | |
local result=0; | |
if [[ $1 == \~* && $1 != */* ]]; then | |
COMPREPLY=($( compgen -P '~' -u "${1#\~}" )); | |
result=${#COMPREPLY[@]}; | |
[[ $result -gt 0 ]] && compopt -o filenames 2> /dev/null; | |
fi; | |
return $result | |
} | |
_uids () | |
{ | |
if type getent &>/dev/null; then | |
COMPREPLY=($( compgen -W '$( getent passwd | cut -d: -f3 )' -- "$cur" )); | |
else | |
if type perl &>/dev/null; then | |
COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"' )' -- "$cur" )); | |
else | |
COMPREPLY=($( compgen -W '$( cut -d: -f3 /etc/passwd )' -- "$cur" )); | |
fi; | |
fi | |
} | |
_update_initramfs () | |
{ | |
local cur prev valid_options; | |
cur=$(_get_cword); | |
prev=${COMP_WORDS[COMP_CWORD-1]}; | |
if [[ "$prev" == '-k' ]]; then | |
_kernel_versions; | |
COMPREPLY=($( compgen -W '${COMPREPLY[@]} all' -- "$cur" )); | |
return; | |
fi; | |
valid_options=$( update-initramfs -h 2>&1 | sed -e '/^ -/!d;s/^ \(-\w\+\).*/\1/' ); | |
COMPREPLY=($( compgen -W "$valid_options" -- $cur )) | |
} | |
_upvar () | |
{ | |
if unset -v "$1"; then | |
if (( $# == 2 )); then | |
eval $1=\"\$2\"; | |
else | |
eval $1=\(\"\${@:2}\"\); | |
fi; | |
fi | |
} | |
_upvars () | |
{ | |
if ! (( $# )); then | |
echo "${FUNCNAME[0]}: usage: ${FUNCNAME[0]} [-v varname" "value] | [-aN varname [value ...]] ..." 1>&2; | |
return 2; | |
fi; | |
while (( $# )); do | |
case $1 in | |
-a*) | |
[[ -n ${1#-a} ]] || { | |
echo "bash: ${FUNCNAME[0]}: \`$1': missing" "number specifier" 1>&2; | |
return 1 | |
}; | |
printf %d "${1#-a}" &>/dev/null || { | |
echo "bash:" "${FUNCNAME[0]}: \`$1': invalid number specifier" 1>&2; | |
return 1 | |
}; | |
[[ -n "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) && shift $((${1#-a} + 2)) || { | |
echo "bash: ${FUNCNAME[0]}:" "\`$1${2+ }$2': missing argument(s)" 1>&2; | |
return 1 | |
} | |
;; | |
-v) | |
[[ -n "$2" ]] && unset -v "$2" && eval $2=\"\$3\" && shift 3 || { | |
echo "bash: ${FUNCNAME[0]}: $1: missing" "argument(s)" 1>&2; | |
return 1 | |
} | |
;; | |
*) | |
echo "bash: ${FUNCNAME[0]}: $1: invalid option" 1>&2; | |
return 1 | |
;; | |
esac; | |
done | |
} | |
_usb_ids () | |
{ | |
COMPREPLY+=($( compgen -W "$( PATH="$PATH:/sbin" lsusb | awk '{print $6}' )" -- "$cur" )) | |
} | |
_user_at_host () | |
{ | |
local cur prev words cword; | |
_init_completion -n : || return; | |
if [[ $cur == *@* ]]; then | |
_known_hosts_real "$cur"; | |
else | |
COMPREPLY=($( compgen -u -- "$cur" )); | |
fi; | |
return 0 | |
} | |
_usergroup () | |
{ | |
if [[ $cur = *\\\\* || $cur = *:*:* ]]; then | |
return; | |
else | |
if [[ $cur = *\\:* ]]; then | |
local prefix; | |
prefix=${cur%%*([^:])}; | |
prefix=${prefix//\\}; | |
local mycur="${cur#*[:]}"; | |
if [[ $1 == -u ]]; then | |
_allowed_groups "$mycur"; | |
else | |
local IFS=' | |
'; | |
COMPREPLY=($( compgen -g -- "$mycur" )); | |
fi; | |
COMPREPLY=($( compgen -P "$prefix" -W "${COMPREPLY[@]}" )); | |
else | |
if [[ $cur = *:* ]]; then | |
local mycur="${cur#*:}"; | |
if [[ $1 == -u ]]; then | |
_allowed_groups "$mycur"; | |
else | |
local IFS=' | |
'; | |
COMPREPLY=($( compgen -g -- "$mycur" )); | |
fi; | |
else | |
if [[ $1 == -u ]]; then | |
_allowed_users "$cur"; | |
else | |
local IFS=' | |
'; | |
COMPREPLY=($( compgen -u -- "$cur" )); | |
fi; | |
fi; | |
fi; | |
fi | |
} | |
_userland () | |
{ | |
local userland=$( uname -s ); | |
[[ $userland == @(Linux|GNU/*) ]] && userland=GNU; | |
[[ $userland == $1 ]] | |
} | |
_variables () | |
{ | |
if [[ $cur =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]; then | |
[[ $cur == *{* ]] && local suffix=} || local suffix=; | |
COMPREPLY+=($( compgen -P ${BASH_REMATCH[1]} -S "$suffix" -v -- "${BASH_REMATCH[2]}" )); | |
return 0; | |
fi; | |
return 1 | |
} | |
_xfunc () | |
{ | |
set -- "$@"; | |
local srcfile=$1; | |
shift; | |
declare -F $1 &>/dev/null || { | |
local compdir=./completions; | |
[[ $BASH_SOURCE == */* ]] && compdir="${BASH_SOURCE%/*}/completions"; | |
. "$compdir/$srcfile" | |
}; | |
"$@" | |
} | |
_xinetd_services () | |
{ | |
local xinetddir=/etc/xinetd.d; | |
if [[ -d $xinetddir ]]; then | |
local restore_nullglob=$(shopt -p nullglob); | |
shopt -s nullglob; | |
local -a svcs=($( printf '%s\n' $xinetddir/!($_backup_glob) )); | |
$restore_nullglob; | |
COMPREPLY+=($( compgen -W '${svcs[@]#$xinetddir/}' -- "$cur" )); | |
fi | |
} | |
dequote () | |
{ | |
eval printf %s "$1" 2> /dev/null | |
} | |
quote () | |
{ | |
local quoted=${1//\'/\'\\\'\'}; | |
printf "'%s'" "$quoted" | |
} | |
quote_readline () | |
{ | |
local quoted; | |
_quote_readline_by_ref "$1" ret; | |
printf %s "$ret" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment