Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reopen terminal, don't have anything change ? #47

Open
dangngoclinh opened this issue Nov 1, 2016 · 5 comments
Open

Reopen terminal, don't have anything change ? #47

dangngoclinh opened this issue Nov 1, 2016 · 5 comments

Comments

@dangngoclinh
Copy link

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?.

@walidvb
Copy link

walidvb commented Feb 19, 2018

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"

@joeytwiddle
Copy link

joeytwiddle commented Feb 20, 2018

@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

@walidvb
Copy link

walidvb commented Feb 20, 2018

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

@joeytwiddle
Copy link

joeytwiddle commented Feb 27, 2018

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.

@walidvb
Copy link

walidvb commented Mar 10, 2018

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants