This bash prompt is a very good example of a multi-line prompt. This would be very useful to have on a Linux system.
# Define colors using ANSI escape sequences RED="\[\033[0;31m\]" GREEN="\[\033[0;32m\]" YELLOW="\[\033[0;33m\]" BLUE="\[\033[0;37m\]" MAGENTA="\[\033[0;35m\]" CYAN="\[\033[0;36m\]" BOLD_RED="\[\033[01;31m\]" BOLD_GREEN="\[\033[01;32m\]" RESET_COLOR="\[\e[m\]" random_color() { local colors=('31' '32' '33' '34' '35' '36' '91' '92' '93' '94' '95' '96') local random_index=$((RANDOM % ${#colors[@]})) echo -e "\e[${colors[$random_index]}m" } # Set up the new stylish PS1 prompt PS1="┏${BOLD_GREEN}\u${RESET_COLOR}@${BOLD_RED}\h${RESET_COLOR}┋ ${YELLOW}\w━━┓\n┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛${BLUE}[$(date +%H:%M)]${RESET_COLOR} ${random_color}▓▒░$(if [ $EUID -eq 0 ]; then echo "#"; else echo "┋"; fi) ${RESET_COLOR}" |
This prompt displays the following information in various colors:
- Bold green username,
- Bold red hostname,
- Yellow working directory on a separate line,
- Blue timestamp in HH:MM format, and
- A cyan dollar sign (or ‘#’ for root) followed by a space before typed commands.
To use this custom prompt, add these lines to your ~/.bashrc or ~/.bash_profile file then restart your terminal or run source ~/.bashrc (or source ~/.bash_profile) to apply changes immediately.
This is what this prompt will look like. Using DOS line-drawing characters makes for a very functional and attractive Linux terminal.
┏jcartwright@localhost┋ ~━━┓ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛[12:12] ▓▒░┋
To have a Linux shell prompt that looks just like a DOS prompt, this PS1 will work.
PS1='\[\033[1;32m\]\u@\h:\w>\[\033[0m\] ' |
This configuration sets the username (\u
), hostname (\h
), current working directory (\w
), and uses green color for the text (\[\033[1;32m\]
). The prompt ends with a >
character. The \[\033[0m\]
resets the color to the default.
This is what it looks like.
jcartwright@localhost:~>