PS1 is a primary prompt variable. This variable displays a default structure to the user that makes a login

Standard ubuntu

The standard ubuntu PS1 variable looks like:

alberto@alberto-5490:~$

# standard
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
# colored mode
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Test

To test your settings export the PS1 variable with your settings:

export PS1='<my_settings>'

Make it permanent

To make your settings permanent edit your .bashrc file, locate the PS1 variable, and edit properly.

Here my personal shell

if [ "$color_prompt" = yes ]; then
    #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='\[\e[0;32m\]\u\[\e[0;32m\]@\[\e[0;32m\]\H\[\e[0m\]:\[\e[0m\]\w\[\e[0;93m\]$(git branch 2>/dev/null | grep '"'"'^*'"'"' | colrm 1 1) \[\e[0m\]$ \[\e[0m\]'
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

Bash prompt generator

Here a beautiful website that could helps you in your shell personalization

https://scriptim.github.io/bash-prompt-generator/

Categories: Bash

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.