darkrc/bin/cd-improved

22 lines
324 B
Text
Raw Normal View History

2020-05-15 09:36:09 +00:00
#!/bin/sh
root="$(git rev-parse --show-toplevel 2>/dev/null)"
if [ -z "$root" ]
then
cd "$@"
2020-05-15 09:36:09 +00:00
else
if [ -z "$1" ]
then
cd "$root"
else
if [ $(echo "$1" | grep '^/') ]
then cd "$root"$@
else cd "$@"
2020-05-15 09:36:09 +00:00
fi
fi
fi
git rev-parse --show-toplevel >/dev/null 2>&1 \
&& prompt gitlong || prompt normal