bash-git-prompt
bash-git-prompt copied to clipboard
error in git_prompt_dir
Following the instruction to install with git cloning I get the version at the commit 6a606da7c0cbb562a745496b2015f52ea1ba5850.
If I put in my .bashrc source ~/.bash-git-prompt/gitprompt.sh
I obtrain an error:
bash: dirs: +P: invalid number
dirs: usage: dirs [-clpv] [+N] [-N]
bash: /git-prompt-help.sh: No such file or directory
bash: dirs: +P: invalid number
dirs: usage: dirs [-clpv] [+N] [-N]
Cannot find prompt-colors.sh!
bash: /themes/Default.bgptheme: No such file or directory
bash: /themes/Default.bgptheme: No such file or directory
bash: dirs: +P: invalid number
dirs: usage: dirs [-clpv] [+N] [-N]
bash: dirs: +P: invalid number
dirs: usage: dirs [-clpv] [+N] [-N]
Cannot find prompt-colors.sh!
bash: /themes/Default.bgptheme: No such file or directory
bash: /themes/Default.bgptheme: No such file or directory
bash: dirs: +P: invalid number
dirs: usage: dirs [-clpv] [+N] [-N]
Cannot find prompt-colors.sh!
bash: /themes/Default.bgptheme: No such file or directory
bash: /themes/Default.bgptheme: No such file or directory
I do not understand the problem but I managed to work around with this patch
diff --git a/gitprompt.sh b/gitprompt.sh
index fe305aa..7aeba3d 100755
--- a/gitprompt.sh
+++ b/gitprompt.sh
@@ -7,17 +7,7 @@ function async_run() {
}
function git_prompt_dir() {
- # assume the gitstatus.sh is in the same directory as this script
- # code thanks to http://stackoverflow.com/questions/59895
- if [ -z "$__GIT_PROMPT_DIR" ]; then
- local SOURCE="${BASH_SOURCE[0]}"
- while [ -h "$SOURCE" ]; do
- local DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
- SOURCE="$(readlink "$SOURCE")"
- [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
- done
- __GIT_PROMPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
- fi
+ __GIT_PROMPT_DIR="/home/myuser/.bash-git-prompt"
}
Does this problem still happen with the latest version? If yes, which system you are using this prompt on (Linux, Mac, Cygwin...)?
I ran into what I'm assuming is the same issue. I'm using the latest version (2.4.1) installed through Homebrew on OS X (10.11.4). Here's what I was getting:
-bash: /usr/local/Cellar/bash-git-prompt/2.4.1/share
Saving session...
...copying shared history...
...saving history...
...completed./git-prompt-help.sh: No such file or directory
Cannot find prompt-colors.sh!
-bash: /usr/local/Cellar/bash-git-prompt/2.4.1/share
Saving session...
...copying shared history...
...saving history...
...completed./themes/Default.bgptheme: No such file or directory
-bash: /usr/local/Cellar/bash-git-prompt/2.4.1/share
Saving session...
...copying shared history...
...saving history...
...completed./themes/Default.bgptheme: No such file or directory
Cannot find !
I managed to get around the issue by changing this:
if [ -f "$(brew --prefix bash-git-prompt)/share/gitprompt.sh" ]; then
source "$(brew --prefix bash-git-prompt)/share/gitprompt.sh"
fi
...to this:
if [ -f "$(brew --prefix bash-git-prompt)/share/gitprompt.sh" ]; then
export __GIT_PROMPT_DIR="$(brew --prefix bash-git-prompt)/share/"
source "$(brew --prefix bash-git-prompt)/share/gitprompt.sh"
fi
@wesm87 Thanks a lot!
I figured that we are using cd_func, or whatever tempts with cd
's normal behavior. As soon as I remove this part from my environment (in my case, Cygwin), the problem went away.
LunarShaddow@Lune-Thinkpad ~
$ mkdir test
LunarShaddow@Lune-Thinkpad ~
$ cd -P test
LunarShaddow@Lune-Thinkpad ~/test
$ cd ..
LunarShaddow@Lune-Thinkpad ~
$ source cd_func.sh
LunarShaddow@Lune-Thinkpad ~
$ cd -P test
-bash: dirs: +P: invalid number
dirs: usage: dirs [-clpv] [+N] [-N]
ADIR is null. Terminating.
I suggest close this issue.
@wesm87 thanks! this solution works for me too.
So, I will close this issue now