Skip to main content
Became Hot Network Question
edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 267
deleted 18 characters in body
Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

I essentially know what the problems is, in that I need to use \[...\] as a way to escape (non-space?) characters, and allow bash to correctly calculate the width of my prompt.

However, I cannot iron out all the problems and have been using trial and error as I don't quite understand where exactly I need all my \[...\] placed.

STARTCOLOR='\[\e[0;31m\]'
 
ENDCOLOR='\[\e[0m\]'
 
BACKGROUND='\[\e[47m\]'
 
export PS1="$STARTCOLOR$BACKGROUND\u@\h \[\t\]$ENDCOLOR\w>\$?\$\]"

Is what I am using. The only issue now seems if I use the arrow keys to scroll previous commands for too long the \w>\$?\$\ part of my PS1 will disappear. It happens too if I reverse back with arrow keys after moving forward with previous commands.

I essentially know what the problems is, in that I need to use \[...\] as a way to escape (non-space?) characters, and allow bash to correctly calculate the width of my prompt.

However, I cannot iron out all the problems and have been using trial and error as I don't quite understand where exactly I need all my \[...\] placed.

STARTCOLOR='\[\e[0;31m\]'
 
ENDCOLOR='\[\e[0m\]'
 
BACKGROUND='\[\e[47m\]'
 
export PS1="$STARTCOLOR$BACKGROUND\u@\h \[\t\]$ENDCOLOR\w>\$?\$\]"

Is what I am using. The only issue now seems if I use the arrow keys to scroll previous commands for too long the \w>\$?\$\ part of my PS1 will disappear. It happens too if I reverse back with arrow keys after moving forward with previous commands.

I essentially know what the problems is, in that I need to use \[...\] as a way to escape (non-space?) characters, and allow bash to correctly calculate the width of my prompt.

However, I cannot iron out all the problems and have been using trial and error as I don't quite understand where exactly I need all my \[...\] placed.

STARTCOLOR='\[\e[0;31m\]'
ENDCOLOR='\[\e[0m\]'
BACKGROUND='\[\e[47m\]'
export PS1="$STARTCOLOR$BACKGROUND\u@\h \[\t\]$ENDCOLOR\w>\$?\$\]"

Is what I am using. The only issue now seems if I use the arrow keys to scroll previous commands for too long the \w>\$?\$\ part of my PS1 will disappear. It happens too if I reverse back with arrow keys after moving forward with previous commands.

Source Link
Gee_k
  • 27
  • 6

Cannot get .bashrc PS1 configuration to render without issues

I essentially know what the problems is, in that I need to use \[...\] as a way to escape (non-space?) characters, and allow bash to correctly calculate the width of my prompt.

However, I cannot iron out all the problems and have been using trial and error as I don't quite understand where exactly I need all my \[...\] placed.

STARTCOLOR='\[\e[0;31m\]'

ENDCOLOR='\[\e[0m\]'

BACKGROUND='\[\e[47m\]'

export PS1="$STARTCOLOR$BACKGROUND\u@\h \[\t\]$ENDCOLOR\w>\$?\$\]"

Is what I am using. The only issue now seems if I use the arrow keys to scroll previous commands for too long the \w>\$?\$\ part of my PS1 will disappear. It happens too if I reverse back with arrow keys after moving forward with previous commands.