darkrc/bin/gitpath

13 lines
206 B
Bash
Executable File

#!/bin/sh
top=$(git rev-parse --show-toplevel 2>/dev/null | sed -e 's/\//\\\//g')
if [ -n "$top" ]
then
path=$(pwd -P | sed -e "s/^$top//")
if [ ! -z "$path" ]
then echo -n "$path "
fi
else
exit 1
fi