jimeh / git-aware-prompt

Display current Git branch name in your terminal prompt when in a Git working directory.
Creative Commons Zero v1.0 Universal
2.15k stars 340 forks source link

Did not work with Ubuntu 18.04 #58

Open iamraju opened 6 years ago

iamraju commented 6 years ago

Hi There,

While it is/was working with other Debian, it did not work with Ubuntu 18.04. Is there anything that I should take care of ?

joeytwiddle commented 6 years ago

If you have .bash_profile file, make sure that it sources .profile

Otherwise .profile won't get loaded! (Thanks bash)

iamraju commented 6 years ago

Nope, I do not have .bash_profile file, but still it does not work.

hossein-jazayeri commented 5 years ago

I have the same problem. On the fresh ubuntu 18.04, it doesn't work unless I run the source "${GITAWAREPROMPT}/main.sh" manually. On my previous setup which was 16.04 upgraded to 18.04, it was working though.

carstencodes commented 1 year ago

@hossein-jazayeri @iamraju

Following https://github.com/magicmonty/bash-git-prompt/issues/520 solved this issue for me.

Does this line appear in your .bashrc?

diogoca commented 1 year ago

Same issue on Ubuntu Terminal, any idea?

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.2 LTS
Release:    22.04
Codename:   jammy

$ echo $BASH
/usr/bin/bash

$ echo $PROMPT_COMMAND
find_git_branch; find_git_dirty; find_git_branch; find_git_dirty;

$ echo $PS1
${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[\]$git_branch\[\]$git_dirty\[\]$

$ cat .profile 
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# 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

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

Last lines from my .bashrc:

# enable gitaware 
# https://github.com/jimeh/git-aware-prompt
export GITAWAREPROMPT=~/git-aware-prompt
source "${GITAWAREPROMPT}/main.sh"
export PS1="\${debian_chroot:+(\$debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "