#!/bin/sh

root="$(git rev-parse --show-toplevel 2>/dev/null)"

if [ -z "$root" ]
then
  builtin cd "$@"
else
  if [ -z "$1" ]
  then
    builtin cd "$root"
  else
    if [ $(echo "$1" | grep '^/') ]
    then builtin cd "$root"$@
    else builtin cd "$@"
    fi
  fi
fi

source smartprompt