cdgit: cd relative to git workdir root

Thomas Koch thomas at
Tue Sep 17 21:44:48 CEST 2013

On Monday, September 16, 2013 11:36:46 PM Adam Spiers wrote:

Thank you! How about this for gitcd:


git rev-parse --show-toplevel | read root

[ $? -eq 0 ] || return $?
cd "$root/$1"

Unfortunately the auto completion does not seem to work for me. It just 
completes the files of the current dir as if it would not see the _gitcd file.

I use the zsh config of grml which automatically autoloads all executable files 
in fpath and I set my fpath to~/.config/zsh/zfunc :

# Where to look for autoloaded function definitions
fpath=( ~/.config/zsh/zfunc "${fpath[@]}" )

# Autoload all shell functions from all directories in $fpath (following
# symlinks) that have the executable bit on (the executable bit is not
# necessary, but gives you an easy way to stop the autoloading of a
# particular shell function). $fpath should not be empty for this to work.
for func in $^fpath/*(N-.x:t); autoload $func

I removed ~/.zcompdump several times but it never contains an entry for gitcd.

Regards, Thomas Koch

More information about the vcs-home mailing list