Posted: . At: 10:25 AM. This was 6 years ago. Post ID: 12283
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 nice bash PS1 prompts.


A complex, but very useful bash shell prompt.

PS1=$(
    sep=$'\xC2\xBB'     # UTF-8 U+00BB
        red=$(tput setaf 1)
	green=$(tput setaf 2)
	yellow=$(tput setaf 3)
	blue=$(tput setaf 4)
	cyan=$(tput setaf 5)
	bold=$(tput bold)
	reset=$(tput sgr0)

	[[ $EUID -eq 0 ]] && user=$red || user=$green

	echo "\[$user\]\u@\h\[$reset\] \[$blue$bold\]$sep\[$reset\] \[$yellow\]\W\[$reset\] \[$blue$bold\]$sep\[$reset\] \[$user\]\$\[$reset\] ")

Gives the user a prompt that looks like this.

jason@Yog-Sothoth » ~ » $

Another simpler one with the prompt on a new line.

PS1="┌─╼ \[\e[0;34m\]\u\[\e[1;35m\]::\[\e[0;34m\]\h \[\e[1;34m\]\w\[\e[0m\]\n──╼ "

Prompt looks like this.

┌─╼ jason::Yog-Sothoth ~
──╼

Both of these are great shell prompts, but it is up to you to decide which one is better for you.


Leave a Comment

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