From b65df9ec82b55a41eda2ab85a8d032a20f9d49ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Sat, 27 Mar 2021 19:11:57 +0300 Subject: How to fix broken terminal on ssh --- .../2021-03-27_fix-broken-terminal-ssh/index.md | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 content/weblog/2021-03-27_fix-broken-terminal-ssh/index.md diff --git a/content/weblog/2021-03-27_fix-broken-terminal-ssh/index.md b/content/weblog/2021-03-27_fix-broken-terminal-ssh/index.md new file mode 100644 index 0000000..41156b5 --- /dev/null +++ b/content/weblog/2021-03-27_fix-broken-terminal-ssh/index.md @@ -0,0 +1,53 @@ ++++ +title = "Fixing terminal and remote machine misunderstandings" +date = 2021-03-27T16:10:01Z ++++ + +If you are like me and use a not-so standard terminal emulator and find yourself +frequently ssh'ing into new machines, or maybe you've changed your terminal +emulator, then this article might help you get your terminal fully functional +over ssh. + + + +Upon logging in you might notice that several shell features might not work as +expected; clear does nothing, pressing backspace doesn't erase the text on +screen, etc. Or trying to use a program like tmux you might come across a +message like `open terminal failed: missing or unsuitable terminal: `. This means that the system you've just logged into doesn't know how +to interact with your terminal emulator. + +This happens to me on a somewhat regular basis but not frequent enough to +remember how to solve it, and for some reason it is not easy to find the nice +answer I was looking for on the Internet, and so, I decided to write this to +help me remember how to properly solve this problem. + +## Solution + +The way I solve this is to first generate the terminfo description file on my +local computer. Let's say I am using Alacritty: + +``` +$ infocmp alacritty > alacritty.terminfo +``` + +Then copy that file to the remote machine, for example, using rsync: + +``` +$ rsync alacritty.terminfo remote: +``` + +Finally on the remote machine import the terminfo file. If you have root access, +you can import using root/sudo so that it is available to all users, otherwise +it will only be available for the user you're currently logged-in as. + +``` +# tic -x alacritty.terminfo +``` + +There are several other solutions (and some hacks) like copying the terminfo +directly from your `/lib/terminfo/…` directory to the remote machine's. I, +however, find the solution presented above to be cleaner and handier, since I +usually keep the terminfo file I generated with `infocmp` in case I need to +import it into any other machines, unless I change my terminal, in which case I +regenerate it first. -- cgit v1.2.3