{"thread":{"id":"34941","subject":"cdgit: cd relative to git workdir root","startedAt":"2013-09-16T19:01:14Z","lastAt":"2013-09-17T05:33:04Z","messageCount":3,"participants":["Thomas Koch","Adam Spiers","martin f krafft"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"227714","messageId":"201309162101.14879.thomas@koch.ro","threadId":"34941","inReplyTo":null,"subject":"cdgit: cd relative to git workdir root","fromName":"Thomas Koch","fromEmail":"thomas-5j3myg3oo4w@public.gmane.org","sentAt":"2013-09-16T19:01:14Z","receivedAt":"2013-09-16T19:01:14Z","isPatch":false,"sender":{"key":"thomas-5j3myg3oo4w@public.gmane.org","avatar":null},"body":"Hi,\n\nI frequently have the need to cd back to the root of the current git workdir \nand created to alias for this:\n\ngit alias root = rev-parse --show-toplevel\n\nshell alias cdgit = cd $(git root)\n\nMaybe somebody likes this.\n\nNow it would be cool, to have an alias to cd into a specific subdir of the git \nworktree and have zsh (or bash) auto completion for this like\n\ngit clone git://git.kernel.org/pub/scm/git/git.git\ncd git/gitweb/static/js/lib (just to be somewhere deep)\ncdgit con<tab>/com<tab> (becomes: cdgit contrib/completion)\n\nSomebody with zsh/bash skills who already did this?\n\nRegards, Thomas Koch\n"},{"id":"227715","messageId":"20130916192510.GA12433@gmail.com","threadId":"34941","inReplyTo":"201309162101.14879.thomas@koch.ro","subject":"Re: cdgit: cd relative to git workdir root","fromName":"Adam Spiers","fromEmail":"git@adamspiers.org","sentAt":"2013-09-16T19:25:10Z","receivedAt":"2013-09-16T19:25:10Z","isPatch":false,"sender":{"key":"git@adamspiers.org","avatar":"https://avatars.githubusercontent.com/u/100738?v=4"},"body":"On Mon, Sep 16, 2013 at 09:01:14PM +0200, Thomas Koch wrote:\n> Hi,\n> \n> I frequently have the need to cd back to the root of the current git workdir \n> and created to alias for this:\n> \n> git alias root = rev-parse --show-toplevel\n> \n> shell alias cdgit = cd $(git root)\n> \n> Maybe somebody likes this.\n\nI do, and I was about to copy it into my own config when I discovered\nthat I'd already done this 4 years ago and totally forgotten about it :)\n\n> Now it would be cool, to have an alias to cd into a specific subdir of the git \n> worktree and have zsh (or bash) auto completion for this like\n> \n> git clone git://git.kernel.org/pub/scm/git/git.git\n> cd git/gitweb/static/js/lib (just to be somewhere deep)\n> cdgit con<tab>/com<tab> (becomes: cdgit contrib/completion)\n> \n> Somebody with zsh/bash skills who already did this?\n\nI hadn't done this before today, but it's easy in zsh:\n\n  https://github.com/aspiers/git-config/commit/89df1d78\n\nOf course, _gitcd needs to be somewhere on your $fpath so it can be\nautoloaded.\n"},{"id":"227724","messageId":"20130917053303.GF5390@fishbowl","threadId":"34941","inReplyTo":"201309162101.14879.thomas-5j3myg3OO4w@public.gmane.org","subject":"Re: cdgit: cd relative to git workdir root","fromName":"martin f krafft","fromEmail":"madduck-jx/+c5dph7vr7s880joybq@public.gmane.org","sentAt":"2013-09-17T05:33:04Z","receivedAt":"2013-09-17T05:33:04Z","isPatch":false,"sender":{"key":"madduck-jx/+c5dph7vr7s880joybq@public.gmane.org","avatar":null},"body":"also sprach Thomas Koch <thomas-5j3myg3OO4w@public.gmane.org> [2013.09.16.2101 +0200]:\n> shell alias cdgit = cd $(git root)\n\nI've tried to make this happen many years ago, but I never finished\nthe ZLE widget that did it. The idea was to bind 'tab' to a function\nthat would replace an occurrence of ~g in $LBUFFER with the output\nof rev-parse--show-toplevel and then delegate to normal tab\nexpansion.\n\nSo now I just have\n\n  hash -d g=$(git rev-parse --show-toplevel)\n\nin a pre-prompt function and get the same effect.\n\n  fishbowl:~/code/salt|develop|debian% ls ~g/debi<tab>\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \n\"i am not in favour of long engagements. they give people the\n opportunity of finding out each other's character before marriage,\n which i think is never advisable.\"\n                                                        -- oscar wilde\n \nspamtraps: madduck.bogus-JX/+c5DPh7vR7s880joybQ@public.gmane.org\n\n\n"}]}