Open gnome terminal new tab in current folder with git prompt command

449 Views Asked by At

In Fedora 29, added nice branch display to my bash prompt and new tabs no longer open in current folder:

if [ -f /etc/bash_completion.d/git-prompt ]
then
  GIT_PS1_SHOWCOLORHINTS='yes'
  GIT_PS1_SHOWDIRTYSTAT='yes'
  GIT_PS1_SHOWSTASHSTATE='yes'
  GIT_PS1_SHOWUNTRACKEDFILES='yes'
  GIT_PS1_SHOWUPSTREAM='auto
  PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
fi

Result:

  • Opening new tab no longer opens in current folder

Notes:

  • Must use PROMPT_COMMAND instead of PS1 because must have colors and nice things....
  • Looks like /etc/profile.d/vte.sh is being cancelled

Resourses:

1

There are 1 best solutions below

0
On BEST ANSWER
function set_git_prompt() {
  __git_ps1 "\u@\h:\w" "\\\$ "
  [ $VTE_VERSION ] && __vte_prompt_command
}

if [ -f /etc/bash_completion.d/git-prompt ]
then
  GIT_PS1_SHOWCOLORHINTS='yes'
  GIT_PS1_SHOWDIRTYSTAT='yes'
  GIT_PS1_SHOWSTASHSTATE='yes'
  GIT_PS1_SHOWUNTRACKEDFILES='yes'
  GIT_PS1_SHOWUPSTREAM='auto

  PROMPT_COMMAND='set_git_prompt'
fi