Emacs: Tramp doesn't work

前端 未结 6 1671
無奈伤痛
無奈伤痛 2020-11-29 22:01

I tried to open a remote file via Emacs via Tramp.

(require \'tramp)
(setq tramp-default-method \"ssh\")

I get a message from Emacs

6条回答
  •  醉话见心
    2020-11-29 22:17

    Well, this is a defect of tramp.

    The real solution is to prevent loading .bashrc when tramp is used. (because now it is PS1, but it can be PATH, or any other thing that your .bashrc will do that will displease tramp...).

    This can be done by asking ssh to set an environment variable, and testing it in .bashrc:

    Add this to ~/.emacs:

    (require 'tramp-sh nil t) (setf tramp-ssh-controlmaster-options (concat "-o SendEnv TRAMP=yes " tramp-ssh-controlmaster-options))

    and that at the beginning of ~/.bashrc:

    if [ ! -z ${TRAMP-x} ] ; then return fi

    Another default of tramp is that it doesn't have a variable to pass random arguments to the ssh command, we have to piggy-back on tramp-ssh-controlmaster-options.

提交回复
热议问题