SpicyClubSauce
SpicyClubSauce

Reputation: 4256

Terminal Prompt line wrapping + some other funky issues

my prompt is not wrapping properly and not moving onto the second line, instead overwriting the first line. There are some other funky behaviors too. Can someone who's got experience with PS1 profiles spot what's wrong here?

once i do emacs .bash_profile, this is the relevant line:

export PS1="\\e[1;34m[\@ \u \W]\$ \e[m\]\]"

I've followed the advice here (https://unix.stackexchange.com/questions/105958/terminal-prompt-not-wrapping-correctly) to close all my brackets on both sides, and also tried this (https://askubuntu.com/questions/24358/how-do-i-get-long-command-lines-to-wrap-to-the-next-line) and made sure I have \\[ preceding everything/my color choice.

Any ideas?

Much appreciated.

Upvotes: 0

Views: 404

Answers (1)

Thomas Dickey
Thomas Dickey

Reputation: 54505

In your example

export PS1="\\e[1;34m[\@ \u \W]\$ \e[m\]\]"

it seems that you meant something like

export PS1="\[\e[1;34m\][\@ \u \W]\$ \[\e[m\]"

The \[ and \] are interpreted by bash to tell it to not count the enclosed characters as part of the line-length. zsh has a similar workaround (see the XTerm manual).

Upvotes: 1

Related Questions