From ea3ad786fa98f1ae75dd32845d0df9e1056f69e2 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sun, 27 Jan 2013 22:05:07 -0500 Subject: [PATCH] scripts/mosh: Add --no-init option to disable alternate screen mode Signed-off-by: Anders Kaseorg Closes #384. Closes #2. --- man/mosh.1 | 6 ++++++ scripts/mosh | 6 ++++++ src/terminal/terminaldisplayinit.cc | 6 ++++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/man/mosh.1 b/man/mosh.1 index b916e4b..9463740 100644 --- a/man/mosh.1 +++ b/man/mosh.1 @@ -128,6 +128,12 @@ only port that is forwarded through a firewall to the server. Otherwise, \fBmosh\fP will choose a port between 60000 and 61000. +.TP +.B \-\-no\-init +Do not send the \fBsmcup\fP initialization string and \fBrmcup\fP +deinitialization string to the client's terminal. On many terminals +this disables alternate screen mode. + .SH ESCAPE SEQUENCES The escape sequence to shut down the connection is \fBCtrl-^ .\fP diff --git a/scripts/mosh b/scripts/mosh index 0841c20..d01c1dc 100755 --- a/scripts/mosh +++ b/scripts/mosh @@ -48,6 +48,8 @@ my $port_request = undef; my $ssh = 'ssh'; +my $term_init = 1; + my $help = undef; my $version = undef; @@ -72,6 +74,8 @@ qq{Usage: $0 [options] [--] [user@]host [command...] (example: "ssh -p 2222") (default: "ssh") + --no-init do not send terminal initialization string + --help this message --version version and copyright information @@ -104,6 +108,7 @@ GetOptions( 'client=s' => \$client, 'n' => sub { $predict = 'never' }, 'p=s' => \$port_request, 'ssh=s' => \$ssh, + 'init!' => \$term_init, 'help' => \$help, 'version' => \$version, 'fake-proxy!' => \my $fake_proxy ) or die $usage; @@ -281,6 +286,7 @@ if ( $pid == 0 ) { # child # Now start real mosh client $ENV{ 'MOSH_KEY' } = $key; $ENV{ 'MOSH_PREDICTION_DISPLAY' } = $predict; + $ENV{ 'MOSH_NO_TERM_INIT' } = '1' if !$term_init; exec {$client} ("$client @cmdline |", $ip, $port); } diff --git a/src/terminal/terminaldisplayinit.cc b/src/terminal/terminaldisplayinit.cc index 4744628..80ba467 100644 --- a/src/terminal/terminaldisplayinit.cc +++ b/src/terminal/terminaldisplayinit.cc @@ -146,7 +146,9 @@ Display::Display( bool use_environment ) posterize_colors = ti_num( "colors" ) < 256; */ - smcup = ti_str("smcup"); - rmcup = ti_str("rmcup"); + if ( !getenv( "MOSH_NO_TERM_INIT" ) ) { + smcup = ti_str("smcup"); + rmcup = ti_str("rmcup"); + } } }