4

I have a custom $PS1 variable that looks like this on my command line: enter image description here

And on emacs using M-x shell unfortunately looks like this: enter image description here

Here is my $PS1 variable export PS1='\[\e]0;\u@\h: \w\a\]\[\e[0;36m\]\T \[\e[1;30m\]\[\e[0;34m\]\u@\H\[\e[1;30m\] \[\e[0;32m\]\[\e[1;37m\]\w\[\e[0;37m\] \$ '

How can I make emacs shell-mode look the same with my CLI variable?

2 Answers 2

5

Leave the set title part to the terminals that support it:

case $TERM in
  (xterm*) set_title='\[\e]0;\u@\h: \w\a\]';;
  (*) set_title=
esac
PS1=$set_title'\[\e[0;36m\]\T \[\e[1;30m\]\[\e[0;34m\]\u@\H\[\e[1;30m\] \[\e[0;32m\]\[\e[1;37m\]\w\[\e[0;37m\] \$ '
3
  • Your answer worked fine but when I go to shell mode everytime I use a command the previous name information and time are lost. Sep 1, 2013 at 14:10
  • 1
    Not sure what you mean, but in your prompt, you set the text colour to white, which may explain why you can't see things. Sep 1, 2013 at 14:15
  • Ok fixed just changed the colours. It was that the ubuntu CLI background is purple and my output was white. But on emacs the background was already white so I couldn't see a thing. Sep 1, 2013 at 14:29
1

You have some commands in your PS1 that set the title of the terminal window. These are confusing the emacs shell. Changing your PS1 to this should work:

export PS1='\[\e[0;36m\]\T \[\e[0;34m\]\u@\H \[\e[1;37m\]\w\[\e[0;37m\] \$ '
2
  • The \e]0;....\a part sets the Window and icon title in xterm-like terminals. Sep 1, 2013 at 14:07
  • @StephaneChazelas yes, I just understood that from your answer, thanks.
    – terdon on strike
    Sep 1, 2013 at 14:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .