Running a brand new Ubuntu 16.04 and a Debian 8 server. Trying to connect via ssh and getting the following strange terminal output. I refer to the rectangles with the numbers in it.
The problem with the language settings was introduced by myself trying to solve the just mentioned problem since I assumed some encoding problems to be responsible.
After 3h of debugging I need your help!
Maybe it's just a missing library? It is hard searching for such graphical problems…
local@local:~$ ssh dummy@server
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Sat Jul 9 17:22:43 2016 from x590c3909.dyn.telefonica.de
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
-bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
]1337;RemoteHost=dummy@server]1337;CurrentDir=/home/patrick]1337;ShellIntegrationVersion=2;shell=bash]133;C;]133;D;0]1337;RemoteHost=dummy@server]1337;CurrentDir=/home/patrick]133;Adummy@server:~$ ]133;B
echo $PS1 output:
echo $PS1
]133;C;\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
echo $TERM output:
echo $TERM
]133;C;xterm
Edit: "locale" – warning fixed by this answer.
Best Answer
What your terminal is doing
The "rectangles with the numbers in [them]" are the way that your terminal emulator is displaying a terminal control sequence to you, because it doesn't recognize that sequence. Specifically:
You'll most likely know one of these 7-bit aliases that is very common: ESC
[
instead of the CSI control character (U+009B). The OSC control character has ESC]
as a 7-bit alias.]
and just treating it as an ESC character followed by an]
character. And that's what it is printing.00
and1B
in the box, for U+001B, the code point for the ESC character.]
over the top of the right-hand half of the box, as you can see.Why it has been told to do that
Several terminal emulators recognize OSC as a control character sequence introducer. There's a standard form for it, even. ECMA-48 § 5.6 defines "control strings" begun with OSC and terminated with ST (U+009C, String Terminator). What is in the control string is terminal-type specific. For example: You'll see from its doco that xterm implements such control strings, for setting fonts and window titles.
However, the form of the control sequence in this case is not that of xterm. Rather, it is
This is the form for OSC control sequences that is understood by iTerm2. iTerm2 defines a set of control sequences introduced by OSC that are distinctly non-standard and idiosyncratic to iTerm2. They do not adhere to the ECMA-48 control string specification but terminate the control string with BEL (U+0007) rather than with ST as the standard says. Strictly speaking, that's a control string that isn't ever terminated, since any characters other than SOS and ST are permitted in the contents of a control string; and is one that with a conformant terminal emulator effectively just stops display, as the terminal simply accrues all further output as a control string.
(The terminal emulator that is built in to the Linux kernel also doesn't implement standard OSC control strings. The xterm doco notes that it has bodges to support broken applications that use the non-conformant Linux kernel terminal emulator or iTerm2 forms. The form here is definitely iTerm2's, not that of the Linux kernel terminal emulator, though.)
When you are using iTerm2 from your Macintosh, whatever is on the other end of the SSH connection is quietly sending iTerm2 control sequences to your terminal emulator to tell it stuff like what your shell is, what your working directory is, who you are, when you start editing at a shell prompt, when you start executing a command, and so forth.
On the remote system, you have hardwired the terminal type. You've made it operate under the assumption that you're always talking to it with iTerm2. But you are now talking to it using Terminator running on Ubuntu, a different terminal emulator that has a different set of control sequences.
In fact, the output even tells you this:
You've installed the iTerm2 "Shell Integration" for the Bourne Again shell on your remote system. Looking at it, it is pretty bad at checking that iTerm2 is actually the terminal that it is speaking to.
So disable/uninstall it.
Further reading
console_codes
. Linux manual pages. § 4. 2015.