unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* On prompt in shell mode
@ 2008-08-12 14:05 Angelo Graziosi
  2008-08-12 14:10 ` adg
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Angelo Graziosi @ 2008-08-12 14:05 UTC (permalink / raw)
  To: emacs-devel

The following regards Emacs (trunk) both on Linux and Cygwin.

When I do: M-x shell, the prompt has garbage:

^[]0;~/downloads/cygwinports^G
^[[32mangelo@host ^[[33m~/downloads/cygwinports^[[0m
$

being

echo PS1
\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$

I have found [1], for which 'ansi-color-for-comint-mode-on' should fix 
the thing. I have also tried defining PS1='PROMPT>' or PS1='\n\u@\h 
\w\n$ ' in .emacs_bash, but in all cases there is still garbage after 
M-x shell.

So I would ask if you have a better solutions.


Thanks,
    Angelo.

---
[1] http://lists.gnu.org/archive/html/help-gnu-emacs/2007-07/msg00796.html





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-12 14:05 On prompt in shell mode Angelo Graziosi
@ 2008-08-12 14:10 ` adg
  2008-08-12 14:17   ` Angelo Graziosi
  2008-08-12 18:19 ` Chong Yidong
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 18+ messages in thread
From: adg @ 2008-08-12 14:10 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

Le 12 Aug 2008 vers 15:05, Angelo Graziosi <angelo.graziosi@alice.it> a tapoté :

> The following regards Emacs (trunk) both on Linux and Cygwin.
>
> When I do: M-x shell, the prompt has garbage:
>
> ^[]0;~/downloads/cygwinports^G
> ^[[32mangelo@host ^[[33m~/downloads/cygwinports^[[0m
> $
>
> being
>
> echo PS1
> \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
>
> I have found [1], for which 'ansi-color-for-comint-mode-on' should fix
> the thing. I have also tried defining PS1='PROMPT>' or PS1='\n\u@\h
> \w\n$ ' in .emacs_bash, but in all cases there is still garbage after
> M-x shell.
>
> So I would ask if you have a better solutions.
>

Maybe you need to unset PROMPT_COMMAND ?

-- 
Antoine DG




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-12 14:10 ` adg
@ 2008-08-12 14:17   ` Angelo Graziosi
  0 siblings, 0 replies; 18+ messages in thread
From: Angelo Graziosi @ 2008-08-12 14:17 UTC (permalink / raw)
  To: adg; +Cc: emacs-devel

adg@crans.org ha scritto:
> Le 12 Aug 2008 vers 15:05, Angelo Graziosi <angelo.graziosi@alice.it> a tapoté :
> 
>> The following regards Emacs (trunk) both on Linux and Cygwin.
>>
>> When I do: M-x shell, the prompt has garbage:
>>
>> ^[]0;~/downloads/cygwinports^G
>> ^[[32mangelo@host ^[[33m~/downloads/cygwinports^[[0m
>> $
>>
>> being
>>
>> echo PS1
>> \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
>>
>> I have found [1], for which 'ansi-color-for-comint-mode-on' should fix
>> the thing. I have also tried defining PS1='PROMPT>' or PS1='\n\u@\h
>> \w\n$ ' in .emacs_bash, but in all cases there is still garbage after
>> M-x shell.
>>
>> So I would ask if you have a better solutions.
>>
> 
> Maybe you need to unset PROMPT_COMMAND ?
> 

$ echo $PROMPT_COMMAND
history -a

$ unset PROMPT_COMMAND

$ emacs -Q &       or    $ emacs &
M-x shell

Same result: garbage.

     Angelo








^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-12 14:05 On prompt in shell mode Angelo Graziosi
  2008-08-12 14:10 ` adg
@ 2008-08-12 18:19 ` Chong Yidong
  2008-08-13 10:03   ` Angelo Graziosi
  2008-08-12 19:46 ` Stefan Monnier
  2008-08-13  6:26 ` Richard M. Stallman
  3 siblings, 1 reply; 18+ messages in thread
From: Chong Yidong @ 2008-08-12 18:19 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

Angelo Graziosi <angelo.graziosi@alice.it> writes:

> The following regards Emacs (trunk) both on Linux and Cygwin.
>
> When I do: M-x shell, the prompt has garbage:
>
> ^[]0;~/downloads/cygwinports^G
> ^[[32mangelo@host ^[[33m~/downloads/cygwinports^[[0m
> $
>
> being
>
> echo PS1
> \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
>
> I have found [1], for which 'ansi-color-for-comint-mode-on' should fix
> the thing. I have also tried defining PS1='PROMPT>' or PS1='\n\u@\h
> \w\n$ ' in .emacs_bash, but in all cases there is still garbage after
> M-x shell.
>
> So I would ask if you have a better solutions.

I'm unable to reproduce this; ansi-color-for-comint-mode-on works for me
with that exact prompt.




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-12 14:05 On prompt in shell mode Angelo Graziosi
  2008-08-12 14:10 ` adg
  2008-08-12 18:19 ` Chong Yidong
@ 2008-08-12 19:46 ` Stefan Monnier
  2008-08-12 20:49   ` Angelo Graziosi
  2008-08-13  6:26 ` Richard M. Stallman
  3 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2008-08-12 19:46 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

> The following regards Emacs (trunk) both on Linux and Cygwin.

> When I do: M-x shell, the prompt has garbage:

> ^[]0;~/downloads/cygwinports^G
> ^[[32mangelo@host ^[[33m~/downloads/cygwinports^[[0m
> $

> being

> echo PS1
> \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$

Doesn't look like garbage to me: it looks like the exact (garbage) codes
specified in your PS1.  After all \e is ^[ and \a is ^G (IIRC).

You should be careful to choose the escape sequences in your PS1
according to the escape sequences accepted by the terminal emulator in
which the shell is running (which is reflected in the $TERM envvar).


        Stefan




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-12 19:46 ` Stefan Monnier
@ 2008-08-12 20:49   ` Angelo Graziosi
  2008-08-13 20:42     ` Stefan Monnier
  0 siblings, 1 reply; 18+ messages in thread
From: Angelo Graziosi @ 2008-08-12 20:49 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier ha scritto:
>> The following regards Emacs (trunk) both on Linux and Cygwin.
> 
>> When I do: M-x shell, the prompt has garbage:
> 
>> ^[]0;~/downloads/cygwinports^G
>> ^[[32mangelo@host ^[[33m~/downloads/cygwinports^[[0m
>> $
> 
>> being
> 
>> echo PS1
>> \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
> 
> Doesn't look like garbage to me: it looks like the exact (garbage) codes
> specified in your PS1.  After all \e is ^[ and \a is ^G (IIRC).
> 
> You should be careful to choose the escape sequences in your PS1
> according to the escape sequences accepted by the terminal emulator in
> which the shell is running (which is reflected in the $TERM envvar).

Obviously, what you call "the exact (garbage) codes specified in your 
PS1" in RXVT, MRXVT, URXVT, (KDE)Konsole produces:

angelo@host ~/downloads/cygwinports
$

in which 'angelo@host' is in green, '~/downloads/cygwinports' in yellow 
and '$' white.

It is only in Emacs shell mode (M-x shell) it produces 'garbage', both 
in GNU/Linux and Cygwin builds of current trunk.

Is there a method to redefine PS1 in .emacs?

Using

'\n\u@\h \w\n $'

for PS1 would be enough.


Cheers,
    Angelo.




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-12 14:05 On prompt in shell mode Angelo Graziosi
                   ` (2 preceding siblings ...)
  2008-08-12 19:46 ` Stefan Monnier
@ 2008-08-13  6:26 ` Richard M. Stallman
  3 siblings, 0 replies; 18+ messages in thread
From: Richard M. Stallman @ 2008-08-13  6:26 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

    The following regards Emacs (trunk) both on Linux and Cygwin.

Thank you for the bug report.

Linux is just the kernel, and the kernel is probably
unrelated to this bug.  So the relevant platform is
the whole system, which is GNU/Linux.

Would you please call the system "GNU/Linux", and give us a share of
the credit?  We did start its developent.  See
http://www.gnu.org/gnu/linux-and-gnu.html for more explanation.




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-12 18:19 ` Chong Yidong
@ 2008-08-13 10:03   ` Angelo Graziosi
  0 siblings, 0 replies; 18+ messages in thread
From: Angelo Graziosi @ 2008-08-13 10:03 UTC (permalink / raw)
  To: Chong Yidong; +Cc: emacs-devel

Chong Yidong ha scritto:
> Angelo Graziosi <angelo.graziosi@alice.it> writes:
> 
>> The following regards Emacs (trunk) both on Linux and Cygwin.
>>
>> When I do: M-x shell, the prompt has garbage:
>>
>> ^[]0;~/downloads/cygwinports^G
>> ^[[32mangelo@host ^[[33m~/downloads/cygwinports^[[0m
>> $
>>
>> being
>>
>> echo PS1
>> \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
>>
>> I have found [1], for which 'ansi-color-for-comint-mode-on' should fix
>> the thing. I have also tried defining PS1='PROMPT>' or PS1='\n\u@\h
>> \w\n$ ' in .emacs_bash, but in all cases there is still garbage after
>> M-x shell.
>>
>> So I would ask if you have a better solutions.
> 
> I'm unable to reproduce this; ansi-color-for-comint-mode-on works for me
> with that exact prompt.

Ok. Now I have discovered that the sequence:

\[\e]0;\w\a\]

is the cause even using 'ansi-color-for-comint-mode-on'.

Indeed defining

PS1='\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '

works just fine with 'ansi-color-for-comint-mode-on'.

For completeness '\[\e]0;\w\a\]' sets the window title.

I have also tried to add (setenv "PS1" "...") in .emacs:

(setenv "PS1" "prompt>")

works, but

(setenv "PS1" "\n\u@\h \w\n$ ")

causes Emacs to start with errors:

"An error has occurred while loading '[...]/.emacs':
error: Non-hex digit used for Unicode escape"

How could this problem be solved?


Thanks a lot,
    Angelo.




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-12 20:49   ` Angelo Graziosi
@ 2008-08-13 20:42     ` Stefan Monnier
  2008-08-13 21:55       ` Angelo Graziosi
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2008-08-13 20:42 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

>>> The following regards Emacs (trunk) both on Linux and Cygwin.
>> 
>>> When I do: M-x shell, the prompt has garbage:
>> 
>>> ^[]0;~/downloads/cygwinports^G
>>> ^[[32mangelo@host ^[[33m~/downloads/cygwinports^[[0m
>>> $
>> 
>>> being
>> 
>>> echo PS1
>>> \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
>> 
>> Doesn't look like garbage to me: it looks like the exact (garbage) codes
>> specified in your PS1.  After all \e is ^[ and \a is ^G (IIRC).
>> 
>> You should be careful to choose the escape sequences in your PS1
>> according to the escape sequences accepted by the terminal emulator in
>> which the shell is running (which is reflected in the $TERM envvar).

> Obviously, what you call "the exact (garbage) codes specified in your PS1"
> in RXVT, MRXVT, URXVT, (KDE)Konsole produces:

> angelo@host ~/downloads/cygwinports
> $

I do not doubt it.  They are codes meant specifically for those terminal
emulators so it's no wonder they do what you want there.  Try it on
a wyse terminal, or in the Linux console.  M-x shell is not a terminal
emulator.  M-x term is more likely to do what you want (tho I do not
guarantee that all those escape sequences are supported, especially the
one that sets the window title).


        Stefan




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-13 20:42     ` Stefan Monnier
@ 2008-08-13 21:55       ` Angelo Graziosi
  2008-08-13 22:37         ` Stefan Monnier
  0 siblings, 1 reply; 18+ messages in thread
From: Angelo Graziosi @ 2008-08-13 21:55 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier ha scritto:
>>>> The following regards Emacs (trunk) both on Linux and Cygwin. 
>>>> When I do: M-x shell, the prompt has garbage: 
>>>> ^[]0;~/downloads/cygwinports^G ^[[32mangelo@host 
>>>> ^[[33m~/downloads/cygwinports^[[0m $ being echo PS1 
>>>> \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
>>> Doesn't look like garbage to me: it looks like the exact 
>>> (garbage) codes specified in your PS1.  After all \e is ^[ and \a
>>>  is ^G (IIRC).
>>> 
>>> You should be careful to choose the escape sequences in your PS1
>>>  according to the escape sequences accepted by the terminal 
>>> emulator in which the shell is running (which is reflected in the
>>>  $TERM envvar).
> 
>> Obviously, what you call "the exact (garbage) codes specified in 
>> your PS1" in RXVT, MRXVT, URXVT, (KDE)Konsole produces:
> 
>> angelo@host ~/downloads/cygwinports $
> 
> I do not doubt it.  They are codes meant specifically for those 
> terminal emulators so it's no wonder they do what you want there.

No! They are codes (escape sequences) for BASH shell. Many people use
different shells (zsh, tcsh,...) which have different syntax.

> Try it on a wyse terminal, or in the Linux console.  M-x shell is not
>  a terminal

Sorry, but I have already cited GNU/Linux and KDE-Konsole! on which
there is the same problem!... and have sent another post [1].

I have pointed this problem because I think that M-x shell does not
interpret correctly some escape/code; googling or searching in
help-emacs, shows this is an acient problem whose workarounds do not
seem to work with 23 (and 22?).

Obviously that is only my opinion.

         Angelo

> emulator.  M-x term is more likely to do what you want (tho I do not
>  guarantee that all those escape sequences are supported, especially 
> the one that sets the window title).


---
[1] http://lists.gnu.org/archive/html/emacs-devel/2008-08/msg00556.html




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-13 21:55       ` Angelo Graziosi
@ 2008-08-13 22:37         ` Stefan Monnier
  2008-08-13 23:02           ` Angelo Graziosi
  0 siblings, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2008-08-13 22:37 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

>>>>> The following regards Emacs (trunk) both on Linux and Cygwin. When
>>>>> I do: M-x shell, the prompt has garbage: ^[]0;~/downloads/cygwinports^G
>>>>> ^[[32mangelo@host ^[[33m~/downloads/cygwinports^[[0m $ being echo PS1
>>>>> \[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$
>>>> Doesn't look like garbage to me: it looks like the exact (garbage) codes
>>>> specified in your PS1.  After all \e is ^[ and \a
>>>> is ^G (IIRC).
>>>> 
>>>> You should be careful to choose the escape sequences in your PS1
>>>> according to the escape sequences accepted by the terminal emulator in
>>>> which the shell is running (which is reflected in the
>>>> $TERM envvar).
>> 
>>> Obviously, what you call "the exact (garbage) codes specified in your
>>> PS1" in RXVT, MRXVT, URXVT, (KDE)Konsole produces:
>> 
>>> angelo@host ~/downloads/cygwinports $
>> 
>> I do not doubt it.  They are codes meant specifically for those terminal
>> emulators so it's no wonder they do what you want there.

> No! They are codes (escape sequences) for BASH shell. Many people use
> different shells (zsh, tcsh,...) which have different syntax.

AFAIK, only the \[, \w, \u, \h, and \] escapes are bash escapes (and
they indeed show up fine in your M-x shell example).  The rest
(e.g. things like "\e]0;" and "\e[32m") are not handled by bash but just
passed blindly as is to the terminal.

>> Try it on a wyse terminal, or in the Linux console.  M-x shell is not
>> a terminal

> Sorry, but I have already cited GNU/Linux and KDE-Konsole! on which
> there is the same problem!... and have sent another post [1].

I'm not sure we talk about the same thing.  I'm talking about running
your shell in a Linux console, or within `screen', or inside a Wyse
terminal (if you can find one these days).  I.e. without involving Emacs
at all.

> I have pointed this problem because I think that M-x shell does not
> interpret correctly some escape/code; googling or searching in
> help-emacs, shows this is an acient problem whose workarounds do not
> seem to work with 23 (and 22?).

> Obviously that is only my opinion.

It's a problem indeed.  I do not deny it.  But your PS1 prompt setting
is still faulty regardless ;-)


        Stefan





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-13 22:37         ` Stefan Monnier
@ 2008-08-13 23:02           ` Angelo Graziosi
  2008-08-13 23:17             ` David Hansen
  2008-08-13 23:55             ` Stefan Monnier
  0 siblings, 2 replies; 18+ messages in thread
From: Angelo Graziosi @ 2008-08-13 23:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier ha scritto:

> 
> I'm not sure we talk about the same thing.  I'm talking about running
>  your shell in a Linux console, or within `screen', or inside a Wyse 
> terminal (if you can find one these days).  I.e. without involving
> Emacs at all.

As I have written [1], defining

    PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '

in /etc/profile or .bashrc works fine in RXVT, MRXVT, URXVT, XTERM,
(KDE)Konsole WITHOUT Emacs.

i.e. the code '\[\e]0;\w\a\]' prints the working directory as title of
RXVT, MRXVT... window; the remains gives the terminal prompt in the form

    blank line (\n)
    user AT host (in green) working directory (yellow)
    $ (white)

As reported here [2], the main problem Emacs meets is with the window
title '\[\e]0;\w\a\]' (and perhaps this is to be expected)

In any case, have you some comment on how to solve the other question I
pointed out in [2], i.e. setting in .emacs

    (setenv "PS1" "prompt>")

works, but

    (setenv "PS1" "address@hidden \w\n$ ")

doesn't: Emacs starts with errors:

    "An error has occurred while loading '[...]/.emacs':
     error: Non-hex digit used for Unicode escape"


Cheers,
Angelo.

---
[1] http://lists.gnu.org/archive/html/emacs-devel/2008-08/msg00536.html
[2] http://lists.gnu.org/archive/html/emacs-devel/2008-08/msg00556.html




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-13 23:02           ` Angelo Graziosi
@ 2008-08-13 23:17             ` David Hansen
  2008-08-13 23:55             ` Stefan Monnier
  1 sibling, 0 replies; 18+ messages in thread
From: David Hansen @ 2008-08-13 23:17 UTC (permalink / raw)
  To: emacs-devel

On Thu, 14 Aug 2008 01:02:27 +0200 Angelo Graziosi wrote:

> works, but
>
>    (setenv "PS1" "address@hidden \w\n$ ")
>
> doesn't: Emacs starts with errors:
>
>    "An error has occurred while loading '[...]/.emacs':
>     error: Non-hex digit used for Unicode escape"

You have to quote the backslash with another backslash (the lisp reader
interprets it special in strings): "foo@bar \\w\\n$".

How about:

if [ "x$EMACS" = xt ]; then
   # set up your prompt for M-x shell.
else
   # fancy prompt for real terminals.
fi

in ~/.bashrc.

David





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-13 23:02           ` Angelo Graziosi
  2008-08-13 23:17             ` David Hansen
@ 2008-08-13 23:55             ` Stefan Monnier
  2008-08-14  1:24               ` Angelo Graziosi
  1 sibling, 1 reply; 18+ messages in thread
From: Stefan Monnier @ 2008-08-13 23:55 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

>> I'm not sure we talk about the same thing.  I'm talking about running
>> your shell in a Linux console, or within `screen', or inside a Wyse
>> terminal (if you can find one these days).  I.e. without involving
>> Emacs at all.

> As I have written [1], defining

>    PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '

> in /etc/profile or .bashrc works fine in RXVT, MRXVT, URXVT, XTERM,
> (KDE)Konsole WITHOUT Emacs.

Indeed, since all those terminal emulators basically emulate each-other
(or even share the underlying code).

> i.e. the code '\[\e]0;\w\a\]' prints the working directory as title of
> RXVT, MRXVT... window; the remains gives the terminal prompt in the form

I know (I use it in my own PS1 setting as well).

> In any case, have you some comment on how to solve the other question I
> pointed out in [2], i.e. setting in .emacs

>    (setenv "PS1" "prompt>")

> works, but

>    (setenv "PS1" "address@hidden \w\n$ ")

You need to escape the backslashes since they're otherwise interpreted
as escape sequences for Emacs's string literals (and there's no such
thing as a \w escape sequence for Emacs string literals).

In any case a better solution is to change your .bashrc (or wherever
you set your PS1 prompt) so as to check the value of $TERM and use
different settings depending on the features suppported by the
corresponding terminal.

I personally only use `xterm', so I use code like:

   if [[ $TERM == xterm* ]]; then
       PROMPT=$(print -n "%{\033]0;%m%${my_uid}(#..-%n)\007%}%B%2c-%?%#%b ")
   else
       PS1="%B%${my_uid}(#..%n@)%m-%2c-%?%#%b "
   fi

in my .zshrc, tho this is for Zsh so it won't work as is for you.



        Stefan




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-13 23:55             ` Stefan Monnier
@ 2008-08-14  1:24               ` Angelo Graziosi
  2008-08-14  8:50                 ` Angelo Graziosi
  0 siblings, 1 reply; 18+ messages in thread
From: Angelo Graziosi @ 2008-08-14  1:24 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: david.hansen, emacs-devel

David Hansen ha scritto:

> You have to quote the backslash with another backslash (the lisp
> reader interprets it special in strings): "address@hidden \\w\\n$".

> How about:
> 
> if [ "x$EMACS" = xt ]; then 
>    # set up your prompt for M-x shell. 
> else 
>    # fancy prompt for real terminals. 
 > fi
> 
> in ~/.bashrc.


Stefan Monnier ha scritto:
> 
> I personally only use `xterm', so I use code like:
> 
> if [[ $TERM == xterm* ]]; then PROMPT=$(print -n
> "%{\033]0;%m%${my_uid}(#..-%n)\007%}%B%2c-%?%#%b ") else 
> PS1="%B%${my_uid}(#..%n@)%m-%2c-%?%#%b " fi
> 
> in my .zshrc, tho this is for Zsh so it won't work as is for you.
> 

Many thanks for these helpful suggestions, and your time.

Cheers,
    Angelo





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-14  1:24               ` Angelo Graziosi
@ 2008-08-14  8:50                 ` Angelo Graziosi
  2008-08-14 10:22                   ` David Hansen
  2008-08-14 13:21                   ` Angelo Graziosi
  0 siblings, 2 replies; 18+ messages in thread
From: Angelo Graziosi @ 2008-08-14  8:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: david.hansen, emacs-devel

Just for completeness...

David Hansen wrote:

> How about:
> 
> if [ "x$EMACS" = xt ]; then
>    # set up your prompt for M-x shell.
> else
>    # fancy prompt for real terminals.
> fi

Well, it works just fine on GNU/Linux but not on Cygwin!

On Cygwin, it seems that only the 'else' branch is followed. Indeed using

if [ "x$EMACS" = xt ]; then
# set up your prompt for M-x shell.
PS1='OK1> '
else
# fancy prompt for real terminals.
PS1='OK2> '
fi

both terminals (rxvt, mrxvt, urxvt, xterm...) and Emacs 'M-x shell' have

OK2>

!!! but...

M-x shell

OK2> echo $EMACS
t


Cheers,
    Angelo.





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-14  8:50                 ` Angelo Graziosi
@ 2008-08-14 10:22                   ` David Hansen
  2008-08-14 13:21                   ` Angelo Graziosi
  1 sibling, 0 replies; 18+ messages in thread
From: David Hansen @ 2008-08-14 10:22 UTC (permalink / raw)
  To: emacs-devel

On Thu, 14 Aug 2008 10:50:30 +0200 Angelo Graziosi wrote:

> On Cygwin, it seems that only the 'else' branch is followed. Indeed using
>
> if [ "x$EMACS" = xt ]; then
> # set up your prompt for M-x shell.
> PS1='OK1> '
> else
> # fancy prompt for real terminals.
> PS1='OK2> '
> fi

What shell do you use?  The brackets may be a bash extension.  You can
try: if test "x$EMACS" = xt; then ...

David





^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: On prompt in shell mode
  2008-08-14  8:50                 ` Angelo Graziosi
  2008-08-14 10:22                   ` David Hansen
@ 2008-08-14 13:21                   ` Angelo Graziosi
  1 sibling, 0 replies; 18+ messages in thread
From: Angelo Graziosi @ 2008-08-14 13:21 UTC (permalink / raw)
  To: david.hansen; +Cc: Stefan Monnier, emacs-devel

David Hansen wrote:

> Angelo Graziosi wrote:
> 
>> On Cygwin, it seems that only the 'else' branch is followed. Indeed using
>>
>> if [ "x$EMACS" = xt ]; then
>> # set up your prompt for M-x shell.
>> PS1='OK1> '
>> else
>> # fancy prompt for real terminals.
>> PS1='OK2> '
>> fi
> 
> What shell do you use?  The brackets may be a bash extension.  You can
> try: if test "x$EMACS" = xt; then ...

I think the cause is this: on Cygwin .bashrc is 'executed by bash for
login shells', instead on Linux it is 'executed by bash for NON login
shells'! and I think M-x shell executes a NON-login shell, i.e. it does
not execute .bashrc!

This seems to be confirmed by

    M-x shell
    OK2> . ~/.bashrc
    OK1>

i.e. the prompt I ask for Emacs M-x shell!

       Angelo




^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-08-14 13:21 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-12 14:05 On prompt in shell mode Angelo Graziosi
2008-08-12 14:10 ` adg
2008-08-12 14:17   ` Angelo Graziosi
2008-08-12 18:19 ` Chong Yidong
2008-08-13 10:03   ` Angelo Graziosi
2008-08-12 19:46 ` Stefan Monnier
2008-08-12 20:49   ` Angelo Graziosi
2008-08-13 20:42     ` Stefan Monnier
2008-08-13 21:55       ` Angelo Graziosi
2008-08-13 22:37         ` Stefan Monnier
2008-08-13 23:02           ` Angelo Graziosi
2008-08-13 23:17             ` David Hansen
2008-08-13 23:55             ` Stefan Monnier
2008-08-14  1:24               ` Angelo Graziosi
2008-08-14  8:50                 ` Angelo Graziosi
2008-08-14 10:22                   ` David Hansen
2008-08-14 13:21                   ` Angelo Graziosi
2008-08-13  6:26 ` Richard M. Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).