Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8046311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:45:08+00:00 2026-06-05T05:45:08+00:00

I found a good customization to my .bashrc for my prompt to show extra

  • 0

I found a good customization to my .bashrc for my prompt to show extra information and provide color highlighting. Here’s what I have:

# ----- Define a few Colors
BLACK='\e[0;30m'
BLUE='\e[0;34m'
GREEN='\e[0;32m'
CYAN='\e[0;36m'
RED='\e[0;31m'
PURPLE='\e[0;35m'
BROWN='\e[0;33m'
LIGHTGRAY='\e[0;37m'
DARKGRAY='\e[1;30m'
LIGHTBLUE='\e[1;34m'
LIGHTGREEN='\e[1;32m'
LIGHTCYAN='\e[1;36m'
LIGHTRED='\e[1;31m'
LIGHTPURPLE='\e[1;35m'
YELLOW='\e[1;33m'
WHITE='\e[1;37m'

function __setprompt {
  local SSH_IP=`echo $SSH_CLIENT | awk '{ print $1 }'`
  local SSH2_IP=`echo $SSH2_CLIENT | awk '{ print $1 }'`
  if [ $SSH2_IP ] || [ $SSH_IP ] ; then
    local SSH_FLAG="@\h"
  fi
  PS1="$CYAN[\u$SSH_FLAG:$BROWN\w$CYAN]\\$ $NOCOLOR"
  PS2="$CYAN>$NOCOLOR "
  PS4='$CYAN+$NOCOLOR '
}
__setprompt

The issue I’m running into is that it doesn’t handle wrapping text correctly (see below screenshot). Can anyone offer any advice on what the problem might be? It looks like it doesn’t adjust at all what is typed in by the user.

Command prompt example

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:45:09+00:00Added an answer on June 5, 2026 at 5:45 am

    what’s the value of CYAN BROWN NOCOLOR vars ?
    You most problably forgot to wrap them in \[ and \],
    to mark them as non-printing characters.

    if your CYAN is

    CYAN="\e[0;36m"
    

    you need to wrap it in \[ and \], like

    CYAN="\[\e[0;36m\]"
    

    otherwise, wrap the vars themselves in the prompt variables, like

    PS2="\[$CYAN\]>\[$NOCOLOR\] "
    

    see the comments here:

    function __setprompt {
      local SSH_IP="${SSH_CLIENT%% *}"      # no need for echo/awk/sed
      local SSH2_IP="${SSH2_CLIENT%% *}"    # use parameter expansion instead
      if [[ -n "$SSH2_IP" || -n "$SSH_IP" ]]; then  # bash uses double brakets
        local SSH_FLAG="@\h"                        # and the OR operator works inside
      fi
      PS1="\[$CYAN\][\u$SSH_FLAG:\[$BROWN\]\w\[$CYAN\]]\\$ \[$NOCOLOR\]"  # dont mess with [ and ]
      PS2="\[$CYAN\]>\[$NOCOLOR\] "                                       # only wrap color vars in \[ and \]
      PS4="\[$CYAN\]+\[$NOCOLOR\] "                 # single quotes will not expand $vars
    }
    __setprompt
    

    also, have a look at PROMPT_COMMAND variable,

    PROMPT_COMMAND
    If set, the value is executed as a command prior to issuing each primary prompt.

    and also note that by convension capital variable names are kept to be used by the environment

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found quite good stuff here . If you know other sites that
Long time lurker, first time poster. I have found some good answers on here
Please provide detailed steps to setup IIS6 could not found good information by googling...
I've searched and found a good discussion here on SO , but it is
I've searched the Internet and have found some good solutions for teeing STDOUT to
Did some searches here & on the 'net and haven't found a good answer
I have never found good answers to these simple questions about helper/utility classes: Why
I found a good solution for a reusable select view here: select dropdown with
I found some good resources for rotating a bitmap in android here and elsewher
What have you guys found to good approaches to developing web applications? For example,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.