I want to have really complex prompt. It should contains login, computer name, date, time, working directory, result of last command and new line symbol. I want to color each item as well. So I inserted into my .bashrc some kind of monster like this one:
# login and computer name
PS1='[\e[1;37m\]\u\e[m\]@\e[1;32m\]\h\e[m\]] '
# date, time and working directory
PS1=$PS1'[\e[1;34m\]\D{%Y-%m-%d} \e[1;35m\]\t\e[m\]] \e[1;33m\]\w\e[m\] '
# result of last command and command prompt in new line
PS1=$PS1'\e[1;31m\]${?#0}\e[m\]\n \e[1;36m\]\$\e[m\] '
I do know it is terrible solution, but I have too little experience with bash to improve this. But this is not the only one problem.
$ aaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bash: bbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: command not found...
After the last a I pressed Home key, but visual caret didn't go to the beginning of the command. As you can see, actual caret went to the beginning. Why this occurred? How can I improve my command prompt in my .bashrc?
Update:
After using @Groxxda advice, I've got one another problem. My .bashrc PS1 definition looks like this one. Described issue doesn't occur now. But if in my command history I have ls and before this I have cat script.sh, and if I push arrow up twice, I have got command like cat scls and buffer has only two signs (only ls). Why this occurs? How can I manage this?
\[\]escapes. This tells bash that the content between does not print visible characters. You should put them around the color codes. – groxxda Aug 03 '14 at 11:54.bashrcPS1 definition looks like this one: http://pastebin.com/EZDn6VkP. Described issue doesn't occurs now. But if in my command history I havelsand before this I havecat script.sh, and if I push arrow twice, I have got command likecat sclsand buffer has only two signs (onlyls). Why this occurs? How can I manage this? – pt12lol Aug 03 '14 at 16:19\[…\]. – Gilles 'SO- stop being evil' Aug 03 '14 at 20:45[login@computername]... etc. – pt12lol Aug 03 '14 at 21:19[login@hostname]is the basic prompt: see https://wiki.archlinux.org/index.php/Color_Bash_Prompt#Regular_user – jasonwryan Aug 03 '14 at 21:22\]s in your prompt. Also which fields are missing? – groxxda Aug 03 '14 at 22:42