contrib/bash_completion
author Thomas Arendsen Hein <thomas@intevation.de>
Sun, 12 Mar 2006 12:29:03 +0100
changeset 1888 283d2ab1e020
parent 1887 913397c27cd8
child 2034 5e7aff1b6ae1
permissions -rw-r--r--
Make bash_completion more robust for e.g. broken hgrc or old hg installations.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1311
db8bebb08f8f bash_completion: extended patterns require extglob option
TK Soh <teekaysoh@yahoo.com>
parents: 1308
diff changeset
     1
shopt -s extglob
db8bebb08f8f bash_completion: extended patterns require extglob option
TK Soh <teekaysoh@yahoo.com>
parents: 1308
diff changeset
     2
1641
1ef060ae7966 bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1639
diff changeset
     3
_hg_option_list()
1ef060ae7966 bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1639
diff changeset
     4
{
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
     5
    "$hg" -v help $1 2>/dev/null | \
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
     6
	awk '/^ *-/ {
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
     7
		for (i = 1; i <= NF; i ++) {
1641
1ef060ae7966 bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1639
diff changeset
     8
		    if (index($i, "-") != 1)
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
     9
			break;
1641
1ef060ae7966 bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1639
diff changeset
    10
		    print $i;
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    11
		}
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    12
	    }'
1641
1ef060ae7966 bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1639
diff changeset
    13
}
1ef060ae7966 bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1639
diff changeset
    14
1ef060ae7966 bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1639
diff changeset
    15
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    16
_hg_commands()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    17
{
1888
283d2ab1e020 Make bash_completion more robust for e.g. broken hgrc or old hg installations.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1887
diff changeset
    18
    local commands
283d2ab1e020 Make bash_completion more robust for e.g. broken hgrc or old hg installations.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1887
diff changeset
    19
    commands="$("$hg" debugcomplete "$cur" 2>/dev/null)" || commands=""
1887
913397c27cd8 new command debugcomplete
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents: 1820
diff changeset
    20
    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$commands' -- "$cur"))
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    21
}
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    22
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    23
_hg_paths()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    24
{
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    25
    local paths="$("$hg" paths 2>/dev/null | sed -e 's/ = .*$//')"
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    26
    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur"))
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    27
}
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    28
1587
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
    29
_hg_repos()
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
    30
{
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
    31
    local i
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    32
    for i in $(compgen -d -- "$cur"); do
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    33
	test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i")
1587
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
    34
    done
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
    35
}
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
    36
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
    37
_hg_status()
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
    38
{
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    39
    local files="$("$hg" status -n$1 . 2>/dev/null)"
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    40
    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
    41
}
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
    42
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    43
_hg_tags()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    44
{
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    45
    local tags="$("$hg" tags 2>/dev/null |
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    46
	sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')"
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    47
    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur"))
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    48
}
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    49
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    50
# this is "kind of" ugly...
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    51
_hg_count_non_option()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    52
{
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    53
    local i count=0
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    54
    local filters="$1"
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    55
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    56
    for ((i=1; $i<=$COMP_CWORD; i++)); do
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    57
	if [[ "${COMP_WORDS[i]}" != -* ]]; then
1152
ff560ce0c635 bash_completion: small cleanup and bugfix
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1151
diff changeset
    58
	    if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then
ff560ce0c635 bash_completion: small cleanup and bugfix
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1151
diff changeset
    59
		continue
ff560ce0c635 bash_completion: small cleanup and bugfix
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1151
diff changeset
    60
	    fi
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    61
	    count=$(($count + 1))
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    62
	fi
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    63
    done
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    64
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    65
    echo $(($count - 1))
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    66
}
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    67
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    68
_hg()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    69
{
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    70
    local cur prev cmd opts i
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    71
    # global options that receive an argument
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    72
    local global_args='--cwd|-R|--repository'
1683
063e04831a09 Use user specified path to hg in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1643
diff changeset
    73
    local hg="$1"
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    74
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    75
    COMPREPLY=()
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    76
    cur="$2"
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    77
    prev="$3"
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    78
1308
2073e5a71008 Cleanup of tabs and trailing spaces.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1263
diff changeset
    79
    # searching for the command
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    80
    # (first non-option argument that doesn't follow a global option that
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    81
    #  receives an argument)
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    82
    for ((i=1; $i<=$COMP_CWORD; i++)); do
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    83
	if [[ ${COMP_WORDS[i]} != -* ]]; then
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    84
	    if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    85
		cmd="${COMP_WORDS[i]}"
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    86
		break
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    87
	    fi
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    88
	fi
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    89
    done
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    90
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    91
    if [[ "$cur" == -* ]]; then
1641
1ef060ae7966 bash_completion: be more careful about whitespaces
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1639
diff changeset
    92
	opts=$(_hg_option_list $cmd)
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    93
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
    94
	COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    95
	return
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    96
    fi
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
    97
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    98
    # global options
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
    99
    case "$prev" in
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
   100
	-R|--repository)
1587
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
   101
	    _hg_repos
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
   102
	    return
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
   103
	;;
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
   104
	--cwd)
1587
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
   105
	    # Stick with default bash completion
1151
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
   106
	    return
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
   107
	;;
10b4f2a5ce17 teach bash_completion about --cwd
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1150
diff changeset
   108
    esac
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   109
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   110
    if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   111
	_hg_commands
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   112
	return
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   113
    fi
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   114
1150
4ee09418c8e5 bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1149
diff changeset
   115
    # canonicalize command name
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
   116
    cmd=$("$hg" -q help "$cmd" 2>/dev/null | sed -e 's/^hg //; s/ .*//; 1q')
1150
4ee09418c8e5 bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1149
diff changeset
   117
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   118
    if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" = --rev ]; then
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   119
	_hg_tags
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   120
	return
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   121
    fi
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   122
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   123
    case "$cmd" in
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   124
	help)
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   125
	    _hg_commands
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   126
	;;
1150
4ee09418c8e5 bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1149
diff changeset
   127
	export|manifest|update)
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   128
	    _hg_tags
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   129
	;;
1150
4ee09418c8e5 bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1149
diff changeset
   130
	pull|push|outgoing|incoming)
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   131
	    _hg_paths
1587
851bc33ff545 Less annoying directory completion (see http://bugs.debian.org/343458)
Daniel Kobras <kobras@debian.org>
parents: 1556
diff changeset
   132
	    _hg_repos
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   133
	;;
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   134
	paths)
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   135
	    _hg_paths
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   136
	;;
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   137
	add)
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   138
	    _hg_status "u"
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   139
	;;
1150
4ee09418c8e5 bash_completion: better handling of aliases
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1149
diff changeset
   140
	commit)
1639
dbfc04a55607 _hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1638
diff changeset
   141
	    _hg_status "mar"
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   142
	;;
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   143
	remove)
1639
dbfc04a55607 _hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1638
diff changeset
   144
	    _hg_status "d"
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   145
	;;
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   146
	forget)
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   147
	    _hg_status "a"
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   148
	;;
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   149
	diff)
1639
dbfc04a55607 _hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1638
diff changeset
   150
	    _hg_status "mar"
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   151
	;;
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   152
	revert)
1639
dbfc04a55607 _hg_status improvements in bash_completion:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1638
diff changeset
   153
	    _hg_status "mard"
935
925563ff1b18 bash: Add smarter completion of add/commit/remove/forget/diff/revert
mpm@selenic.com
parents: 929
diff changeset
   154
	;;
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   155
	clone)
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   156
	    local count=$(_hg_count_non_option)
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   157
	    if [ $count = 1 ]; then
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   158
		_hg_paths
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   159
	    fi
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
   160
	    _hg_repos
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   161
	;;
1115
89f54e72581d bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents: 1018
diff changeset
   162
	debugindex|debugindexdot)
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
   163
	    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur"))
1115
89f54e72581d bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents: 1018
diff changeset
   164
	;;
89f54e72581d bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents: 1018
diff changeset
   165
	debugdata)
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
   166
	    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur"))
1115
89f54e72581d bash_completion: add debugindex and debugdata support
mpm@selenic.com
parents: 1018
diff changeset
   167
	;;
916
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   168
    esac
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   169
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   170
}
fe094cca9915 Add bash_completion to contrib
mpm@selenic.com
parents:
diff changeset
   171
1684
cf930b2452d3 Cleanup of spacing in bash_completion
Thomas Arendsen Hein <thomas@intevation.de>
parents: 1683
diff changeset
   172
complete -o bashdefault -o default -F _hg hg 2>/dev/null \
1153
fa9ae7df88a9 bash_completion: try to use bash3 features if they're available
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents: 1152
diff changeset
   173
    || complete -o default -F _hg hg