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

  • SEARCH
  • Home
  • 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 175209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:39:31+00:00 2026-05-11T13:39:31+00:00

I admit that I use a somewhat long-winded bash prompt: –(username)-(Wed April 01|12:00:00)–(~ $

  • 0

I admit that I use a somewhat long-winded bash prompt:

--(username)-(Wed April 01|12:00:00)--(~ $

Recently, I got the bright idea to change it so that depending on the exit value from the previous command, if success, the interior elements of the ()’s would be green, and if failure, they would be red. I got it working for the most part (some odd exit statuses will change the color to something else, but I’m ok with it), but when typing a command which is more than one line, and causes the terminal to scroll, the prompt disappears! My prompt worked fine when there was no color, so I’m guessing it is related to my color escaping, and particularly my unclosed [‘s, but I can’t pin it down.

#.profile export PS1='--(\e[$((32-${?}))m\u\e[0m)-(\e[$((32-${?}))m\d\e[0m|\e[$((32-${?}))m\T\e[0m)--(\e[$((32-${?}))m\w\e[0m \$ '

Thanks in advance!

  • 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. 2026-05-11T13:39:31+00:00Added an answer on May 11, 2026 at 1:39 pm

    It sounds like this should solve your problem.

    This seems to work for me*:

    export PS1='--(\[\e[$((32-${?}))m\]\u\[\e[0m\])-(\[\e[$((32-${?}))m\]\d\[\e[0m\]|\[\e[$((32-${?}))m\]\T\[\e[0m\])--(\[\e[$((32-${?}))m\]\w\[\e[0m\] \$ ' 

    * well, really export PS1='\u@\h:\w\$ ' works for me

    To quote the linked post, the answer lies in adding \[ and \] around all of your color sequences in your PS1 declaration:

    Before I had the following value for PS1:

    ‘\e[0;34m\h:\w [!]\$\e[0m ‘

    which gave me a nice blue prompt of the following form

    hostname:working-directory [command-number]$

    However, I had the same line-wrapping problem you did. The fix was to insert \[ and \] around the ANSI escapes so that the shell knows not to include them in the line wrapping calculation. This results in the following value for PS1:

    ‘\[\e[0;34m\]\h:\w [!]\$\[\e[m\] ‘

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

Sidebar

Related Questions

I've got a locally installed MySQL database server that I want to use for
I have two models User and Admin(with RailsAdmin) that use Devise. I sign in
I've notice django admin UI does not allow use name with characters that are
I admit that I have almost none experience of unittesting. I did a try
I must admit that I am incredibly jealous of those developers who happen to
I will openly admit that I fall on the side of Test Driven Development.
I have to admit that I'm new to Java and Android. db4o seems to
I must admit that I don't really know if this is the right place
I am fully prepared to admit that I am missing something simple here. I
I would first like to admit that I am an extremely novice developer, so

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.