I have a problem I cannot understand, and cannot debug for the life of me.

  • I run Mac OS X 10.9.2 (latest) and use Terminal.app and zsh as my shell.
  • A server I work remotely on runs Ubuntu 13.04 and zsh as my shell.
  • My $TERM environment variable on OS X is set to xterm256-color, and the same shows after logging into the remote server.
  • Locally, my prompt is [[ ${EUID} != 0 ]] && PS1=$'%{\e[1;32m%}%n@dhm %{\e[1;36m%}%1d %#%{\e[0m%} '. I think the color codes are escaped properly.
  • In my .vimrc:
    • set nocompatible " default options
    • set term=ansi " colors on
    • syntax on " syntax highlighting
    • ...
  • At the moment, I'm triaging the issue and my remote .zshrc is empty: # Created by newuser for 5.0.0 is the only line in the file.

Here's my issue:

  • When I use vim normally on my Mac, it works fine.
  • When I ssh into the Ubuntu server, vim and zsh and etc. work fine.
  • After I log out of the remote server, vim does the thing where arrow keys put B\n A\n, C\n, D\n that is usually fixed by, e.g., setting nocompatible or setting your terminal to ansi, according to other threads.
  • After a terminal reset locally, vim works fine.

Another data point: this does not happen when I set my remote shell to bash. Even though my remote .zshrc is empty.

Any advice as to how I can debug this? I have tried things like comparing env and echo $PS1 before and after ssh, but didn't find any changes.

Edit: I have posted a gist of the output of the login process through script here: https://gist.github.com/dhalperi/d00f191801c000ff0770

  • Althought the user's zshrc on the remote machine is empty, there might be some conflicting code in system wide config files (/etc/zsh*, /etc/zlogout, etc.) – mpy May 12 '14 at 18:31
  • Is script available on OS X? If so, you could try to make a hardcopy of the process login->logout and check if some non-visible characters are transmitted. – mpy May 12 '14 at 18:37
  • @mpy - Edited to post the typescript in a gist – Dan Halperin May 12 '14 at 18:46
  • 1. Can you please try answering 0 to that question? So as to avoid having that process start. 2. The right way to debug shells is to run them with -x, try ssh foo@your-address.org -t 'zsh -x' (and save that in script). Although it is a little noisy, you should be able to find the source of any funny characters. – Francisco Jul 10 '14 at 8:19
  • Ok. A better idea: after you answered '0' there to have an empty .zshrc. Try ssh foo@bar.com -t 'zsh --no-global-rcs'. This will start zsh skipping any of the system configuration files, i.e. those in /etc. If you use ssh foo@bar.com -t 'zsh -f' you'll ignore all of your own config files. Worth trying as well. – Francisco Jul 10 '14 at 8:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.