programming:bash_notes
Differences
This shows you the differences between two versions of the page.
| programming:bash_notes [2022/06/10 19:19] – external edit 127.0.0.1 | programming:bash_notes [2022/11/04 20:27] (current) – colored prompt with git branch rene | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| < | < | ||
| for f in *; do mv -i " | for f in *; do mv -i " | ||
| + | </ | ||
| + | |||
| + | === Colored prompt === | ||
| + | Have a colored prompt for the user spanning two lines. | ||
| + | |||
| + | * date and time in white | ||
| + | * Path in blue color | ||
| + | * branch in yellow | ||
| + | * username and server in green | ||
| + | * command in white | ||
| + | |||
| + | < | ||
| + | [2022-11-04 20:09.15] ~ | ||
| + | (master)[user@server]: | ||
| + | </ | ||
| + | |||
| + | The function fetches the branch name and the prompt dispays it. | ||
| + | <code bash> | ||
| + | parse_git_branch() { | ||
| + | git branch 2> /dev/null | sed -e '/ | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | export PS1=" | ||
| + | </ | ||
| + | |||
| + | For the root user maybe a red color for the username and server is better | ||
| + | |||
| + | <code bash> | ||
| + | export PS1=" | ||
| </ | </ | ||
programming/bash_notes.txt · Last modified: 2022/11/04 20:27 by rene