DEV Community

Discussion on: g - a wrapper around git with additional feature extension

Collapse
 
moopet profile image
Ben Sinclair

Nice. I'm not a fan of these things myself, because I'm generally not big on character-saving aliases, and I almost never do the things people think are common (like immediately changing to a directory you just created).

I was interested in changing to a directory relative to the project root though, and I put this in my shell startup script:

git() {
  if [ "$1" = "cd" ]; then
    shift
    cd "./$(git rev-parse --show-cdup)$*"
  else
    command git "$@"
  fi
}

You know what, though? I almost never use it!

Collapse
 
pcdevil profile image
Attila Gonda • Edited

I know what you talking about :)

Often time I use g cd without any argument and couple of weeks ago I started to use CDPATH (available in both zsh and bash):

I can specify regularly used repositories and then jump to their git root from anywhere! so right now i rarely type g cd at all and just type cd project (or simply project with zsh) :)

(edit: wording)