Posted: . At: 10:17 AM. This was 1 year ago. Post ID: 17808
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.


Another very nice bash shell prompt, this shows how to have custom characters in a prompt.


This amazing bash shell prompt shows how to have custom characters to replace the $ prompt. This is a nice way to customize the prompt further.

echo $PS1
\[\e]0;\u@\h: \w\a\]\[\033[;32m\]╭──${debian_chroot:+($debian_chroot)──}${VIRTUAL_ENV:+(\[\033[0;1m\]$(basename $VIRTUAL_ENV)\[\033[;32m\])}(\[\033[1;34m\]\u${prompt_symbol}\h\[\033[;32m\])-[\[\033[0;1m\]\w\[\033[;32m\]]\n\[\033[;32m\]╰───────────────────────────╾\[\033[1;34m\]$(if [ $EUID -eq 0 ]; then echo "#"; else echo "┋"; fi)\[\033[0m\]

And this is what the prompt looks like. This is very usable and fast.

╭──(john㉿DESKTOP-PF01IEE)-[~]
╰───────────────────────────╾┋

This code will print either the # or $ characters depending upon whether the user is root or not.

$(if [ $EUID -eq 0 ]; then echo "#"; else echo "┋"; fi)

But you may replace the $ character with whatever you wish. This is nice.

This is another bash prompt. This one is very colourful.

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 what it looks like.

5.2 Thu Mar 30 john@DESKTOP-PF01IEE 1: $

More settings to put in your ~/.bashrc.

# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
# Force prompt to write history after every command.
# http://superuser.com/questions/20900/bash-history-loss
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"

This sets an unlimited .bash_history.


Leave a Comment

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