Support functions for navigating Google3

I had `tbz`, which toggles between a project directory and it's associated
blaze-bin.

I added three functions which support navigating to blaze-bin, blaze-genfiles,
and to the project root.
This commit is contained in:
William Carroll 2019-05-14 17:00:28 +01:00
parent 01b985fdd9
commit a7c72adb2e

View file

@ -42,6 +42,29 @@ fv() {
[[ -n "$file" ]] && vim "$file"
}
project_root() {
# Changes to the directory of the project root.
if [[ "$(pwd)" =~ '(.*)/blaze-bin(.*)' ]]; then
cd "${match[1]}${match[2]}"
elif [[ "$(pwd)" =~ '(.*)/blaze-genfiles(.*)' ]]; then
cd "${match[1]}${match[2]}"
fi
}
blaze_bin() {
# Changes to the blaze-bin directory.
# Depends:
# - project_root
project_root && cd "${PWD/\/google3//google3/blaze-bin}"
}
blaze_genfiles() {
# Changes to the blaze-genfiles directory.
# Depends:
# - project_root
project_root && cd "${PWD/\/google3//google3/blaze-genfiles}"
}
tbz() {
# Toggle between blaze-bin and your source.
# Useful if you like to cd into the dir where your source lives.