| OLD | NEW |
| (Empty) |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 # Source this file into your shell to gain the cr function and tab completion | |
| 6 # for it | |
| 7 | |
| 8 cr_base_dir=$(dirname $(realpath "${BASH_SOURCE:-$0}")) | |
| 9 cr_main="${cr_base_dir}/main.py" | |
| 10 cr_exec="PYTHONDONTWRITEBYTECODE=1 python ${cr_main}" | |
| 11 | |
| 12 # The main entry point to the cr tool. | |
| 13 # Invokes the python script with pyc files turned off. | |
| 14 function cr() { | |
| 15 env $cr_exec "$@" | |
| 16 } | |
| 17 | |
| 18 # Attempts to cd to the root/src of the current client. | |
| 19 function crcd() { | |
| 20 cd $(cr info -s CR_SRC) | |
| 21 } | |
| 22 | |
| 23 # Add to your PS1 to have the current selected output directory in your prompt | |
| 24 function _cr_ps1() { | |
| 25 cr info -s CR_OUT_FULL | |
| 26 } | |
| 27 | |
| 28 # The tab completion handler, delegates into the python script. | |
| 29 function _cr_complete() { | |
| 30 COMPREPLY=() | |
| 31 local cur="${COMP_WORDS[COMP_CWORD]}" | |
| 32 local main="python -B "${cr_main}")" | |
| 33 local completions="$(env COMP_CWORD=${COMP_CWORD} COMP_WORD=${cur} $cr_exec)" | |
| 34 COMPREPLY=( $(compgen -W "${completions}" -- ${cur}) ) | |
| 35 } | |
| 36 | |
| 37 # Setup the bash auto complete | |
| 38 complete -F _cr_complete cr | |
| OLD | NEW |