Wednesday, December 21, 2016

Modifying PS1 for bash.

You can change your bash prompt to be more informative:



or



or



or



This prompt is showing the user (root) at IP, the currently opened folder and the git branch if you are in a git repo.

To change your prompt add these lines to ~/.bashrc (for the first prompt shown above)

\[\e[0;31m\] Some Text Here \[\e[m\]

This will color "Some Text Here" red.

parse_git_branch determines the git branch (if you are in a git project directory) and appends it to PS1.

For displaying time you can use : \t or \T. See : (https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html) for more options.

For changing the prompt to look like the second one above:

For the third prompt shown above:

For the fourth prompt shown above:

No comments:

Post a Comment