Color Bash Prompt on Ubuntu and Debian

Ubuntu

Green Prompt for your user

Edit ”~/.bashrc” and change:

#force_color_prompt=yes

to:

force_color_prompt=yes

To change it for all new users make the same in ”/etc/skel/.bashrc”.

Red Prompt for root

Edit ”/root/.bashrc” and change ”force_color_prompt=yes” like for your user.

Now change the color to red. Search this line:

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

and change it to:

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

Note: For this change to take effect, you must log out then log in again.

Debian (older versions)

Green Prompt for your user

Open ”~/.bashrc” and append:

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

Red Prompt for root

Edit ”/root/.bashrc” and append:

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

Other colors

Color	Code
Black	30
Blue	34
Green	32
Cyan	36
Red	31
Purple	35
Brown	33
Blue	34
Green	32
Cyan	36
Red	31
Purple	35
Brown	33

This Post Has 2 Comments

  1. You don’t need to log out and in again to see changes. Just `source ~/.bashrc’.

Schreibe einen Kommentar

eMail-Benachrichtigung bei weiteren Kommentaren.
Auch möglich: Abo ohne Kommentar.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.