all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* ~/.emacs_bash setting PS1
@ 2008-02-05  1:41 Samuel Karl Peterson
  2008-02-05  9:09 ` Sven Joachim
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Samuel Karl Peterson @ 2008-02-05  1:41 UTC (permalink / raw)
  To: help-gnu-emacs

I set my PS1 prompt so that it highlights the hostname portion of my
PS1 string.  I use different colors on different hosts so I have a
better visual cue as to which host I'm actually logged into (had some
mishaps in the past with running the wrong command on the wrong
machine).  It looks like this:

export PS1="[\u@\[\033[1;35m\]\h\[\033[0m\] \W]$ "

Unfortunately, in Emacs shell-mode, this doesn't show up correctly.  I
don't need for it to work in shell-mode.  The info manual says that
shell-mode reads the file ~/.emacs_SHELL depending on the shell used
(I use bash).  However, placing the above line into the ~/.emacs_bash
file doesn't seem to work.  Oddly enough, I can type 'exit' and then
I'll have a shell with the proper PS1 variable set.

Anyone have any advice for me?
-- 
Sam Peterson
skpeterson At nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown


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

* Re: ~/.emacs_bash setting PS1
  2008-02-05  1:41 ~/.emacs_bash setting PS1 Samuel Karl Peterson
@ 2008-02-05  9:09 ` Sven Joachim
  2008-02-05 15:44   ` Samuel Karl Peterson
  2008-02-05  9:25 ` Peter Dyballa
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Sven Joachim @ 2008-02-05  9:09 UTC (permalink / raw)
  To: help-gnu-emacs

On 2008-02-05 02:41 +0100, Samuel Karl Peterson wrote:

> I set my PS1 prompt so that it highlights the hostname portion of my
> PS1 string.  I use different colors on different hosts so I have a
> better visual cue as to which host I'm actually logged into (had some
> mishaps in the past with running the wrong command on the wrong
> machine).  It looks like this:
>
> export PS1="[\u@\[\033[1;35m\]\h\[\033[0m\] \W]$ "
>
> Unfortunately, in Emacs shell-mode, this doesn't show up correctly.

Do you know you can change that? Quoting (Info "(emacs)Shell Options"):

,----
|    If you want Shell mode to handle color output from shell commands,
| you can enable ANSI Color mode.  Here is how to do this:
| 
|      (add-hook 'shell-mode-hook 'ansi-color-for-comint-mode-on)
`----

Sven


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

* Re: ~/.emacs_bash setting PS1
  2008-02-05  1:41 ~/.emacs_bash setting PS1 Samuel Karl Peterson
  2008-02-05  9:09 ` Sven Joachim
@ 2008-02-05  9:25 ` Peter Dyballa
  2008-02-05 10:27 ` Ehud Karni
  2008-02-06 15:05 ` Stefan Monnier
  3 siblings, 0 replies; 8+ messages in thread
From: Peter Dyballa @ 2008-02-05  9:25 UTC (permalink / raw)
  To: Samuel Karl Peterson; +Cc: help-gnu-emacs


Am 05.02.2008 um 02:41 schrieb Samuel Karl Peterson:

> However, placing the above line into the ~/.emacs_bash
> file doesn't seem to work.

It can't work because shell-mode does not support ANSI code in the  
prompt. Even if you enable some ANSI-fication with

	(ansi-color-for-comint-mode-on)

it won't. What you can do is to set in the customisation sections  
(variables and faces) of your user init file (~/.emacs) your prompts'  
looks (here for a prompt that will look like "pete 1234 /\ "):

	 '(comint-prompt-regexp "^[a-z]+ [0-9]+ /\\\\ " t)
	 '(shell-prompt-pattern "^[a-z0-9]+ [0-9]+ /\\\\ ")
	
	 '(comint-highlight-prompt ((t (:background  
"FloralWhite" :foreground "DarkViolet" :weight bold :family "-*- 
courier new-medium-r-*-10646-1"))))
	 '(minibuffer-prompt ((t (:background "yellow" :foreground "dark  
red" :weight bold))))

If you're using *one* user init file for a handful of hosts you would  
need to put some ELisp code into the customisation to make GNU Emacs  
distinguish between the hosts and prompts.


BTW, you can also choose different colours for background,  
foreground, fringes ... that's what I prefer. This can partly also be  
done by ~/.Xdefaults-<hostname>.

--
Greetings

   Pete

When people run around and around in circles we say they are crazy.  
When planets do it we say they are orbiting.






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

* Re: ~/.emacs_bash setting PS1
  2008-02-05  1:41 ~/.emacs_bash setting PS1 Samuel Karl Peterson
  2008-02-05  9:09 ` Sven Joachim
  2008-02-05  9:25 ` Peter Dyballa
@ 2008-02-05 10:27 ` Ehud Karni
  2008-02-06 15:05 ` Stefan Monnier
  3 siblings, 0 replies; 8+ messages in thread
From: Ehud Karni @ 2008-02-05 10:27 UTC (permalink / raw)
  To: skpeterson; +Cc: help-gnu-emacs

On Mon, 04 Feb 2008 17:41:09 -0800, Samuel Karl Peterson wrote:
>
> I set my PS1 prompt so that ...  It looks like this:
>
> export PS1="[\u@\[\033[1;35m\]\h\[\033[0m\] \W]$ "
>
> Unfortunately, in Emacs shell-mode, this doesn't show up correctly.

I can't help you with ~/.emacs_bash problem, but I can offer a better
solution.  Add the following line to your .emacs and you'll have color
in your Emacs shell mode too.

(add-hook 'comint-mode-hook 'ansi-color-for-comint-mode-on)

Ehud.


--
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry




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

* Re: ~/.emacs_bash setting PS1
  2008-02-05  9:09 ` Sven Joachim
@ 2008-02-05 15:44   ` Samuel Karl Peterson
  0 siblings, 0 replies; 8+ messages in thread
From: Samuel Karl Peterson @ 2008-02-05 15:44 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks to both Sven and Ehud,

(add-hook 'comint-mode-hook 'ansi-color-for-comint-mode-on)

worked really, really, well!

-- 
Sam Peterson
skpeterson At nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown


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

* Re: ~/.emacs_bash setting PS1
  2008-02-05  1:41 ~/.emacs_bash setting PS1 Samuel Karl Peterson
                   ` (2 preceding siblings ...)
  2008-02-05 10:27 ` Ehud Karni
@ 2008-02-06 15:05 ` Stefan Monnier
  2008-02-06 17:32   ` Samuel Karl Peterson
  3 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2008-02-06 15:05 UTC (permalink / raw)
  To: help-gnu-emacs

> file doesn't seem to work.  Oddly enough, I can type 'exit' and then
> I'll have a shell with the proper PS1 variable set.

Could you give a precise recipe to reproduce this very odd behavior?


        Stefan


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

* Re: ~/.emacs_bash setting PS1
  2008-02-06 15:05 ` Stefan Monnier
@ 2008-02-06 17:32   ` Samuel Karl Peterson
  2008-02-08  2:57     ` Stefan Monnier
  0 siblings, 1 reply; 8+ messages in thread
From: Samuel Karl Peterson @ 2008-02-06 17:32 UTC (permalink / raw)
  To: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> on Wed, 06 Feb 2008 10:05:51
-0500 didst step forth and proclaim thus:

>> file doesn't seem to work.  Oddly enough, I can type 'exit' and then
>> I'll have a shell with the proper PS1 variable set.
>
> Could you give a precise recipe to reproduce this very odd behavior?
>

C-x C-f ~/.emacs_bash
; put this as the only line in the file
export PS1="[\u@\h \W]$ "
C-x C-s
C-x C-k
M-x shell
exit

Emacs version: GNU Emacs 22.1.1 (i486-pc-linux-gnu, GTK+ Version
2.12.0) of 2007-11-06 on terranova, modified by Ubuntu

-- 
Sam Peterson
skpeterson At nospam ucdavis.edu
"if programmers were paid to remove code instead of adding it,
software would be much better" -- unknown


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

* Re: ~/.emacs_bash setting PS1
  2008-02-06 17:32   ` Samuel Karl Peterson
@ 2008-02-08  2:57     ` Stefan Monnier
  0 siblings, 0 replies; 8+ messages in thread
From: Stefan Monnier @ 2008-02-08  2:57 UTC (permalink / raw)
  To: help-gnu-emacs

>>> file doesn't seem to work.  Oddly enough, I can type 'exit' and then
>>> I'll have a shell with the proper PS1 variable set.
>> 
>> Could you give a precise recipe to reproduce this very odd behavior?

> C-x C-f ~/.emacs_bash
> ; put this as the only line in the file
> export PS1="[\u@\h \W]$ "
> C-x C-s
> C-x C-k
> M-x shell
> exit

> Emacs version: GNU Emacs 22.1.1 (i486-pc-linux-gnu, GTK+ Version
> 2.12.0) of 2007-11-06 on terranova, modified by Ubuntu

I tried it with Emacs-22.1 (from Debian testing) and with the following
differences:

- started emacs as "SHELL=/bin/bash emacs22 -Q"
- did not do C-x C-k (which is not bound to any command, but to a submap
  containing various macro-expansion bindings).

the result is that after typing `exit' and RET the shell process
is terminated.

I suspect that the "-Q" is key and that your problem is linked to some
customization of yours.


        Stefan


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

end of thread, other threads:[~2008-02-08  2:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-05  1:41 ~/.emacs_bash setting PS1 Samuel Karl Peterson
2008-02-05  9:09 ` Sven Joachim
2008-02-05 15:44   ` Samuel Karl Peterson
2008-02-05  9:25 ` Peter Dyballa
2008-02-05 10:27 ` Ehud Karni
2008-02-06 15:05 ` Stefan Monnier
2008-02-06 17:32   ` Samuel Karl Peterson
2008-02-08  2:57     ` Stefan Monnier

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.