Files
dotfiles/zsh/g3path.zsh
Christian Nieves 38d06bc325 stuff
2022-12-11 01:39:57 +00:00

23 lines
637 B
Bash

g3path::hook () {
if [[ $PWD =~ (^.*/([^/]+)/google3)($|/.*) ]]; then
export GOOGLE3_ROOT="${match[1]}"
export GOOGLE3_CLIENT="${match[2]}"
export GOOGLE3_PATH="${match[3]:-/}"
else
unset GOOGLE3_ROOT GOOGLE3_CLIENT GOOGLE3_PATH
fi
}
g3path::hook
autoload -Uz add-zsh-hook
add-zsh-hook chpwd g3path::hook
g3path::zle::accept-line () {
if [[ -n $GOOGLE3_ROOT && ! $BUFFER =~ \\s*(blaze|g4|p4|g4d|add_dep|buildozer|build_cleaner|debug_android_lint|rabbit|hb|gqui|builddoctor|unused_deps) ]]; then
BUFFER=${BUFFER// \/\// $GOOGLE3_ROOT\/}
fi
zle .accept-line
}
zle -N accept-line g3path::zle::accept-line