Emacs: Tramp doesn't work

前端 未结 6 1672
無奈伤痛
無奈伤痛 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:24

    If the account you're connecting to uses some weird fancy shell prompt, then there is a good chance that this is what makes tramp trip.

    Log in as root, then enter

    PS1="> "
    

    (that's a normal, standard shell (ZSH, BASH, younameit) prompt, one that tramp will understand) then switch to the user account, and launch emacs -q (to make sure that your .emacs is not causing this mess) and try to C-x C-f /sudo:root@localhost:/etc/hosts and see what's what.

    You can (not recommended) also customize the regexp that defines what tramp expects :

    M-x customize-variable RET tramp-terminal-prompt-regexp
    

    My approach :

    1. Make sure the variable tramp-terminal-type is set to "dumb"

    M-x customize-variable RET tramp-terminal-type

    1. Test that in your .*shrc and serve the correct prompt :
    case "$TERM" in
    "dumb")
        PS1="> "
        ;;
    xterm*|rxvt*|eterm*|screen*)
        PS1="my fancy multi-line \n prompt > "
        ;;
    *)
        PS1="> "
        ;;
    esac
    

提交回复
热议问题