Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a simple custom bash prompt:

PS1="\[\e[47;1;30m\]\u@\h [\W] \!\[\e[0;32m\]$\[\e[0m\]"

It worked great under Snow Leopard, and worked great in Lion until I installed Xcode. I installed Xcode 3 (without System Tools or Unix Development) and then Xcode 4.1.1.

Now, the caret starts in the middle of the prompt.

And, bash fails completely at line wrapping.

enter image description here

If I remove \[ and \], the caret starts in the right place but line wrapping doesn't happen at all.

Worse, man is broken:

WARNING: terminal is not fully functional
-  (press RETURN)

What happened to my terminal when I installed Xcode? Does anyone have any ideas on how to make this better?


In response to Turadg’s answer: diff reports that these directories were missing from my terminfo folder, but present in that of a fresh Lion install (all the others were identical):

31, 32, 33, 34, 35, 36, 37, 38, 39, 4c, 4d, 4e, 50, 51, 58, 66, 6a, 7a

share|improve this question
    
Did export TERM=xterm fix this problem for you Sid? –  chown Sep 9 '11 at 22:50
    
Hey, @chown. See my comment on your answer. –  Sidnicious Sep 13 '11 at 17:22

3 Answers 3

up vote 2 down vote accepted

I encountered the same problem after installing Xcode 4.1. It appears to have replaced /usr/share/terminfo and left out the descriptor for xterm-256color, the default for Lion terminals.

You can verify this this is the case on your system with: infocmp xterm-256color

That should return a descriptor. If it doesn't, it's missing from /usr/share/terminfo/78.

One way to get back to a working terminal is to set "TERM=xterm-color", but then you lose the expanded features of xterm-256color. What I did was restore /usr/share/terminfo from a backup (thanks Time Machine). If you don't have a backup, you can copy it from another machine. For more details, see these example commands.

share|improve this answer
    
Looks like this is it. A number of directories were missing from my /usr/share/terminfo but present on a fresh install of Lion. Now I just wonder, what’s going on here? –  Sidnicious Sep 26 '11 at 2:34

Install iTerm2, and the first thing it did upon being launched was to advise me that the configuration for xterm-256colors was missing, and offered to install it. This repaired the terminal display problems (which is now virtually a moot point as iTerm2 is outstanding).

share|improve this answer
    
Of all the other answers, this was the only one that worked. Simple, flawless, painless. Thank you, this was driving me nuts. –  Christos Sotiriou Mar 2 '12 at 15:17
    
There should probably be a more straight forward answer to this problem, but this was easy and worked flawlessly. –  BlueVoid Jul 16 '12 at 17:25

In ~/.bashrc or /etc/bashrc put:

export TERM=xterm
## or export TERM=xterm-color

Then type:

source ~/.bashrc

or

source /etc/bashrc

If you have both files, put it in your ~/.bashrc and source the one in your ~.

This same exact thing happened to me yesterday when I uninstalled and reinstalled Xcode/developer-tools and it seems that the env variable TERM got changed to "xterm-256color" which has quite a diff from xterm-color:

[ 09:32 root@MacBook-Air ~ ]# infocmp -I xterm-256color > ~/xterm-256color.src
[ 09:32 root@MacBook-Air ~ ]# infocmp -I xterm-color > ~/xterm-color.src
[ 09:33 root@MacBook-Air ~ ]# diff xterm-color.src xterm-256color.src
1,4c1,4
< # Reconstructed via infocmp from file: /opt/local/share/terminfo/78/xterm-color
< xterm-color|xterm terminal emulator (X Window System),
<   am, bce, xenl, km, mir, msgr, npc, mc5i,
<   cols#80, it#8, lines#24, colors#8, pairs#64,
---
> # Reconstructed via infocmp from file: /opt/local/share/terminfo/78/xterm-256color
> xterm-256color|xterm with 256 colors,
>   am, bce, ccc, xenl, km, mir, msgr, npc, mc5i,
>   cols#80, it#8, lines#24, colors#256, pairs#32767,
12,15c12,17
<   smir=\E[4h, rev=\E[7m, invis=\E[8m, smso=\E[7m, smul=\E[4m,
<   ech=\E[%p1%dX, rmacs=\E(B, rmam=\E[?7l, sgr0=\E(B\E[m,
<   rmir=\E[4l, rmso=\E[27m, rmul=\E[24m,
<   flash=\E[?5h$<100/>\E[?5l, is2=\E[!p\E[?3;4l\E[4l\E>,
---
>   smcup=\E[?1049h, smir=\E[4h, rev=\E[7m, invis=\E[8m,
>   smso=\E[7m, smul=\E[4m, ech=\E[%p1%dX, rmacs=\E(B,
>   rmam=\E[?7l, sgr0=\E(B\E[m, rmcup=\E[?1049l, rmir=\E[4l,
>   rmso=\E[27m, rmul=\E[24m, flash=\E[?5h$<100/>\E[?5l,
>   is2=\E[!p\E[?3;4l\E[4l\E>,
>   initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
39,45c41,49
<   smkx=\E[?1h\E=, rmm=\E[?1034l, smm=\E[?1034h,
<   op=\E[39;49m, dch=\E[%p1%dP, dl=\E[%p1%dM, cud=\E[%p1%dB,
<   ich=\E[%p1%d@, indn=\E[%p1%dS, il=\E[%p1%dL,
<   cub=\E[%p1%dD, cuf=\E[%p1%dC, rin=\E[%p1%dT,
<   cuu=\E[%p1%dA, mc0=\E[i, mc4=\E[4i, mc5=\E[5i, rs1=\Ec,
<   rs2=\E[!p\E[?3;4l\E[4l\E>, rc=\E8, vpa=\E[%i%p1%dd,
<   sc=\E7, ind=^J, ri=\EM, setab=\E[4%p1%dm, setaf=\E[3%p1%dm,
---
>   smkx=\E[?1h\E=, meml=\El, memu=\Em, rmm=\E[?1034l,
>   smm=\E[?1034h, op=\E[39;49m, dch=\E[%p1%dP, dl=\E[%p1%dM,
>   cud=\E[%p1%dB, ich=\E[%p1%d@, indn=\E[%p1%dS,
>   il=\E[%p1%dL, cub=\E[%p1%dD, cuf=\E[%p1%dC,
>   rin=\E[%p1%dT, cuu=\E[%p1%dA, mc0=\E[i, mc4=\E[4i,
>   mc5=\E[5i, rs1=\Ec, rs2=\E[!p\E[?3;4l\E[4l\E>, rc=\E8,
>   vpa=\E[%i%p1%dd, sc=\E7, ind=^J, ri=\EM,
>   setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
>   setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
47,48d50
<   setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
<   setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
share|improve this answer
    
This should be a comment, not an answer. –  Sean W. Sep 3 '11 at 16:10
    
Thanks, @chown, but I don't think this is the right solution. TERM gets set by Terminal itself based on your preferences (you set it on a per-configuration basis in the settings tab), so you should never need to override it. Also, Lion uses xterm-256color by default, which works fine on an out-of-box computer. –  Sidnicious Sep 13 '11 at 17:21
    
Maybe the configuration got changed for the xterm-256color when xCode was installed. I'll look into some more. Btw, I just found out about iTerm, so superior to Terminal! I would highly recommend it. –  chown Sep 13 '11 at 19:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.