开发者

Trying to get a terminal to work in Emacs

开发者 https://www.devze.com 2022-12-12 03:26 出处:网络
I\'ve been having a lot of problems with emacs and trying to get the terminal to work with: M-x term I installed cygwin and I fixed up my .emacs to include the paths:

I've been having a lot of problems with emacs and trying to get the terminal to work with:

    M-x term

I installed cygwin and I fixed up my .emacs to include the paths:

    (setenv "PATH" (concat "c:/cygwin/bin;" (getenv "PATH")))
    (setq exec-path (cons "c:/cygwin/bin" exec-path))
    (require 'cygwin-mount)
    (cygwin-mount-activate)
    (add-hook 'comint-output-filter-functions
    'shell-strip-ctrl-m nil t)
    (add-hook 'comint-output-filter-functions
    'comint-watch-for-password-prompt nil t)
    (setq explicit-shell-开发者_如何学Cfile-name "bash.exe")
    ;; For subprocesses invoked via the shell
    ;; (e.g., "shell -c command")
    (setq shell-file-name explicit-shell-file-name)

However now when I launch terminal, it seems to give nothing but a blank screen and "hang"

When I launch:

    M-x shell

It does indeed launch the bash shell and flying around the file directories is okay (with cd, ls, cp, rm, etc.). However, when I do something like try to open up a Python shell, it again hands, and I type in ... and the shell crashes. Is there anything significantly wrong with what I am doing or perhaps somebody could direct me towards solutions online? (I've looked quite extensively.)

SSH also gives the error:

"Pseudo-terminal will not be allocated because stdin is not a terminal."


Are you using the default 'Cygwin Bash Shell'? This is the one that launches inside a Windows cmd shell, and you can't drag to resize the screen. This shell is horribly broken, because of the underlying Windows component. Try using something like rxvt, or one of the putty forks.

If this is all set, then the issue is likely a termcap issue. Some people set their Cygwin TERM variable to 'xterm', because many remote machines don't have termcaps installed for things like rxvt-cygwin-native. Overridding it locally will cause problems with programs that attempt a range of terminal operations.

In your ~/.bash_profile, you can set your terminal to the following. export TERM=rxvt-cygwin-native

See my rxvt install guide and tips for more on rxvt.


SSH also gives the error:

"Pseudo-terminal will not be allocated because stdin is not a terminal."

To solve this problem in NTEmacs (NOT cygwin's emacs), I did the following:

  1. Install cygwin's gcc
  2. Use it to compile fakecygpty.c into fakecygpty.exe
  3. Run fakecygpty ssh my_server instead of just ssh my_server in an emacs shell (easiest if fakecygpty is on your path).

I tested this in *shell* running cmd, cygwin bash, and git bash, and they all work fine. My understanding is that fakecygpty.c present NTEmacs as a valid cygwin tty so that ssh is willing to talk to it. More information about fakecygpty and SSH with ntemacs.


You can also make NTEmacs edit files properly over SSH by adding this to init.el:

(eval-after-load "tramp"
  '(progn
     (add-to-list 'tramp-methods
                  (mapcar
                   (lambda (x)
                     (cond
                      ((equal x "sshx") "cygssh")
                      ((eq (car x) 'tramp-login-program) (list 'tramp-login-program "fakecygpty ssh"))
                      (t x)))
                   (assoc "sshx" tramp-methods)))
     (setq tramp-default-method "cygssh")))

I also needed to update my Tramp to 2.2.7 to be able to edit files over ssh from ntemacs.

Hope this saves someone some trouble. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消