rtomayko / git-sh

A customized bash environment suitable for git work.
GNU General Public License v2.0
737 stars 83 forks source link

Feature: Make 'cd ~' go to project root directory #20

Open ls12styler opened 12 years ago

ls12styler commented 12 years ago

As this integrates into the users shell, I think it would be beneficial for the command 'cd ~' (which would usually cd to the users home directory) to cd to the projects root directory instead.

Daenyth commented 12 years ago

You can add this with cd $(git rev-parse --git-dir)/.. for normal repos with .git inside the directory.

phatblat commented 11 years ago

git-sh leverages the shell alias function (type 'alias' while in git-sh to see) and '~' is a shell metacharacter, not available for alias names.

I suggest adding the following line to your .gitshrc file (building on the answer from @Daenyth): alias root='cd $(git rev-parse --git-dir)/..'

Daenyth commented 8 years ago

A more robust one is git rev-parse --show-toplevel