Giter VIP home page Giter VIP logo

Comments (6)

guenhter avatar guenhter commented on July 17, 2024

Very strange.

Can you run this after a new bash and before you did anything manually:

echo $PROMPT_COMMAND

and post the output.

from bash-git-prompt.

derSeddy avatar derSeddy commented on July 17, 2024

Sure:

echo $PROMPT_COMMAND
__vte_prompt_command

from bash-git-prompt.

guenhter avatar guenhter commented on July 17, 2024

Ok, this is not correct. Can you

source gitprompt.sh

once manually and let met see what

echo $PROMPT_COMMAND

is then.

from bash-git-prompt.

derSeddy avatar derSeddy commented on July 17, 2024
source ~/.bash-git-prompt/gitprompt.sh
echo $PROMPT_COMMAND
setLastCommandState;__vte_prompt_command;setGitPrompt

I hadn't mentioned yet that sourcing the script manually will also make the prompt appear.
Thank you for your effort.

from bash-git-prompt.

guenhter avatar guenhter commented on July 17, 2024

Ok, to me this means that something overwrites the PROMPT_COMMAND after it is sourced in the .bashrc with __vte_prompt_command.

You should narrow down where the PROMPT_COMMAND gets overwritten. Maybe you do something like this:

if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
  ...
  echo "$PROMPT_COMMAND" >> /tmp/debug
fi

in your .bashrc, open a new terminal and then look what /tmp/debug contains. That way you can trace down the cause.

from bash-git-prompt.

derSeddy avatar derSeddy commented on July 17, 2024

In my bashrc I had the line

if [ $TILIX_ID ] || [ $VTE_VERSION ] ; then source /etc/profile.d/vte.sh; fi # Ubuntu Budgie END

which I'm not sure what this does and it seem like Ubuntu Budgie automatically added this. But this line was causing PROMPT_COMMAND to be set to __vte_prompt_command.
I removed the line, problem solved.

FYI the content of /etc/profile.d/vte.sh:

# Copyright © 2012 Christian Persch
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

# Not bash or zsh?
[ -n "${BASH_VERSION:-}" -o -n "${ZSH_VERSION:-}" ] || return 0

# Not an interactive shell?
[[ $- == *i* ]] || return 0

# Not running under vte?
[ "${VTE_VERSION:-0}" -ge 3405 ] || return 0

# TERM not supported?
case "$TERM" in
    xterm*|vte*|gnome*) :;;
    *) return 0 ;;
esac

__vte_osc7 () {
  printf "\033]7;file://%s%s\033\\" "${HOSTNAME}" "$(/usr/libexec/vte-urlencode-cwd)"
}

__vte_prompt_command() {
  local pwd='~'
  [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
  pwd="${pwd//[[:cntrl:]]}"
  printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${pwd}"
  __vte_osc7
}

if [[ -n "${BASH_VERSION:-}" ]]; then

    # Newer bash versions support PROMPT_COMMAND as an array. In this case
    # only add the __vte_osc7 function to it, and leave setting the terminal
    # title to the outside setup.
    # On older bash, we can only overwrite the whole PROMPT_COMMAND, so must
    # use the __vte_prompt_command function which also sets the title.

    if [[ "$(declare -p PROMPT_COMMAND 2>&1)" =~ "declare -a" ]]; then
	PROMPT_COMMAND+=(__vte_osc7)
    else
	PROMPT_COMMAND="__vte_prompt_command"
    fi

elif [[ -n "${ZSH_VERSION:-}" ]]; then
    precmd_functions+=(__vte_osc7)
fi

return 0

from bash-git-prompt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.