From 56e9e243a3d9b86deb16d7af7f0136d1cd55c962 Mon Sep 17 00:00:00 2001 From: Martin Goldhahn Date: Wed, 3 Jul 2013 01:53:22 +0200 Subject: [PATCH] script works for any installation directory --- gitprompt.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gitprompt.sh b/gitprompt.sh index 84791fa..94843a6 100644 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -1,6 +1,14 @@ -if [ "x$__GIT_PROMPT_DIR" == "x" ] -then - __GIT_PROMPT_DIR=~/.bash +#!/bin/bash +# assume the gitstatus.py is in the same directory as this script +# code thanks to http://stackoverflow.com/questions/59895 +if [ -z "$__GIT_PROMPT_DIR" ] ; then + SOURCE="${BASH_SOURCE[0]}" + while [ -h "$SOURCE" ] ; do + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" + done + __GIT_PROMPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" fi # Colors