Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Run from either local inclusion or /etc/bash_completions.d | |
|
bradn
2014/01/07 02:04:49
So I don't have "have" on my goobuntu system.
I as
Sheridan Rawlins
2014/01/16 03:48:26
Ok, I realize that installation into /etc/bash_com
| |
| 2 declare -f have >/dev/null && have gclient || return | |
| 3 | |
| 4 __gclient_commands () { | |
| 5 gclient -h | grep -P '(?<= (?:\x1b)\[32m)([\w\d]+)' -o | |
|
bradn
2014/01/07 02:04:49
It looks like these terminal codes can vary depend
Sheridan Rawlins
2014/01/16 01:12:59
Added "update" manually, and used sed instead of g
bradn
2014/01/16 04:48:48
I think so.
| |
| 6 } | |
| 7 | |
| 8 __gclient_compute_all_commands () { | |
| 9 test -n "$__gclient_all_commands" || | |
| 10 __gclient_all_commands=$(__gclient_commands) | |
| 11 } | |
| 12 | |
| 13 # Passthrough to git completion | |
|
bradn
2014/01/07 02:04:49
Huh?
Sheridan Rawlins
2014/01/16 03:48:26
Improved comment - basically just aliased so that
| |
| 14 _gclient_fetch=_git_fetch | |
| 15 | |
| 16 _gclient () { | |
| 17 local cur prev words cword | |
| 18 _get_comp_words_by_ref -n =: cur prev words cword | |
| 19 | |
| 20 local i c=1 command | |
| 21 while [ $c -lt $cword ]; do | |
| 22 i="${words[$c]}" | |
| 23 case "$i" in | |
| 24 -*) : ignore options ;; | |
|
bradn
2014/01/07 02:04:49
This hangs for me when there are flags, should tha
Sheridan Rawlins
2014/01/16 03:48:26
Wow copied from git-completion.bash, but forgot th
| |
| 25 *) command="$i"; break ;; | |
| 26 esac | |
| 27 done | |
| 28 | |
| 29 local completion_func="_gclient_${command//-/_}" | |
| 30 local -f $completion_func >/dev/null && $completion_func && return | |
| 31 | |
| 32 case "$command" in | |
| 33 ""|help) | |
| 34 if [[ "$command" != help || "$cword" -le 2 ]]; then | |
|
bradn
2014/01/07 02:04:49
Maybe a comment explaining this is so gclient help
Sheridan Rawlins
2014/01/16 03:48:26
Done.
| |
| 35 __gclient_compute_all_commands | |
| 36 COMPREPLY=($(compgen -W "$__gclient_all_commands" $cur)) | |
| 37 fi | |
| 38 ;; | |
| 39 *) : just use the default ;; | |
| 40 esac | |
| 41 } && | |
| 42 complete -F _gclient -o default gclient | |
| OLD | NEW |