all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* how to display that a term is inside emacs
@ 2013-12-04 16:46 henry atting
  2013-12-04 19:02 ` Pascal J. Bourguignon
  0 siblings, 1 reply; 8+ messages in thread
From: henry atting @ 2013-12-04 16:46 UTC (permalink / raw
  To: help-gnu-emacs

On X I have no window decoration, emacs starts without mode-line, menu,
toolbar. One of the things I use emacs is as terminal emulator
(multi-term). So far, so good.
At times I open up rxvt-unicode as terminal emulator beside emacs. Both
look rather similar, no decoration, same background- same foreground
color. 

Is there a way to add something informative to the prompt (like the file
manager ranger does) or display somewhere else something like
`inside_emacs' for instance to indicate that this terminal is inside
emacs?

henry


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

* Re: how to display that a term is inside emacs
  2013-12-04 16:46 how to display that a term is inside emacs henry atting
@ 2013-12-04 19:02 ` Pascal J. Bourguignon
  2013-12-04 20:51   ` henry atting
  2013-12-04 20:54   ` Emanuel Berg
  0 siblings, 2 replies; 8+ messages in thread
From: Pascal J. Bourguignon @ 2013-12-04 19:02 UTC (permalink / raw
  To: help-gnu-emacs

henry atting <snd@online.de> writes:

> On X I have no window decoration, emacs starts without mode-line, menu,
> toolbar. One of the things I use emacs is as terminal emulator
> (multi-term). So far, so good.
> At times I open up rxvt-unicode as terminal emulator beside emacs. Both
> look rather similar, no decoration, same background- same foreground
> color. 
>
> Is there a way to add something informative to the prompt (like the file
> manager ranger does) or display somewhere else something like
> `inside_emacs' for instance to indicate that this terminal is inside
> emacs?

TERM is probably different in the two terminal emulators.

in M-x shell, TERM=emacs
in M-x term,  TERM=eterm-color
I don't have M-x multi-term
in xterm,     TERM=xterm-256color
I don't have rxvt-unicode.

so you could have:

   export PS1="${TERM} ${PS1}"
 
in your ~/.bashrc etc.

-- 
__Pascal Bourguignon__
http://www.informatimago.com/


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

* Re: how to display that a term is inside emacs
  2013-12-04 19:02 ` Pascal J. Bourguignon
@ 2013-12-04 20:51   ` henry atting
  2013-12-04 20:56     ` Emanuel Berg
  2013-12-04 20:54   ` Emanuel Berg
  1 sibling, 1 reply; 8+ messages in thread
From: henry atting @ 2013-12-04 20:51 UTC (permalink / raw
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com> writes:

> henry atting <snd@online.de> writes:
>
>> On X I have no window decoration, emacs starts without mode-line, menu,
>> toolbar. One of the things I use emacs is as terminal emulator
>> (multi-term). So far, so good.
>> At times I open up rxvt-unicode as terminal emulator beside emacs. Both
>> look rather similar, no decoration, same background- same foreground
>> color. 
>>
>> Is there a way to add something informative to the prompt (like the file
>> manager ranger does) or display somewhere else something like
>> `inside_emacs' for instance to indicate that this terminal is inside
>> emacs?
>
> TERM is probably different in the two terminal emulators.
>
> in M-x shell, TERM=emacs
> in M-x term,  TERM=eterm-color
> I don't have M-x multi-term
> in xterm,     TERM=xterm-256color
> I don't have rxvt-unicode.
>
> so you could have:
>
>    export PS1="${TERM} ${PS1}"
>  
> in your ~/.bashrc etc.

Ah, I see, this changes the bash prompt in urxvt, not in emacs. I did
not think of doing it this way but it's fine by me. 
Then again I use zsh, not bash (what I unfortunately kept a secret) -
it's a little more complicated but doable anyway.

Thanks,
henry


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

* Re: how to display that a term is inside emacs
  2013-12-04 19:02 ` Pascal J. Bourguignon
  2013-12-04 20:51   ` henry atting
@ 2013-12-04 20:54   ` Emanuel Berg
  1 sibling, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2013-12-04 20:54 UTC (permalink / raw
  To: help-gnu-emacs

"Pascal J. Bourguignon" <pjb@informatimago.com> writes:

> TERM is probably different in the two terminal
> emulators.
>
> in M-x shell, TERM=emacs
> in M-x term,  TERM=eterm-color
> I don't have M-x multi-term
> in xterm,     TERM=xterm-256color
> I don't have rxvt-unicode.
>
> so you could have:
>
>    export PS1="${TERM} ${PS1}"
>  
> in your ~/.bashrc etc.

Yes. To the OP:

In zsh, you could do it like this in .zshrc (it'll be
similar in bash). I have a sort of similar setup [1],
only I have some other stuff there as well, *and* I
don't want those labels, so I provide them here so you
can compare directly to this screenshot [2], to see how
it works.

CURRENT_VT=`tty`
if [[ ${CURRENT_VT[6]} == "p" ]]; then
    if [[ `uname` == "SunOS" ]]; then
        # on a remote SunOS/Solaris system:
        # here, also  setup aliases and so forth
        # used on that specific machine
        export VT="Sun"
        PROMPT_VT="%K{red}%F{yellow}$VT%f%k"
    elif [[ $TERM == "screen" ]]; then
        # I always use tmux both in the Linux VTs and
        # on top of urxvt (the same as you use) -
        # confusingly, this is called "screen"
        export VT="tmux"
        PROMPT_VT="%F{red}$VT%f"
    elif [[ $EMACS == "t" ]]; then
        # Emacs
        export VT="emacs"
        PROMPT_VT="%F{red}$VT%f"
    fi
else
    # this will be the Linux VTs *without* tmux
    export VT=${CURRENT_VT: -1:1}
    PROMPT_VT="%F{red}$VT%f"
fi
PROMPT=" %B$PROMPT_VT %F{cyan}%(4~|../|)%3~%f%b "

[1] http://user.it.uu.se/~embe8573/conf/.zshrc
[2] http://user.it.uu.se/~embe8573/vt_id.png

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


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

* Re: how to display that a term is inside emacs
  2013-12-04 20:51   ` henry atting
@ 2013-12-04 20:56     ` Emanuel Berg
  2013-12-05 10:38       ` henry atting
  0 siblings, 1 reply; 8+ messages in thread
From: Emanuel Berg @ 2013-12-04 20:56 UTC (permalink / raw
  To: help-gnu-emacs

henry atting <snd@online.de> writes:

>> TERM is probably different in the two terminal
>> emulators.
>>
>> in M-x shell, TERM=emacs
>> in M-x term,  TERM=eterm-color
>> I don't have M-x multi-term
>> in xterm,     TERM=xterm-256color
>> I don't have rxvt-unicode.
>>
>> so you could have:
>>
>>    export PS1="${TERM} ${PS1}"
>>  
>> in your ~/.bashrc etc.
>
> Ah, I see, this changes the bash prompt in urxvt, not
> in emacs. I did not think of doing it this way but
> it's fine by me.  Then again I use zsh, not bash
> (what I unfortunately kept a secret) - it's a little
> more complicated but doable anyway.

I think Emacs reads PS1 as well. Check out my post. It
is not more complicated in zsh and it is the exact same
principle.

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


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

* Re: how to display that a term is inside emacs
  2013-12-04 20:56     ` Emanuel Berg
@ 2013-12-05 10:38       ` henry atting
  2013-12-05 10:49         ` henry atting
  0 siblings, 1 reply; 8+ messages in thread
From: henry atting @ 2013-12-05 10:38 UTC (permalink / raw
  To: help-gnu-emacs

Emanuel Berg <embe8573@student.uu.se> writes:

> henry atting <snd@online.de> writes:
>
>>> TERM is probably different in the two terminal
>>> emulators.
>>>
>>> in M-x shell, TERM=emacs
>>> in M-x term,  TERM=eterm-color
>>> I don't have M-x multi-term
>>> in xterm,     TERM=xterm-256color
>>> I don't have rxvt-unicode.
>>>
>>> so you could have:
>>>
>>>    export PS1="${TERM} ${PS1}"
>>>  
>>> in your ~/.bashrc etc.
>>
>> Ah, I see, this changes the bash prompt in urxvt, not
>> in emacs. I did not think of doing it this way but
>> it's fine by me.  Then again I use zsh, not bash
>> (what I unfortunately kept a secret) - it's a little
>> more complicated but doable anyway.
>
> I think Emacs reads PS1 as well. Check out my post. It
> is not more complicated in zsh and it is the exact same
> principle.

As far as I can see urxvt (which is called `rx' on my system) reads PS1
and Emacs reads TERM, so I found out this (or the like) is the easiest
way to do it in ~/.zshrc:


case $TERM in
    rx*)
        precmd () PS1="%d"' in rx '
        ;;
esac


Thanks,
henry


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

* Re: how to display that a term is inside emacs
  2013-12-05 10:38       ` henry atting
@ 2013-12-05 10:49         ` henry atting
  2013-12-06 18:26           ` Emanuel Berg
  0 siblings, 1 reply; 8+ messages in thread
From: henry atting @ 2013-12-05 10:49 UTC (permalink / raw
  To: help-gnu-emacs

henry atting <snd@online.de> writes:

> As far as I can see urxvt (which is called `rx' on my system) reads PS1
> and Emacs reads TERM

Erh, this must be wrong. But though I do not understand it correctly it
works fine...



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

* Re: how to display that a term is inside emacs
  2013-12-05 10:49         ` henry atting
@ 2013-12-06 18:26           ` Emanuel Berg
  0 siblings, 0 replies; 8+ messages in thread
From: Emanuel Berg @ 2013-12-06 18:26 UTC (permalink / raw
  To: help-gnu-emacs

henry atting <snd@online.de> writes:

> henry atting <snd@online.de> writes:
>
>> As far as I can see urxvt (which is called `rx' on
>> my system) reads PS1 and Emacs reads TERM

Yeah? u is for Unicode, r is for reduced (as compared
to xterm, urxvt and rxvt requires less computer power),
x is for X, and vt is for virtual terminal.

> Erh, this must be wrong. But though I do not
> understand it correctly it works fine...

I don't think either reads TERM, it is just an
environmental variable that describes the current
setup. If you wish to have this reflected in the prompt
string, you can read TERM and then setup PS depending
on what was read.

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


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

end of thread, other threads:[~2013-12-06 18:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-04 16:46 how to display that a term is inside emacs henry atting
2013-12-04 19:02 ` Pascal J. Bourguignon
2013-12-04 20:51   ` henry atting
2013-12-04 20:56     ` Emanuel Berg
2013-12-05 10:38       ` henry atting
2013-12-05 10:49         ` henry atting
2013-12-06 18:26           ` Emanuel Berg
2013-12-04 20:54   ` Emanuel Berg

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.