[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: On prompt in shell mode

From: Stefan Monnier
Subject: Re: On prompt in shell mode
Date: Wed, 13 Aug 2008 19:55:20 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

>> 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;address@hidden \[\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 ")
       PS1="%B%${my_uid}(#..%n@)%m-%2c-%?%#%b "

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]