| Start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Colorize and customize terminal prompt This is how the author sets their personal And this is how my prompt looks like:
Color reference: Notes: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Show git branch name in terminal prompt You can have functions in the PS1 variable, just make sure to single quote it or use escape for special chars: It will give you a prompt like this: Notes:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Change PS1 prompt To change PS1, you just have to change the value of PS1 shell variable. The value can be set in Besides the plain text, a number of backslash-escaped special characters are supported:
So for example, we can set PS1 to: And it will output:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Show a git branch using PROMPT_COMMAND If you are inside a folder of a git repository it might be nice to show the current branch you are on. In If we are in a folder inside a git repository this will output:
And if we are inside a normal folder:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Show time in terminal prompt It will give you a prompt like this: Notes:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Show previous command return status and time Sometimes we need a visual hint to indicate the return status of previous command. The following snippet make put it at the head of the PS1. Note that the __stat() function should be called every time a new PS1 is generated, or else it would stick to the return status of last command of your .bashrc or .bash_profile. |
Read Article
https://develop.horje.com/learn/1434/reference