Bug 416981

Summary: Colorful PS1 is somewhat broken
Product: [Applications] konsole Reporter: a.taha.baki
Component: historyAssignee: Konsole Developer <konsole-devel>
Status: CLOSED NOT A BUG    
Severity: critical CC: a.samirh78, nate
Priority: NOR    
Version: 19.12.1   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description a.taha.baki 2020-01-31 11:04:56 UTC
SUMMARY

Custom colorful "$PS1" env. variables causes editing the previous command or navigitaion via keys like "home" and "end" or "ctrl+tab" etc.

STEPS TO REPRODUCE
1. Make colorful custom $PS1 var
2. Write some commands
3. Use arrow keys to get the previous command and try to edit it via the keys i mentioned above.

OBSERVED RESULT
Nothing works normally if i won't change to the default $PS1 var.

EXPECTED RESULT
Colorful PS1 var is useful. But it is not working great for me.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.17.5
KDE Frameworks Version: 5.66.0
Qt Version: 5.14.1

ADDITIONAL INFORMATION
May be my $PS1 variable is broken or somewhat i missed sth. But i tried every posibility.
Comment 1 Ahmad Samir 2020-02-01 09:27:18 UTC
What do you set PS1 to?
Comment 2 a.taha.baki 2020-02-03 23:11:50 UTC
(In reply to Ahmad Samir from comment #1)
> What do you set PS1 to?
It was:
PS1='\e[1m[\e[35m\u\e[97m@\e[34m\h \W\e[97m]\$ \e[0m'
I used tput instead of "\e[xxx" but it was not good either.
Now, it is:
PS1='[\u@\h \W]\$ '
Comment 3 Ahmad Samir 2020-02-05 21:15:51 UTC
Try:
PS1='\[\e[1m[\e[35m\]\u\[\e[97m\]@\[\e[34m\]\h \W\[\e[97m]\]$ \[\e[0m\]'

From `man bash`:
\[     begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
\]     end a sequence of non-printing characters

Also remove the "\" before "$".
Comment 4 a.taha.baki 2020-02-06 22:39:22 UTC
(In reply to Ahmad Samir from comment #3)
> Try:
> PS1='\[\e[1m[\e[35m\]\u\[\e[97m\]@\[\e[34m\]\h \W\[\e[97m]\]$ \[\e[0m\]'
> 
> From `man bash`:
> \[     begin a sequence of non-printing characters, which could be used to
> embed a terminal control sequence into the prompt
> \]     end a sequence of non-printing characters
> 
> Also remove the "\" before "$".

Thanks, it worked.