2009-11-24 73 views
3

我一直有很多与emacs的问题,并试图让终端一起工作的工作:试图让一个终端在Emacs

M-x term 

我安装了Cygwin和我定了我的.emacs包括路径:

(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-file-name "bash.exe") 
    ;; For subprocesses invoked via the shell 
    ;; (e.g., "shell -c command") 
    (setq shell-file-name explicit-shell-file-name) 

但是现在,当我启动终端,它似乎给什么,但一个空白的屏幕和“挂”

当我启动:

M-x shell 

它确实启动了bash shell并且在文件目录周围飞行是可以的(使用cd,ls,cp,rm等)。但是,当我尝试打开一个Python shell之类的东西时,它会再次提交,然后输入...并且shell崩溃。我在做什么或者有人可以指导我在线解决方案,是否有什么重大错误? (我已经相当广泛地看着。)

SSH还给出了错误:

“伪终端不会被分配,因为标准输入不是终端。”

回答

3

您是否使用默认的'Cygwin Bash Shell'?这是在Windows cmd shell中启动的,不能拖动来调整屏幕大小。由于底层的Windows组件,这个shell非常糟糕。尝试使用类似rxvt或其中一种腻子叉子。

如果这是全部设置,那么问题可能是termcap问题。有些人将他们的Cygwin TERM变量设置为'xterm',因为许多远程机器没有为rxvt-cygwin-native之类的东西安装termcap。在本地重写它会导致尝试一系列终端操作的程序出现问题。

在您的〜/ .bash_profile中,您可以将您的终端设置为以下。 export TERM=rxvt-cygwin-native

有关rxvt的更多信息,请参阅我的rxvt install guide and tips

+0

无法通过.emacs设置rxvt ...说'-i不是选项'并列出可能的选项。 TERM变量的默认设置是什么?我发现在线资源说它设置为CYGWIN,但是,我不知道这是批处理文件还是其他隐藏文件?我猜,很难在emacs中获得一个shell。尽管感谢了很多输入! – mduvall 2009-11-25 01:07:46

1

SSH also gives the error:

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

要NTEmacs(不Cygwin的emacs的)解决了这个问题,我做了以下内容:

  1. 安装cygwin的GCC
  2. 用它来编译fakecygpty.c到fakecygpty.exe
  3. 运行fakecygpty ssh my_server而不是仅仅在emacs外壳中使用ssh my_server(如果fakecygpty在你的路径上最简单)。

我在*shell*运行cmd,cygwin bash和git bash测试了它,它们都正常工作。我的理解是,fakecygpty.c将NTEmacs作为有效的cygwin tty呈现,以便ssh愿意与它交谈。 More information about fakecygpty and SSH with ntemacs.


你也可以通过添加这初始化使NTEmacs编辑文件正确通过SSH。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"))) 

我还需要将我的Tramp更新到2.2.7,以便能够通过ntemacs在ssh上编辑文件。

希望这可以为别人节省一些麻烦。 :)