@slhck@slhck provided valuable suggestions and proof-read most of this. Thanks Werner!
Username http://superuser.com/users/flair/22317.png
In this questionthis question, XenoroseXenorose asked:
Through some bash
debugging facilities, it's even possible to add these formatting rules to the commands you entercommands you enter.
Through color highlighting, the prompt is easily visible between program invocations with lots of output. It prints the previous command's return code unless it's 0
, and lists all files in the current directory if the file count is reasonably low. I prefer this to functions that combine cd
and ls
functions that combine cd
and ls
, as I can immediately see the changes to the current directory after program execution.
As I wrote at the beginning, your prompt is not kept across shell sessions when you simply set PS1
(or PS2
) in your shell. To keep your changes across sessions and restarts of your machine, add the relevant assignments of PS1
, PS2
and PROMPT_COMMAND
-- one per line -- to your .bash_profile
or .bashrc
file in your home directory (more on these filesmore on these files). Save the file, open a new bash session, and enjoy your custom prompt!