Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
532 views
in Technique[技术] by (71.8m points)

ssh - Emacs: Tramp doesn't work

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

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

I get a message from Emacs

Tramp: Waiting for prompts from remote shell

Emacs hung and did not respond to any action after that

Emacs was installed on Windows; the remote file was on a Linux machine.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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 
 prompt > "
    ;;
*)
    PS1="> "
    ;;
esac

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...