From e13736091cadeaddcecf79cb611caea7992bf35a Mon Sep 17 00:00:00 2001 From: Pavel Puchkin Date: Fri, 22 Jun 2012 21:00:40 +1100 Subject: [PATCH] Add `toroot` function to fast changing workdir to repo's root If we are not in repo, just call `cd` with no arguments (which in most cases move us to home dir). Maybe will be better to do nothing otherwise? --- plugins/git/git.plugin.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index d3d3f702a..8b53147f8 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -60,6 +60,11 @@ function current_repository() { echo $(git remote -v | cut -d':' -f 2) } +# change workdir to repo's root (or do `cd` with no arguments if not in a repo) +function toroot() { + builtin cd "`git_get_root`" +} + # these aliases take advantage of the previous function alias ggpull='git pull origin $(current_branch)' compdef ggpull=git