[fx][zsh-completion] support $FUCHSIA_DIR
The `fx` command now looks at $FUCHSIA_DIR to find your Fuchsia dir
before looking through CWD's parents. This updates Zsh completion to
match that behavior.
Change-Id: Ib3f49cf2ee97012117a01309d388c548b1933325
diff --git a/zsh-completion/_fx b/zsh-completion/_fx
index ffdc4ba..74aaf44 100644
--- a/zsh-completion/_fx
+++ b/zsh-completion/_fx
@@ -9,15 +9,17 @@
_fx() {
typeset -A opt_args
- local fuchsia_dir
- fuchsia_dir="$(pwd)"
- while [[ ! -d "${fuchsia_dir}/.jiri_root" ]]; do
- fuchsia_dir="$(dirname "${fuchsia_dir}")"
- if [[ "${fuchsia_dir}" == "/" ]]; then
- _message -r "Cannot find Fuchsia source tree containing $(pwd)"
- return
- fi
- done
+ local fuchsia_dir="${FUCHSIA_DIR}"
+ if [[ -z "${fuchsia_dir}" ]]; then
+ fuchsia_dir="$(pwd)"
+ while [[ ! -d "${fuchsia_dir}/.jiri_root" ]]; do
+ fuchsia_dir="$(dirname "${fuchsia_dir}")"
+ if [[ "${fuchsia_dir}" == "/" ]]; then
+ _message -r "Cannot find Fuchsia source tree containing $(pwd)"
+ return
+ fi
+ done
+ fi
# list of commands based on //scripts/devshell/
# each file is read to find the description line (starts with "### ").