X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;ds=sidebyside;f=.shellrc;h=b06ba8b24312a12021ba31d788e50cf0e5fcfbb3;hb=a090b02a21df5d04f3359a79d14eff3b4d72d934;hp=78beaf7ad6991ee6e20a79304de731d21dc89dae;hpb=2c9e8b23a92508c4fe13c9b43eae6274786f5aa9;p=dotfiles.git diff --git a/.shellrc b/.shellrc index 78beaf7..b06ba8b 100644 --- a/.shellrc +++ b/.shellrc @@ -52,6 +52,28 @@ if [ -n "$STY" -a "$WINDOW" != 0 ]; then unset MAILCHECK fi +if test -x /usr/bin/git >/dev/null 2>&1; then + # chdir to a directory + cdgitpath() { + if [ $# -ne 1 ]; then + echo "Usage: cdgitpath path_key" >&2 + return 1 + fi + + path_key="$1" + if [ -z "$path_key" ]; then + echo "Usage: cdgitpath path_key" >&2 + return 1 + fi + + path_url="`git config --get --path $path_key`" + if echo "$path_url" | grep -q '^file:/'; then + path_url="`echo \"$path_url\" | sed 's@^file:/\+@/@'`" + fi + cd "$path_url" + } +fi + include() { cfg="$1" shift