0

I am trying to set a custom bash prompt to also include history line count and time in 24h format, both in different colors, aside from a standard user@host prompt.

I have seen this post

Custom bash prompt is buggy

and some other examples, but I still seem to be unable to make it right, since I experience all kinds of weird behavior after setting the custom prompt.

I have tried several variations of this string:

PS1='\[\e[01;31m\]\!\[\e[00m\] \[\e[01;33m\A\[\e[00m\] ${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

some with less and some with more escape characters. Various trials result in either too much or too little text when browsing history or deleting a command on a line.

Even by looking at several examples, I cannot get, what needs to be escaped and how much.

It is probably not relevant, but I am using Kubuntu 21.10. I only access bash through Konsole and Dolphin terminal.

Thank you in advance and Kindest regards!

1 Answers1

0

This seems to work. It is trivial. I have no idea why I could not make it before.

PS1='[\033[01;31m]![\033[00m] [\033[01;33m]\A[\033[00m] ${debian_chroot:+($debian_chroot)}[\033[01;32m]\u@\h[\033[00m]:[\033[01;34m]\w[\033[00m]$ '

I apologize for posting such a trivial problem.

Anyway, I find this prompt very useful, so here is the solution anyway for anybody interested in it.