##// END OF EJS Templates
add http_proxy= lines to test-bad-pull and test-pull
add http_proxy= lines to test-bad-pull and test-pull

File last commit:

r1888:283d2ab1 default
r1927:397b62d5 default
Show More
bash_completion
207 lines | 3.9 KiB | application/x-sh | BashLexer
TK Soh
bash_completion: extended patterns require extglob option
r1311 shopt -s extglob
Alexis S. L. Carvalho
bash_completion: be more careful about whitespaces...
r1641 _hg_command_list()
{
Thomas Arendsen Hein
Use user specified path to hg in bash_completion...
r1683 "$hg" --debug help 2>/dev/null | \
Alexis S. L. Carvalho
bash_completion: be more careful about whitespaces...
r1641 awk 'function command_line(line) {
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 gsub(/,/, "", line)
gsub(/:.*/, "", line)
split(line, aliases)
command = aliases[1]
delete aliases[1]
print command
for (i in aliases)
if (index(command, aliases[i]) != 1)
print aliases[i]
}
/^list of commands:/ {commands=1}
commands && /^ debug/ {a[i++] = $0; next;}
commands && /^ [^ ]/ {command_line($0)}
/^global options:/ {exit 0}
END {for (i in a) command_line(a[i])}'
Alexis S. L. Carvalho
bash_completion: be more careful about whitespaces...
r1641
}
_hg_option_list()
{
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 "$hg" -v help $1 2>/dev/null | \
awk '/^ *-/ {
for (i = 1; i <= NF; i ++) {
Alexis S. L. Carvalho
bash_completion: be more careful about whitespaces...
r1641 if (index($i, "-") != 1)
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 break;
Alexis S. L. Carvalho
bash_completion: be more careful about whitespaces...
r1641 print $i;
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 }
}'
Alexis S. L. Carvalho
bash_completion: be more careful about whitespaces...
r1641 }
mpm@selenic.com
Add bash_completion to contrib...
r916 _hg_commands()
{
Alexis S. L. Carvalho
bash_completion: use hg --debug help to get the list of debug commands....
r1555 local all commands result
Alexis S. L. Carvalho
bash_completion: be more careful about whitespaces...
r1641 all=$(_hg_command_list)
commands=${all%%$'\n'debug*}
Alexis S. L. Carvalho
bash_completion: always use single quotes with compgen -W...
r1642 result=$(compgen -W '$commands' -- "$cur")
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308
# hide debug commands from users, but complete them if
Alexis S. L. Carvalho
bash_completion: use hg --debug help to get the list of debug commands....
r1555 # there is no other possible command
if [ "$result" = "" ]; then
local debug
Alexis S. L. Carvalho
bash_completion: be more careful about whitespaces...
r1641 debug=debug${all#*$'\n'debug}
Alexis S. L. Carvalho
bash_completion: always use single quotes with compgen -W...
r1642 result=$(compgen -W '$debug' -- "$cur")
mpm@selenic.com
Add bash_completion to contrib...
r916 fi
Alexis S. L. Carvalho
bash_completion: use hg --debug help to get the list of debug commands....
r1555
COMPREPLY=(${COMPREPLY[@]:-} $result)
mpm@selenic.com
Add bash_completion to contrib...
r916 }
_hg_paths()
{
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 local paths="$("$hg" paths 2>/dev/null | sed -e 's/ = .*$//')"
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur"))
mpm@selenic.com
Add bash_completion to contrib...
r916 }
Daniel Kobras
Less annoying directory completion (see http://bugs.debian.org/343458)...
r1587 _hg_repos()
{
local i
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 for i in $(compgen -d -- "$cur"); do
test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i")
Daniel Kobras
Less annoying directory completion (see http://bugs.debian.org/343458)...
r1587 done
}
mpm@selenic.com
bash: Add smarter completion of add/commit/remove/forget/diff/revert...
r935 _hg_status()
{
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 local files="$("$hg" status -n$1 . 2>/dev/null)"
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
mpm@selenic.com
bash: Add smarter completion of add/commit/remove/forget/diff/revert...
r935 }
mpm@selenic.com
Add bash_completion to contrib...
r916 _hg_tags()
{
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 local tags="$("$hg" tags 2>/dev/null |
sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')"
COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur"))
mpm@selenic.com
Add bash_completion to contrib...
r916 }
# this is "kind of" ugly...
_hg_count_non_option()
{
local i count=0
local filters="$1"
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 for ((i=1; $i<=$COMP_CWORD; i++)); do
mpm@selenic.com
Add bash_completion to contrib...
r916 if [[ "${COMP_WORDS[i]}" != -* ]]; then
Alexis S. L. Carvalho
bash_completion: small cleanup and bugfix...
r1152 if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then
continue
fi
mpm@selenic.com
Add bash_completion to contrib...
r916 count=$(($count + 1))
fi
done
echo $(($count - 1))
}
_hg()
{
local cur prev cmd opts i
Alexis S. L. Carvalho
teach bash_completion about --cwd
r1151 # global options that receive an argument
local global_args='--cwd|-R|--repository'
Thomas Arendsen Hein
Use user specified path to hg in bash_completion...
r1683 local hg="$1"
mpm@selenic.com
Add bash_completion to contrib...
r916
COMPREPLY=()
cur="$2"
prev="$3"
Thomas Arendsen Hein
Cleanup of tabs and trailing spaces.
r1308 # searching for the command
Alexis S. L. Carvalho
teach bash_completion about --cwd
r1151 # (first non-option argument that doesn't follow a global option that
# receives an argument)
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 for ((i=1; $i<=$COMP_CWORD; i++)); do
Alexis S. L. Carvalho
teach bash_completion about --cwd
r1151 if [[ ${COMP_WORDS[i]} != -* ]]; then
if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
cmd="${COMP_WORDS[i]}"
break
fi
mpm@selenic.com
Add bash_completion to contrib...
r916 fi
done
if [[ "$cur" == -* ]]; then
Alexis S. L. Carvalho
bash_completion: be more careful about whitespaces...
r1641 opts=$(_hg_option_list $cmd)
mpm@selenic.com
Add bash_completion to contrib...
r916
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
mpm@selenic.com
Add bash_completion to contrib...
r916 return
fi
Alexis S. L. Carvalho
teach bash_completion about --cwd
r1151 # global options
case "$prev" in
-R|--repository)
Daniel Kobras
Less annoying directory completion (see http://bugs.debian.org/343458)...
r1587 _hg_repos
Alexis S. L. Carvalho
teach bash_completion about --cwd
r1151 return
;;
--cwd)
Daniel Kobras
Less annoying directory completion (see http://bugs.debian.org/343458)...
r1587 # Stick with default bash completion
Alexis S. L. Carvalho
teach bash_completion about --cwd
r1151 return
;;
esac
mpm@selenic.com
Add bash_completion to contrib...
r916
if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then
_hg_commands
return
fi
Alexis S. L. Carvalho
bash_completion: better handling of aliases...
r1150 # canonicalize command name
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 cmd=$("$hg" -q help "$cmd" 2>/dev/null | sed -e 's/^hg //; s/ .*//; 1q')
Alexis S. L. Carvalho
bash_completion: better handling of aliases...
r1150
mpm@selenic.com
Add bash_completion to contrib...
r916 if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" = --rev ]; then
_hg_tags
return
fi
case "$cmd" in
help)
_hg_commands
;;
Alexis S. L. Carvalho
bash_completion: better handling of aliases...
r1150 export|manifest|update)
mpm@selenic.com
Add bash_completion to contrib...
r916 _hg_tags
;;
Alexis S. L. Carvalho
bash_completion: better handling of aliases...
r1150 pull|push|outgoing|incoming)
mpm@selenic.com
Add bash_completion to contrib...
r916 _hg_paths
Daniel Kobras
Less annoying directory completion (see http://bugs.debian.org/343458)...
r1587 _hg_repos
mpm@selenic.com
Add bash_completion to contrib...
r916 ;;
paths)
_hg_paths
;;
mpm@selenic.com
bash: Add smarter completion of add/commit/remove/forget/diff/revert...
r935 add)
_hg_status "u"
;;
Alexis S. L. Carvalho
bash_completion: better handling of aliases...
r1150 commit)
Thomas Arendsen Hein
_hg_status improvements in bash_completion:...
r1639 _hg_status "mar"
mpm@selenic.com
bash: Add smarter completion of add/commit/remove/forget/diff/revert...
r935 ;;
remove)
Thomas Arendsen Hein
_hg_status improvements in bash_completion:...
r1639 _hg_status "d"
mpm@selenic.com
bash: Add smarter completion of add/commit/remove/forget/diff/revert...
r935 ;;
forget)
_hg_status "a"
;;
diff)
Thomas Arendsen Hein
_hg_status improvements in bash_completion:...
r1639 _hg_status "mar"
mpm@selenic.com
bash: Add smarter completion of add/commit/remove/forget/diff/revert...
r935 ;;
revert)
Thomas Arendsen Hein
_hg_status improvements in bash_completion:...
r1639 _hg_status "mard"
mpm@selenic.com
bash: Add smarter completion of add/commit/remove/forget/diff/revert...
r935 ;;
mpm@selenic.com
Add bash_completion to contrib...
r916 clone)
local count=$(_hg_count_non_option)
if [ $count = 1 ]; then
_hg_paths
fi
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 _hg_repos
mpm@selenic.com
Add bash_completion to contrib...
r916 ;;
mpm@selenic.com
bash_completion: add debugindex and debugdata support
r1115 debugindex|debugindexdot)
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur"))
mpm@selenic.com
bash_completion: add debugindex and debugdata support
r1115 ;;
debugdata)
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur"))
mpm@selenic.com
bash_completion: add debugindex and debugdata support
r1115 ;;
mpm@selenic.com
Add bash_completion to contrib...
r916 esac
}
Thomas Arendsen Hein
Cleanup of spacing in bash_completion
r1684 complete -o bashdefault -o default -F _hg hg 2>/dev/null \
Alexis S. L. Carvalho
bash_completion: try to use bash3 features if they're available...
r1153 || complete -o default -F _hg hg