Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

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

Open
ls12styler opened this issue Apr 24, 2012 · 3 comments
Open

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

ls12styler opened this issue Apr 24, 2012 · 3 comments

Comments

@ls12styler
Copy link

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
Copy link
Contributor

Daenyth commented Aug 13, 2012

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

@phatblat
Copy link
Contributor

phatblat commented Mar 8, 2013

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
Copy link
Contributor

Daenyth commented Jul 14, 2016

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants