Open dangngoclinh opened 7 years ago
I'm having a similar issue, where running the commands manually after prompt has loaded works, but from .profile
doesn't (although i do see my echo, so file is definitely run)
manually running source ~/.profile
also doesn't work
export GITAWAREPROMPT=~/.bash/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
export PS1="\${debian_chroot:+(\$debian_chroot)}\u@\h:\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
echo "test"
@walidvb, I think ~
might only work on the command line. You could try export GITAWAREPROMPT="$HOME/.bash/git-aware-prompt"
After you source ~/.profile
what does echo "$PS1"
show you?
And are the functions loaded in your shell? You can check with declare -f find_git_branch
Hi @joeytwiddle thanks for the quick reply.
Here is my output:
Last login: Tue Feb 20 14:31:17 2018 from 179.105.132.190
adding git-aware-prompt
walid@prod-server:~$ cd api
walid@prod-server:~/api$ source ~/.profile
adding git-aware-prompt
walid@prod-server:~/api$ echo "$1"
walid@prod-server:~/api$ declare -f find_git_branch
find_git_branch ()
{
local branch;
if branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null); then
if [[ "$branch" == "HEAD" ]]; then
branch='detached*';
fi;
git_branch="($branch)";
else
git_branch="";
fi
}
walid@prod-server:~/api$ find_git_branch
walid@prod-server:~/api$ git rev-parse --abbrev-ref HEAD
master
walid@prod-server:~/api$ branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null)
walid@prod-server:~/api$ echo $branch
master
walid@prod-server:~/api$ git_branch
-bash: git_branch: command not found
walid@prod-server:~/api$ export GITAWAREPROMPT="$HOME/.bash/git-aware-prompt"
walid@prod-server:~/api$ source "${GITAWAREPROMPT}/main.sh"
walid@prod-server:~/api$ export PS1="\${debian_chroot:+(\$debian_chroot)}\u@\h:\w \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "
And the machine i'm running on:
Linux prod-server 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64
If nothing changes after you manually export PS1
then my guess is that you are running a different shell, perhaps zsh, which uses PROMPT
instead of PS1
.
Note that this software expects you to set PS1
or PROMPT
yourself. It doesn't do that automatically.
Also note that if you have a ~/.bash_profile
file then bash will not load ~/.profile
when it starts up.
It turns out that some code running(the default gcloud machines) was reverting the commands run:
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
Placing the export after this solved the issue for me. Thanks!
Hi,
I have install success on my terminal mac os.
But at this terminal i cant view git branch is beautiful.
But I close this terminal and reopen, I cd to git folder. I don't see git branch current show ?.
Can't I help me?.