bash-git-prompt
bash-git-prompt copied to clipboard
Not displaying correctly on termux
Hi.
I've tryed to use this on termux and the status doesn't display correctly:

I've used:
grep -lir --exclude-dir=.git '#!' . | xargs termux-fix-shebang
To fix the shebang on the scripts.
Any ideas? Thanks.
Please give the Output of grep -ir --exclude-dir=.git '#!' ~/.bash/bash-git-prompt/
Hi, this is it:
/data/data/com.termux/files/home/.bash/bash-git-prompt//git-prompt-help.sh:#!/usr/bin/env bash
Binary file /data/data/com.termux/files/home/.bash/bash-git-prompt//gitprompt.png matches
/data/data/com.termux/files/home/.bash/bash-git-prompt//gitprompt.sh:#!/usr/bin/env bash
/data/data/com.termux/files/home/.bash/bash-git-prompt//gitstatus.py:#!/usr/bin/env python
/data/data/com.termux/files/home/.bash/bash-git-prompt//gitstatus.sh:#!/usr/bin/env bash
/data/data/com.termux/files/home/.bash/bash-git-prompt//gitstatus_pre-1.7.10.sh:#!/usr/bin/env bash
/data/data/com.termux/files/home/.bash/bash-git-prompt//prompt-colors.sh:#!/usr/bin/env bash
And the termux-fix-shebang script is here: https://github.com/termux/termux-packages/blob/master/packages/termux-tools/termux-fix-shebang
It doesn't looks like something's changed...
~/.bash-git-prompt [master|✔] $ grep -ir --exclude-dir=.git '#!' .
./gitprompt.sh:#!/usr/bin/env bash
./prompt-colors.sh:#!/usr/bin/env bash
Übereinstimmungen in Binärdatei ./gitprompt.png
./gitstatus.sh:#!/usr/bin/env bash
./git-prompt-help.sh:#!/usr/bin/env bash
./gitstatus_pre-1.7.10.sh:#!/usr/bin/env bash
./gitstatus.py:#!/usr/bin/env python
To actually change the files you have to use the full command I provided in the initial post:
grep -lir --exclude-dir=.git '#!' . | xargs termux-fix-shebang
That part is definitely working because before running that I don't get any git status on the prompt and after I do, like you can see on the screen shot.
Off course, i referenced to you own Post ;) Which clearly hasn't changed your copy. So i wonder, if it has ever worked.
oh, sorry :P I've reverted that. This is how it looks if I run it again:
/data/data/com.termux/files/home/.bash/bash-git-prompt//git-prompt-help.sh:#!/data/data/com.termux/files/usr/bin/env bash
Binary file /data/data/com.termux/files/home/.bash/bash-git-prompt//gitprompt.png matches
/data/data/com.termux/files/home/.bash/bash-git-prompt//gitprompt.sh:#!/data/data/com.termux/files/usr/bin/env bash
/data/data/com.termux/files/home/.bash/bash-git-prompt//gitstatus.py:#!/data/data/com.termux/files/usr/bin/env python
/data/data/com.termux/files/home/.bash/bash-git-prompt//gitstatus.sh:#!/data/data/com.termux/files/usr/bin/env bash
/data/data/com.termux/files/home/.bash/bash-git-prompt//gitstatus_pre-1.7.10.sh:#!/data/data/com.termux/files/usr/bin/env bash
/data/data/com.termux/files/home/.bash/bash-git-prompt//prompt-colors.sh:#!/data/data/com.termux/files/usr/bin/env bash
sorry for the confusion.
Either commands spawns there refered binary?
Try /data/data/com.termux/files/usr/bin/env bash and /data/data/com.termux/files/usr/bin/env python?
The bash command can be checked with cd /proc/self; ls -l
for the Python one it's enough if you prompted with something like this in the first line: Python (here i have Python 3.4.5)
I'm not sure I follow what you mean but yes, /data/data/com.termux/files/usr/bin/env bash spawns a new bash.
And /data/data/com.termux/files/usr/bin/env python? Should spawn a python Environment. If it does not spawn the python cli. This can be your Problem.
yes, it does. It's using python 3.6.2 but I think I'm using the bash version gitstatus.sh.
My config is here: https://github.com/luisdavim/dotfiles/blob/master/files/bash/git-prompt-colors.sh
Hmpf... okay sorry for wasting your time. My thoughts were that something in this termux Packages are not there where it should be.
No, problem. I appreciate your help.
Also the output of gitstatus.sh looks ok, I don't know how to debug this any further.
Any idea how to debug this?
➜ 08:05:04 ~/.../github/dotfiles (master|● 106…106) $ ~/.bash/bash-git-prompt/gitstatus.sh master
.
origin/master
0
0
0
0
0
1
➜ 08:05:22 ~/.../github/dotfiles (master|● 106…106) $ git --version
git version 2.16.1
➜ 08:06:32 ~/.../github/dotfiles (master|● 106…106) $ bash --version GNU bash, version 4.4.12(1)-release (aarch64-unknown-linux-android)
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
➜ 08:06:47 ~/.../github/dotfiles (master|● 106…106) $ git status On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
➜ 08:07:35 ~/.../github/dotfiles (master|● 106…106) $ git status -sb
## master...origin/master
➜ 08:07:41 ~/.../github/dotfiles (master|● 106…106) $
The output of gitstatus.sh seems wrong - it should show more data - so maybe start looking there.
If I have a clean state on master gitstatus shows this:
master
.
origin/master
0
0
0
0
0
1
Too few rows here might throw the parser off.
Hi, That is how my output looks. I guess the problem is that I was posting from my tablet and the text got wrapped.
This is what I get:
23:27:32 ~/.bash/bash-git-prompt (master|● 46…46) $ ./gitstatus.sh
master
.
origin/master
0
0
1
0
0
0
Here's what I get if I set -x:
https://gist.github.com/luisdavim/9445651ad1050377467c699381ef6a86
I have the same behaviour
If I call gitstatus.sh directly from inside git repository, it displays correct data
When I modify gitstatus.sh to display (or write to some file) contents of ${gitstatus} variable when called from gitprompt.sh, it shows:
## master...origin/master
D .gitattributes
D .gitignore
D LICENSE.txt
D README.md
D bash-git-prompt.rb
D bash-git-prompt.spec
D git-prompt-help.sh
D gitprompt.fish
D gitprompt.png
D gitprompt.sh
D gitstatus.py
D gitstatus.sh
D gitstatus_pre-1.7.10.sh
D prompt-colors.sh
D themes/Chmike.bgptheme
D themes/Crunch.bgptheme
D themes/Custom.bgptemplate
D themes/Default.bgptheme
D themes/Default_NoExitState.bgptheme
D themes/Default_NoExitState_Ubuntu.bgptheme
D themes/Default_Ubuntu.bgptheme
D themes/Evermeet.bgptheme
D themes/Evermeet_Lowres.bgptheme
D themes/Evermeet_Ubuntu.bgptheme
D themes/Minimal.bgptheme
D themes/Minimal_Chevron.bgptheme
D themes/Minimal_UserHost.bgptheme
D themes/Plague_Doctor.bgptheme
D themes/Single_line.bgptheme
D themes/Single_line_Dark.bgptheme
D themes/Single_line_Minimalist.bgptheme
D themes/Single_line_NoExitState.bgptheme
D themes/Single_line_NoExitState_Gentoo.bgptheme
D themes/Single_line_NoExitState_openSUSE.bgptheme
D themes/Single_line_Solarized.bgptheme
D themes/Single_line_Solarized_Lamda.bgptheme
D themes/Single_line_Ubuntu.bgptheme
D themes/Single_line_openSUSE.bgptheme
D themes/Single_line_username_repo.bgptheme
D themes/Solarized.bgptheme
D themes/Solarized_Extravagant.bgptheme
D themes/Solarized_NoExitState.bgptheme
D themes/Solarized_NoExitState_Ubuntu.bgptheme
D themes/Solarized_Ubuntu.bgptheme
D themes/Solarized_UserHost.bgptheme
D themes/TruncatedPwd_WindowTitle.bgptheme
D themes/TruncatedPwd_WindowTitle_NoExitState.bgptheme
D themes/TruncatedPwd_WindowTitle_NoExitState_Ubuntu.bgptheme
D themes/TruncatedPwd_WindowTitle_Ubuntu.bgptheme
?? .gitattributes
?? .gitignore
?? LICENSE.txt
?? README.md
?? bash-git-prompt.rb
?? bash-git-prompt.spec
?? git-prompt-help.sh
?? gitprompt.fish
?? gitprompt.png
?? gitprompt.sh
?? gitstatus.py
?? gitstatus.sh
?? gitstatus_pre-1.7.10.sh
?? prompt-colors.sh
?? themes/
It looks like git status called from gitprompt.sh script thinks files are simultaneously deleted and not tracked. I don't know why.
Additionally I think in script gitstatus.sh there is one missing line checking if file is deleted on second pass, otherwise it is added to staged files
?D) ((num_changed++)) ;;
?\ ) ;;
#single character matches, second loop
+ D) ((num_changed++)) ;;
U) ((num_conflicts++)) ;;
\ ) ;;
*) ((num_staged++)) ;;
Git version 2.23 on Termux
Found it - on Android there is no /tmp directory, so private git index was not created, but still variable GIT_INDEX_FILE was set pointing to non-existent file. This way git status showed all files were simultaneously deleted and not tracked.
Created PR #460
For what it's worth, the change in that pull request solved the issue for me. Is there a chance that it will be merged?