From a7c72adb2ebec1e497fc040eaf3551d564d61a5b Mon Sep 17 00:00:00 2001 From: William Carroll Date: Tue, 14 May 2019 17:00:28 +0100 Subject: 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. --- configs/shared/zsh/functions.zsh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'configs/shared/zsh/functions.zsh') diff --git a/configs/shared/zsh/functions.zsh b/configs/shared/zsh/functions.zsh index 4eede030466c..9a02b1b947c8 100644 --- a/configs/shared/zsh/functions.zsh +++ b/configs/shared/zsh/functions.zsh @@ -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. -- cgit 1.4.1