Discussion:
[mosh-devel] Is there a way to tell if you are running inside mosh?
TJ Luoma
2018-11-14 19:52:11 UTC
Permalink
Hi folks

I just installed mosh after hearing about it for awhile but never
having used it before. I'm not sure if this is the best place to ask
questions. If not, please let me know. I checked the IRC channel but
it seemed to be empty.

I have a rather complex zsh prompt which uses colors using ANSI color
codes… to be honest, I just copied it from some website several years
ago, and I don't even understand how it works myself.

When I connect via ssh, it works fine. When I connect via mosh, it
looks weird. Here's a picture, showing SSH on top, and MOSH on bottom:

Loading Image...

Ideally, I'd like to figure out how to make this work under MOSH, but
in the meantime I'd like to setup my .zshrc to use a different prompt
when I am connected via MOSH instead of SSH.

However, I can't seem to figure out how to tell the difference
programmatically. The only thing I knew to try to check was `printenv`
but that didn't show me anything, at least as far as I can tell.

Thanks for any pointers

TjL


--
TJ Luoma
TJ @ MacStories
Personal Website: luo.ma (aka RhymesWithDiploma.com)
Twitter: @tjluoma
Alex Chernyakhovsky
2018-11-15 14:35:40 UTC
Permalink
Hi,

What's the value of $TERM in the terminal emulator where you are
running ssh/mosh? It looks to me like you may be using color codes
that are not (claimed to be) supported by the outside terminal
emulator and mosh is compensating.

Sincerely,
-Alex
Post by TJ Luoma
Hi folks
I just installed mosh after hearing about it for awhile but never
having used it before. I'm not sure if this is the best place to ask
questions. If not, please let me know. I checked the IRC channel but
it seemed to be empty.
I have a rather complex zsh prompt which uses colors using ANSI color
codes… to be honest, I just copied it from some website several years
ago, and I don't even understand how it works myself.
When I connect via ssh, it works fine. When I connect via mosh, it
https://www.dropbox.com/s/y1xuktzuom648f8/ssh-on-top-mosh-on-bottom.png?dl=0
Ideally, I'd like to figure out how to make this work under MOSH, but
in the meantime I'd like to setup my .zshrc to use a different prompt
when I am connected via MOSH instead of SSH.
However, I can't seem to figure out how to tell the difference
programmatically. The only thing I knew to try to check was `printenv`
but that didn't show me anything, at least as far as I can tell.
Thanks for any pointers
TjL
--
TJ Luoma
Personal Website: luo.ma (aka RhymesWithDiploma.com)
_______________________________________________
mosh-devel mailing list
http://mailman.mit.edu/mailman/listinfo/mosh-devel
TJ Luoma
2018-11-15 15:01:27 UTC
Permalink
Post by Alex Chernyakhovsky
What's the value of $TERM in the terminal emulator where you are
running ssh/mosh?
both ssh and mosh say TERM is 'xterm-256color'

--
TJ Luoma
TJ @ MacStories
Personal Website: luo.ma (aka RhymesWithDiploma.com)
Twitter: @tjluoma
Alex Chernyakhovsky
2018-11-15 15:32:32 UTC
Permalink
Hi,

What's the value of TERM outside, without running ssh?

Sincerely,
-Alex
Post by TJ Luoma
Post by Alex Chernyakhovsky
What's the value of $TERM in the terminal emulator where you are
running ssh/mosh?
both ssh and mosh say TERM is 'xterm-256color'
--
TJ Luoma
Personal Website: luo.ma (aka RhymesWithDiploma.com)
TJ Luoma
2018-11-15 15:45:47 UTC
Permalink
Post by Alex Chernyakhovsky
What's the value of TERM outside, without running ssh?
same, "xterm-256color"

TjL

--
TJ Luoma
TJ @ MacStories
Personal Website: luo.ma (aka RhymesWithDiploma.com)
Twitter: @tjluoma
Keith Winstein
2018-11-15 17:48:11 UTC
Permalink
Hello -- I think the main issue here is that you are using ISO 2022 shift
sequences to switch to the "alternate character set" to draw those lines on
the screen. Mosh follows the practice of some (but not most) UTF-8 (ISO
10646) ANSI terminal emulators in refusing to interpret the "locking
shifts" of the older ISO 2022 standard. Hence all those "q"s on the screen.

Your options are probably:

a) Change your shell configuration to send real Unicode (UTF-8) characters
instead of switching into an alternate character set via ISO 2022
b) Use a program like "screen", "tmux", or "luit" to translate between ISO
2022 (input) and UTF-8 (output) for Mosh.
c) Detect if you are running inside a mosh-server with a command like
`pstree -plus $$ | grep mosh-server`

Would have happily answered this over IRC as well!

Best regards,
Keith
Post by TJ Luoma
Post by Alex Chernyakhovsky
What's the value of TERM outside, without running ssh?
same, "xterm-256color"
TjL
--
TJ Luoma
Personal Website: luo.ma (aka RhymesWithDiploma.com)
_______________________________________________
mosh-devel mailing list
http://mailman.mit.edu/mailman/listinfo/mosh-devel
Continue reading on narkive:
Loading...