summaryrefslogtreecommitdiffstats
path: root/tools/bash-completion
blob: 19172dab145249adf93b5c622988d937993801e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Flag completion rule for bash.
# To load in your shell, "source path/to/this/file".

chrome_source=$(cd $(dirname $BASH_SOURCE)/.. && pwd)

_chrome_flag() {
    local cur targets
    cur="${COMP_WORDS[COMP_CWORD]}"
    targets=$(cd $chrome_source; \
        git ls-files '*switches*' | \
        xargs sed -ne 's/^[^/]*"\([^" /]\{1,\}\)".*/--\1/p')
    COMPREPLY=($(compgen -W "$targets" -- "$cur"))
    return 0
}

complete -F _chrome_flag google-chrome
complete -F _chrome_flag chrome
if [ $(uname) = "Darwin" ]
then
  complete -F _chrome_flag Chromium
fi