When I write a long command and the line of text gets to end of terminal, it continues at beginning the same line (as if it was "overwriting it), and if I hit home it doesn't really go to the beginning of the line.
I've found this question, this other, etc., and I now it is related with the colors and things I want it to display... and I am so sorry to open another post, but I tried to edit the line myself but I can't really get it ok. Can yo guys give me some help?
Here is the extract from my .bashrc:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\][\u@debian]\[\033[01;34m\][\033[01;34m\]\w\]]\033[01;34m\]\$\033[00m\] '
To clarify it, I want the prompt to be:
[username@debian][~]$
- Meaning, username@debian between brackets
[\u@debian], in green color
*Yes, I want it to display "debian", not usual \h
- Working directory also between its brackets
[\w], in blue color - The
$of normal user - And the text I type to be displayed in white colour.
- I don't care about root user's prompt.
Thanks for the help, and again, sorry to open another post for this...
Edit: I tried to rewrite it after slowly reading this full tutorial. But wasn't able to make it work. Now it doesn't "overwrite" the first line, but on the second, after a few characters, overwrites that second line for just a few characters, then continues ok. But with this new PS1, if I hit the UP arrow on the keyboard to previous commands, it gets really funky.
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[[\]\u\[@debian]\]\[\033[01;34m\]\[[\]\w\[]\]\[\033[01;34m\]\$\[\033[00m\] '
If I didn't get wrong the tutorial, it is supposed to be:
\[Begin a sequence of non-printing characters.\]end the sequence of non-printing characters.\033[XXmcolor, that needed to be between the start and end of non-printing characters, so, for example, for color blue (34) it should be:\[\033[34m\]
So, in my mind, it should work now, but it doesn't. Clearly I'm not seeing it right -.-
[before the working directory, meaning it shows[user@debian] ~] $(I use spaces here so it's easier to read, but the characters are, of course, all next to each other)Here is a screenshot
– PolGZ Feb 03 '21 at 13:50\[and[, then, each in the appropriate place.[where you want a literal[, and\[around each of the control sequences:[\[\033[01;34m\]\w\[\033[00m\]]? You might find it easier to define some variables, e.g.green='\['"$(tput setaf 2)"'\]'etc. – Toby Speight Feb 03 '21 at 16:27[\[\033[01;34m\]\w\[\033[00m\]], but it doesn't seem to work. I've edited the main post with another try starting from scratch. Maybe you can help from that now – PolGZ Feb 03 '21 at 19:47\[[\]is completely broken - you've told Bash that[doesn't take any screen space. There's one simple rule - use\[..\]around sequences that don't advance the cursor, and nowhere else. – Toby Speight Feb 03 '21 at 21:07\[...\]should have been only for the colors! I LOVE YOU SO MUCH! – PolGZ Feb 03 '21 at 22:01