jueves, 14 de julio de 2022

Colorize BASH Prompt

Let's colorize the BASH prompt.

This was my original prompt... so sad!!

eze@LinuxServer:~$ 

And the culprit:

PS1='\u@\h:\w\$ '

Where:

PS1=' <-- This means "Primary Prompt"
\u    <-- Username
@\    <-- @
h:\   <-- Hostname and Colon
w\    <-- Tilde
$ '   <-- Dollar sign with a blank space

So, let's put some joy to it.

PS1='
\033[1;31m\]\u\    <-- Red username
[\033[1;37m\]@\    <-- Strong white @
[\033[1;36m\]\h\   <-- Cian hostname
[\033[1;37m\]:\    <-- Strong white Colon
[\033[1;34m\]\w\   <-- Blue tilde
[\033[0;37m\]\$ '  <-- Soft white money money (dollar sign) with the respective blank space

This is the result:

eze@LinuxServer:~

Yep, that's better.

The PS line would look like this:

PS1='\033[1;31m\]\u\[\033[1;37m\]@\[\033[1;36m\]\h\[\033[1;37m\]:\[\033[1;34m\]\w\[\033[0;37m\]\$ '

And because this is an Ubuntu server, the actual PS line looks like this:

PS1='${debian_chroot:+($debian_chroot)}\[\033[1;31m\]\u\[\033[1;37m\]@\[\033[1;36m\]\h\[\033[1;37m\]:\[\033[1;34m\]\w\[\033[0;37m\]\$ '

Here's an example:

eze@LinuxServer:~/Scripts

So, you want more colors?
Here are a few links to pages I used to tune up my BASH prompt.


Cheers!!

No hay comentarios.:

Publicar un comentario