Posted: . At: 9:57 AM. This was 6 years ago. Post ID: 12389
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


Very useful bash PS1 prompts.


A very colorful example that will really stand out.

4.4 Wed Aug 29 jason@Yog-Sothoth 0: $

Here is the code for this example.

export PS1="\[\033[38;5;39m\]\v\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;83m\]\d\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;201m\]\u\[$(tput sgr0)\]\[\033[38;5;196m\]@\[$(tput sgr0)\]\[\033[38;5;51m\]\H\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]\[\033[38;5;82m\]\l\[$(tput sgr0)\]\[\033[38;5;15m\]: \\$ \[$(tput sgr0)\]"

This is a nice monochrome example. This is more restrained.

-09:27:42-- jason@Yog-Sothoth [~]$

and this is the code for this example.

PS1="-\t-- \u@\h [\w]\$ "

More information on setting up your shell here.

https://securitronlinux.com/my-linux-tips-and-tricks-page-part-1/#toc-setting-up-your-bash-prompt.

This is another example with color.

09:32:12 jason@Yog-Sothoth ~ $ 

it is very good to use if the user wishes to make it stand out from the shell output, but not to be as garish as my first example.

PS1='\t \e[0;35m\u\e[m@\h \W \$ '

There are a couple more examples on this page.

https://securitronlinux.com/debian-testing/very-nice-bash-ps1-prompts/.

How to have a bash prompt that changes when the user is in a certain folder.

https://securitronlinux.com/debian-testing/how-to-have-a-custom-bash-prompt-that-changes-when-you-are-in-a-certain-folder/.

Use a bash prompt that is randomly generated every time it appears.

https://securitronlinux.com/bejiitaswrath/get-a-randomly-generated-bash-shell-prompt-and-some-other-tricks-for-the-linux-shell/.

These tips should really help out a Linux user that is needing to customize their Linux environment to suit a particular use case. Or just for fun.


1 thought on “Very useful bash PS1 prompts.”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.