Show your PS1 (the bash prompt gallery)


Lets see if a PS1 thread might be as successful as the Show your Desktop threads.

I’ll start with mine - it’s not that flashy but it helps me lots to keep a good overview of where I am and further more “whoami”!

PS1='\[$(tput bold)\]\u\[$(tput sgr0)\]@\h:\[$(tput sgr0)\]\[\033[38;5;33m\][\[$(tput sgr0)\]\[\033[38;5;39m\]\w\[$(tput sgr0)\]\[\033[38;5;33m\]]\[$(tput sgr0)\]\[\033[38;5;15m\]\\$ \[$(tput sgr0)\]'

PS1='\[$(tput bold)\]\[\033[38;5;1m\]\u\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;11m\]@\h:\[$(tput sgr0)\]\[\033[38;5;33m\][\[$(tput sgr0)\]\[\033[38;5;39m\]\w\[$(tput sgr0)\]\[\033[38;5;33m\]]\[$(tput sgr0)\]\[\033[38;5;15m\]\\$ \[$(tput sgr0)\]'

How to change init terminal colors
[SOLVED] Changing color in terminal
Urxvt color problem

PROMPT_COMMAND=__prompt_command # Func to gen PS1 after CMDs

__prompt_command() {
    local EXIT="$?"             # This needs to be first

    local RCol='\[\e[0m\]' 	# Right color

    local Red='\[\e[0;31m\]'
    local Gre='\[\e[0;32m\]'
    local BYel='\[\e[1;33m\]'
    local BBlu='\[\e[1;34m\]'
    local Pur='\[\e[0;35m\]'
    # Prompt prefix
    PS1="${BBlu}\w${BYel}$(parse_git_branch)${RCol} "

    if [ $EXIT != 0 ]; then
        PS1+="${Red}${EXIT}${RCol} $ ${RCol}"      # Add red if exit code non 0
        PS1+="$ ${RCol}"

#git branch display
parse_git_branch() {
     git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | sed -e 's/master/M/g'


i install a “big” font
configure my terminal (tilix) with this font

Add one function in ~/.bashrc

        declare MANJARO='\uf312'      # logo manjaro par defaut
        [[ "$(pwd)" =~ "/workspace" ]] && MANJARO='\ue70c'      
        [[ "$(pwd)" =~ "/www" ]] && MANJARO='\uf81e'
        [[ "$(pwd)" =~ "/C++" ]] && MANJARO='\ufb71'
        [[ "$(pwd)" =~ "/bash" ]] && MANJARO='\uf489'
        [[ "$(pwd)" =~ "/etc" ]] && MANJARO='\uf425'
        [[ "$(pwd)" == "/home/$(whoami)" ]] && MANJARO='\uf46d'
        [[ "$(pwd)" =~ "/Images" ]] && MANJARO='\ue60d'
        echo -en "\n${MANJARO}"

small change original second PS1 : \$ by \$(last_char)

export PS1="\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$(last_char)\[\033[00m\] "

result (manjaro by default):



When I get bored I love playing with stuff like this. So, I redid my PS1 today. I must say I like the result of my fiddling around.

	if [[ ${EUID} == 0 ]] ; then
		PS1='\[\033[01;31m\] \u@\h\[\033[0;33m\] \w\[\033[01;31m\]] \[\033[00m\] \n\$ '
		PS1='\[\033[01;32m\] \u@\h\[\033[01;34m\] \w\[\033[38;5;33m\] \[\033[38;5;33m\]\n\$ '


I’d really would not like this thread to die - arn’t you folks cusomizing your bash/zsh/… prompts?


I was kind of surprised at the lack of response as well. I thought more people would like to share their prompts. Kind of a shame because I’m sure there’s some great examples out there.


ok, a new
with bash functions , we can add all infos

  • Number of files in curent directory

in .bashrc

prompt_get_nb_files() {
    nb=$(ls -AGU --width=1 | wc -l)
    ((nb>0)) && echo -n " ($nb)"

in PS1, only call function \$(prompt_get_nb_files)

result (55 files in my directory):

cd ~/.local/bin/
[patrick@MyMachine ~/.local/bin] (55)

  • or memory used :
prompt_mem() {
    echo -n " ($(free -h | awk '/^Mem/ {print $3"/"$2}'))"

[patrick@MyMachine ~] (194) (1,3Gi/5,7Gi)


Here is mine :upside_down_face:


PS1=’[\033[01;32m]|[\033[01;37m]\t[\033[01;32m]| [\033[01;37m]\u[\033[01;32m]:[\033[01;37m]\h [\033[01;32m]|[\033[01;33m]\w[\033[01;32m]| $[\033[00m] ’
(sorry, I don’t know how to make it shorter…)


I also have a pretty long string in the PS1 variable but I added a Return almost at the end, just before the $ sign, which will then be placed on the next line. This to start commands from the left side of the terminal instead of somewhere in the middle.


Yes, I do the same thing. I prefer the entire path be shown and I have a lot of nested folders, so want my prompt to start on the next line as well.


zsh for me:



It looks nice @xircon, but how about including the code for generating your PS1.



Do not ask for code, can not remember, I am old :disappointed_relieved:

Who am I??? :wink:

Maybe ;-)
# Change the window title of X terminals
case ${TERM} in
		PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\007"'
		PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/\~}\033\\"'


# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.  Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
[[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs}    ]] \
	&& type -P dircolors >/dev/null \
	&& match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
	# Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
	if type -P dircolors >/dev/null ; then
		if [[ -f ~/.dir_colors ]] ; then
			eval $(dircolors -b ~/.dir_colors)
		elif [[ -f /etc/DIR_COLORS ]] ; then
			eval $(dircolors -b /etc/DIR_COLORS)

	if [[ ${EUID} == 0 ]] ; then
		PS1='\[\033[01;31m\][\h\[\033[01;36m\] \W\[\033[01;31m\]]\$\[\033[00m\] '
		PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]\$\[\033[00m\] '

	alias ls='ls --color=auto'
	alias grep='grep --colour=auto'
	alias egrep='egrep --colour=auto'
	alias fgrep='fgrep --colour=auto'
	if [[ ${EUID} == 0 ]] ; then
		# show root@ when we don't have colors
		PS1='\u@\h \W \$ '
		PS1='\u@\h \w \$ '


The code for that should (normaly) be in .bashrc file located in the users home direcotry under PS1="…" =)


Oops - it is spaceship with some colour changes :smiley:


This caught my eye so I decided to try your little setup.
Glad I took the time. :+1:


git users, for a few days we have gitprompt-rs in repos