0

I have a kind of complicated PS1 pattern:

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\]\$ "

Which is based off of the git-aware-prompt utility and docs.

Everything used to work pretty well, but for a while now, whenever I start a new terminal session my terminal seems to output some of the PS1:

\]\u@\h\[\]:\[\]\w\[\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "pat@computer:~ $

And I can't figure out why. Hitting enter the next ps1 output is normal:

\]\u@\h\[\]:\[\]\w\[\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ "pat@computer:~ $ 
pat@computer:~ $ 
pat@computer:~ $ 

Executing individual lines of my .bashrc related to PS1 configuration doesn't appear to cause shell output.

Patrick Flynn
  • 430
  • 2
  • 8
  • Perhaps you have `echo "$PS1"` in your `.profile` or `.bashrc`. Did you `grep PS1` all the possible startup files? – Toby Speight May 03 '17 at 14:42
  • 1
    Run `PS4=':$BASH_SOURCE:$LINENO+' bash -x -l -i`, and look through its output to find the exact command responsible, complete with path to the file and line number. – Charles Duffy May 03 '17 at 16:49
  • 1
    (aside: *grumble* about the unnecessary use of `export` -- PS1 is a shell builtin variable; there's not generally any good reason for it to be exported to the environment, which can make it available to other, non-bash shells which won't necessarily parse it correctly). – Charles Duffy May 03 '17 at 16:50
  • 1
    Anyhow -- for this to be answerable, it would need to contain a [mcve] -- that is, code actually tested to produce the same result *in isolation*. That one `export` command does *not* produce the output in question on its own, meaning you need to track down what else in your dotfiles is involved. – Charles Duffy May 03 '17 at 16:51
  • Thanks for the responses and apologies for the delayed response on this question. I posted it and then went on break. I spent some time trying to create a minimal/complete/verifiable example and had some trouble, but it was some time ago, so I don't quite remember the details. I'll give it another go and let you know. FYI: - I did search for PS1 in my config files and found nothing apart from my one assignment in my .bashrc. - duly noted that export is not required. - PS4=':$BASH_SOURCE:$LINENO+' bash -x -l -i produced a LOT of output. Nothing stood out. – Patrick Flynn May 11 '17 at 12:59

0 Answers0