diff options
author | William Carroll <wpcarro@gmail.com> | 2019-02-27T17·47+0000 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2019-02-28T12·24+0000 |
commit | dba7ac236500f49b03c83ef9b8de16b114e9ab85 (patch) | |
tree | 616e05e7f6cf053f40e1f9943cd7f081e24459a4 /configs/shared/zsh/functions.zsh | |
parent | f4c53982c70927a23276405c4bc9c02b1a59fa4c (diff) |
More fully support zsh
Support zshrc, variables, aliases, functions TODO: incorporate dumping_grounds.zsh into functions.
Diffstat (limited to 'configs/shared/zsh/functions.zsh')
-rw-r--r-- | configs/shared/zsh/functions.zsh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/configs/shared/zsh/functions.zsh b/configs/shared/zsh/functions.zsh new file mode 100644 index 000000000000..b328f5c4a59d --- /dev/null +++ b/configs/shared/zsh/functions.zsh @@ -0,0 +1,36 @@ +# From Google's ZSH Hacks + +# Improvement to fasd's existing `zz` alias +unalias zz +function zz() { + # TODO: Add documentation + local dir + dir="$(fasd -Rdl "$1" | fzf --query="$1" -1 -0 --no-sort +m)" && cd "${dir}" || return 1 +} + +function fv() { + # Usage: fv file pattern + # This is useful when you know the fuzzy name of the file you want to edit + local file + file="$(fzf --exact --height 40% --reverse --query="$1" --select-1 --exit-0)" + [[ -n "$file" ]] && vim "$file" +} + +function bb() { + # Toggle between blaze-bin and your source. + # Useful if you like to cd into the dir where your source lives. + if [[ $PWD =~ '(.*)/blaze-bin(.*)' ]]; then + cd "${match[1]}${match[2]}" + else + cd "${PWD/\/google3//google3/blaze-bin}" + fi +} + +function jt() { + # Toggle between the source dir and test dir. + if [[ $PWD =~ '(.*)/javatests(.*)' ]]; then + cd "${match[1]}/java${match[2]}" + else + cd "${PWD/\/google3\/java//google3/javatests}" + fi +} |