0

I have modified my MacOS terminal by introducing a .bash_profile and .bashRC. When typing commands into the terminal and it goes to a new line, if I then backspace/delete the input I entered it will delete all content but the first line will leave some characters displayed. They will be deleted apparently, (if I press enter or type something new its as if those stray undeleted characters aren't present in the input) but still display and the cursor cannot reach back to them. The cursor will be a few spaces ahead of the undeleted characters. Is there any issue with the .bashRC file/ does anyone know what's going on here?

.bash_profile

if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi

.bashRC

PS1='\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
export PS1;

alias ls='ls -G'
alias grep='grep --color=auto'

Screenshots

Entering input that trails to next line:

Doing same command but deleting all of it after typing. As far back as cursor goes:

Hitting enter acts as if nothing typed at all:

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • The `ENV` variables in your `.bashrc` should be in `.bash_profile`... – l'L'l Feb 14 '19 at 17:13
  • 3
    It looks like your `PS1` misses a `\[` at the beginning to wrap the non-printing sequence. – Benjamin W. Feb 14 '19 at 17:34
  • @BenjaminW. probably has the answer. This symptom is typical for missing `\[ ... \]` markers around nonprinting characters. – tripleee Feb 14 '19 at 17:52
  • 1
    Voting to close as a typo, since `\[` was correctly inserted everywhere else. – chepner Feb 14 '19 at 18:07
  • 1
    `PS1` shouldn't be exported; there is no standard for what escape characters can be included, so it's definition is almost always specific to a shell. Leave it as an ordinary shell variable in the appropriate interactive-shell configuration file (like `.bashrc`). – chepner Feb 14 '19 at 18:08

0 Answers0