Index: tools/cr/cr.sh |
diff --git a/tools/cr/cr.sh b/tools/cr/cr.sh |
new file mode 100644 |
index 0000000000000000000000000000000000000000..27c5ca1eb3fc41198e69aa4fe52ec9cc3a76b1c0 |
--- /dev/null |
+++ b/tools/cr/cr.sh |
@@ -0,0 +1,38 @@ |
+# Copyright (c) 2013 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. |
+ |
+# Source this file into your shell to gain the cr function and tab completion |
+# for it |
+ |
+cr_base_dir=$(dirname $(realpath "${BASH_SOURCE:-$0}")) |
+cr_main="$cr_base_dir/main.py" |
bulach
2013/11/14 16:40:16
perhaps ${cr_base_dir} here and ${cr_main} below?
ian_cottrell
2013/11/15 10:28:51
Done.
|
+cr_exec="PYTHONDONTWRITEBYTECODE=1 python $cr_main" |
+ |
+# The main entry point to the cr tool. |
+# Invokes the python script with pyc files turned off. |
+function cr() { |
+ env $cr_exec "$@" |
+} |
+ |
+# Attempts to cd to the root/src of the current client. |
+function crcd() { |
+ cd `cr info -s CR_SRC` |
bulach
2013/11/14 16:40:16
nit: perhaps $(..) ?
ian_cottrell
2013/11/15 10:28:51
Done.
|
+} |
+ |
+# Add to your PS1 to have the current selected output directory in your prompt |
+function _cr_ps1() { |
+ cr info -s CR_OUT_FULL |
+} |
+ |
+# The tab completion handler, delegates into the python script. |
+function _cr_complete() { |
+ COMPREPLY=() |
+ local cur="${COMP_WORDS[COMP_CWORD]}" |
+ local main="python -B "$cr_main")" |
bulach
2013/11/14 16:40:16
nit: perhaps ${cr_main} as well?
ian_cottrell
2013/11/15 10:28:51
Done.
|
+ local completions="$(env COMP_CWORD=${COMP_CWORD} COMP_WORD=${cur} $cr_exec)" |
+ COMPREPLY=( $(compgen -W "${completions}" -- ${cur}) ) |
+} |
+ |
+# Setup the bash auto complete |
+complete -F _cr_complete cr |