Question

^[[1m and More When Shelling Out in emacs

Asked by: KenHadley

I am using Emacs 23, puttying (with Xming) through SSH to a Ubuntu 8.10 VMWare machine from Windows Vista.

All display characters look fine, both in Emacs and in the native Bash shell. When, however, I enter M-x shell within Emacs in the Putty/Xming connection, my PS1 prompt is:

 ^[[1m^[[41m^[[37mSat May 30 user ~ ^[[0m

(A similar thing happens when I run a Python interpreter session within the same Emacs configuration.)

Have looked all around for Putty, Emacs 23 encoding, etc. help, but am stuck.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-05-30 at 08:33:02ID24450522
Topics

Emacs

,

SSH / Telnet Software

,

Linux

,

Microsoft Windows Operating Systems

Participating Experts
5
Points
500
Comments
13

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. color coding in emacs
    Hi, I don't know if this is the correct forum to ask this question but hopefully someone will tell me otherwise. What I need to know is if there is any way to have emacs using color coding when i run it in a terminal window. I usually run emacs in my terminal window (putty o...
  2. File from Windows Vista into Ubuntu
    I have a file on my Vista desktop on want to copy onto Ubuntu running in Parallels on the same laptop. I tried to copy/paste -- no go I tried to copy through a USB drive, but Ubuntu running in Parallels does not display the drive.
  3. how to transfer file from windows vista to vmware running…
    i hve vmware installed on windows vista machine. how to transfer file from windows vista to vmware running redhat linux using ftp or ssh?. i mean do i need to configure something before doing ftp or ssh? is it possible to transfer thru network and mounting, if yes then pleas...
  4. python Ubuntu
    Hi Guys, I am a C++/C# Programmer, am newbie to ubunut and have no idea about python I have a python script to run on ubuntu, i user@PC1:~/mapnik$ ./z0_generate_tile1s.py I got this Error /mapnik$ ./z0_generate_tile1s.py ./z0_generate_tile1s.py: line 1: /administrator/bin/py...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Let_Me_BePosted on 2009-05-31 at 02:54:55ID: 24512013

Those are collor escape codes. For some reason Emacs does not seem to understand them. Switching to a black and white prompt would solve your problem.

 

by: oklitPosted on 2009-05-31 at 02:55:43ID: 24512016

Is your PS1 variable set to be bold, with white text on red background? Change it to contain no colors (control codes) at all.

 

by: KeremEPosted on 2009-05-31 at 02:58:35ID: 24512023

Hi,

Will you try to set your TERM varibale? such as:

export TERM=linux

and try to run emacs after setting the shell variable.

Cheers,
K.

 

by: KeremEPosted on 2009-05-31 at 02:59:25ID: 24512025

May be you'd likte to see what it is set in your environment. Please execute env and post the output here.

 

by: ahoffmannPosted on 2009-05-31 at 07:42:22ID: 24512774

which TERM environment variable have you set in your (remote) shell?
which putty settings do you have for Windows->Colours?

 

by: KenHadleyPosted on 2009-05-31 at 11:11:39ID: 24513350

I have pasted in my env below. I understand now that the codes are color escape codes and, yes, my prompt is white on red. Removing the color does indeed remove the escape codes from the Emacs shell window.

If you are saying I cannot have a colorized prompt without having the escape codes appear in an Emacs shell window, I can remove the color permanently, but I am unclear as to why the Emacs shell window would not understand and handle it like my BASH shell does.

Many thanks,

TERM=xterm
SHELL=/bin/bash
XDG_SESSION_COOKIE=3b72570aa705097c7f5e7777490a2956-1243703209.726674-1567315895
SSH_CLIENT=192.168.1.102 4495 22
SSH_TTY=/dev/pts/2
USER=user
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.svgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:
MAIL=/var/mail/user
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PWD=/home/user
LANG=en_US.UTF-8
HISTCONTROL=ignoreboth
SHLVL=1
HOME=/home/user
LOGNAME=user
SSH_CONNECTION=192.168.1.102 4495 192.168.1.105 22
LESSOPEN=| /usr/bin/lesspipe %s
DISPLAY=localhost:11.0
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env
OLDPWD=/usr/lib/python2.5/site-packages/scapy

 

by: oklitPosted on 2009-05-31 at 14:34:07ID: 24514060

 

by: KeremEPosted on 2009-05-31 at 14:40:45ID: 24514080

Hi,

The  reason is simple. You have created the red on white backgroud effect using the Escape sequences for a terminal type. But Xterm and Vi have different databases to query the terminal capabilties and they don't match.

You would either set your terminal  type to xterm-color (export TERM=xtaer-color)
or
you would prevent vi to use escape sequences. (export LESS="-X" in tyour .bash_profile)

Cheers,
K.

 

by: KenHadleyPosted on 2009-05-31 at 14:41:00ID: 31586960

Perfect. Thanks so much. Never thought to google using ANSI and color keywords for what looked like gibberish to me in the shell window.

 

by: KeremEPosted on 2009-05-31 at 14:41:12ID: 24514083

Opps sorry TERM=xtaer-color should read TERM=xterm-color

 

by: duncan_roePosted on 2009-05-31 at 14:54:10ID: 24514130

It's not actually bash that understands the colours. The interpretation of these colours is done by the actual program that is writing to the terminal - putty in your case. This seems to work OK for you in bash - perhaps putty does an xterm emulation or maybe xterm is near enough  to whatever actual terminal putty does emulate - vt320 or whatever.
The escape sequence is usually set by your .bashrc when it defines PS1 (the prompt string). In doing so, .bashrc may take some cognizance of the setting of TERM or it may not. On the other hand, putty may change its emulation behaviour as TERM changes (I really don't know if it does, but technically it could).
Now to your question : "I am unclear as to why the Emacs shell window would not understand and handle it like my BASH shell does". So am I - we need to do some more digging to find out what's happening here. When in a mis-behaving shell, can you please try the following an post results:

echo $TERM
echo $PS1
echo $0
stty -a


(PS1 didn't show up iwith the env command because it's not in the environment. Bash sets it per session. You can see such variables from the "set" command (which also re-displays env)).
Also your prompt may not work if emacs starts some shell other than bash. That's why I asked to see $0.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...