Unix Bash Coloured Prompts

| Posted by watashii | Filed under Unix

To display coloured prompts upon user login (on Unix Bash shell, PuTTY client), perform the following modifications:

  1. Unix login and open the user’s profile in the home directory, eg /home/username/.profile
  2. In the .profile, add the following entry in a new line to execute the bash shell upon login, eg /usr/bin/bash
  3. The bash shell will refer to a .bashrc file.  If its not there, create it,  eg /home/username/.bashrc
  4. Add following entries in the .bashrc to enable the coloured prompt; showing the username, hostname and working directory:
    # Colored Prompts
    STARTGREEN='\[\e[0;32m\]';
    STARTBLUE='\[\e[1;34m\]';
    ENDCOLOR="\[\e[0m\]";
    PS1="$STARTGREEN\u@\h$ENDCOLOR:$STARTBLUE\w$ENDCOLOR $ ";

Tags: , , , ,