Results 1 to 3 of 3

Thread: bash prompt string problem

  1. #1

    Default bash prompt string problem

    I am having the following problem with the bash prompt:
    whenever $PS1 is configured to have a color to distinguish it from the typed and response text, e.g.

    > PS1='\e[0;36m\w #\e[ \e[m '

    to make prompt the current path in cyan, the home, arrow, and end keys get all screwed up:
    The home key cannot return the cursor to the first character in the input string, instead stopping at the tenth character.
    The end key places the cursor 10 characters beyond the last character of the input string.
    The arrow keys are similarly fubar

    When the prompt string is the minimal

    > PS1='\w # '

    there is no such problem

    I'm on KDE 4.10.2
    I don't remember having this problem ever before with bash

    Anyone have any ideas why this is happening or is this a bug ?

  2. #2
    Join Date
    Mar 2010
    Location
    Austin - Texas
    Posts
    10,140
    Blog Entries
    48

    Smile Re: bash prompt string problem

    Quote Originally Posted by totalled View Post
    I am having the following problem with the bash prompt:
    whenever $PS1 is configured to have a color to distinguish it from the typed and response text, e.g.

    > PS1='\e[0;36m\w #\e[ \e[m '

    to make prompt the current path in cyan, the home, arrow, and end keys get all screwed up:
    The home key cannot return the cursor to the first character in the input string, instead stopping at the tenth character.
    The end key places the cursor 10 characters beyond the last character of the input string.
    The arrow keys are similarly fubar

    When the prompt string is the minimal

    > PS1='\w # '

    there is no such problem

    I'm on KDE 4.10.2
    I don't remember having this problem ever before with bash

    Anyone have any ideas why this is happening or is this a bug ?
    PS1='prompt_code'; why not use "prompt_code"?

    \e[0;36m = Bold Cyan

    \w # = $HOME as ~ and a #, where "~ #" means you are at home folder.

    You then embed unseen characters?

    \e[ and \e[m

    But what are you trying to use again? You do not set PS2 to anything?

    For anyone that wonders what is going on here, have a look at this link: How to: Change / Setup bash custom prompt (PS1)

    Thank You,
    My Blog: https://forums.opensuse.org/blogs/jdmcdaniel3/

    Software efficiency halves every 18 months, thus compensating for Moore's Law

    Its James again from Austin, Texas

  3. #3
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    25,402

    Default Re: bash prompt string problem

    Quote Originally Posted by totalled View Post
    I am having the following problem with the bash prompt:
    whenever $PS1 is configured to have a color to distinguish it from the typed and response text, e.g.

    > PS1='\e[0;36m\w #\e[ \e[m '

    to make prompt the current path in cyan, the home, arrow, and end keys get all screwed up:
    The home key cannot return the cursor to the first character in the input string, instead stopping at the tenth character.
    The end key places the cursor 10 characters beyond the last character of the input string.
    The arrow keys are similarly fubar

    When the prompt string is the minimal

    > PS1='\w # '

    there is no such problem

    I'm on KDE 4.10.2
    I don't remember having this problem ever before with bash

    Anyone have any ideas why this is happening or is this a bug ?
    Apart from James' remarks, I think your problem description is far from complete. You are adding "escape sequencies" to your prompt in the assumption that something will understand and interprete these escape sequencies. That "something" must be a terminal (or terminal emulator). But you do not even tell which terminal (emulator) and consequently we can not check it's documentation to see what your combinations should do.
    Henk van Velden

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •