Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Terminal input is broken

Hello! Terminal input is broken now. When I try to write some command I often obtain smth like this::

I suppose that it could be because I've changed ~/.bash_profile content to this one:

export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
export PS1='\e[32;1m\u\e[0m@\e[34m\h\e[0m \e[35m\W\e[0m\$ '
export PS2='\e[90m>'

MacBook Pro 15”, macOS 10.13

Posted on Oct 5, 2020 10:31 PM

Reply
Question marked as Best reply

Posted on Oct 7, 2020 7:15 PM

wrap escape sequences in \[...esc seq...\]


The \[ and \] tell bash that these characters do not take up space in the command line.


it gets ugly, but it works.


export PS1='\[\e[32;1m\]\u\[\e[0m\]@\[\e[34m\]\h\[\e[0m\] \[\e[35m\]\W\[\e[0m\]\$ '

export PS2='\[\e[90m\]>\[\e[0m\]'

5 replies

Oct 8, 2020 5:06 PM in response to VikingOSX

VikingOSX wrote:

Are you using the Bash 3.2.57 shell, or Bash 5, considering you are also using GNU CoreUtils too? Your PS1 prompt colors display as shown on Mojave 10.14.6 too, so what is the issue with your custom text coloring?

Does this article help?

Personally, I use the tput command and decimal colors to reduce the complication of using the ANSI escape sequences. That preceding link offers a color chart of decimal color values. The following is in my ~/.bashrc file that is sourced in ~/.bash_profile.

TPUT="/usr/bin/tput"
Bluebld="$(${TPUT} bold; ${TPUT} setaf 63)"
White="$(${TPUT} bold; ${TPUT} setaf 15)"
Green="$(${TPUT} bold; ${TPUT} setaf 42)"
MyHost="$(networksetup -getcomputername)"
export PS1='\[$Bluebld\]$MyHost: \w \[$Green\]$ \[$White\]'

https://discussions.apple.com/content/attachment/7960b3cc-c70d-4dea-bb8e-0c5a3f4c6541


I use Bash 5.0 shell along with GNU CoreUtils. The issue is reproduced when I try to write long command on one line - the text is wrapped and bash prompt is overlapped with it.

Oct 7, 2020 2:47 AM in response to AlvinSeville7cf

Are you using the Bash 3.2.57 shell, or Bash 5, considering you are also using GNU CoreUtils too? Your PS1 prompt colors display as shown on Mojave 10.14.6 too, so what is the issue with your custom text coloring?


Does this article help?


Personally, I use the tput command and decimal colors to reduce the complication of using the ANSI escape sequences. That preceding link offers a color chart of decimal color values. The following is in my ~/.bashrc file that is sourced in ~/.bash_profile.


TPUT="/usr/bin/tput"
Bluebld="$(${TPUT} bold; ${TPUT} setaf 63)"
White="$(${TPUT} bold; ${TPUT} setaf 15)"
Green="$(${TPUT} bold; ${TPUT} setaf 42)"
MyHost="$(networksetup -getcomputername)"
export PS1='\[$Bluebld\]$MyHost: \w \[$Green\]$ \[$White\]'



Terminal input is broken

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.