让 Emacs ansiterm 和 Zsh 更好地发挥作用

发布于 2024-07-09 14:31:09 字数 622 浏览 7 评论 0原文

我一直在尝试在 emacs 会话中使用 Zsh,而无需 emacs 重新映射所有 Zsh 键。 我发现 ansi-term 对此非常有效,但是我仍然遇到一些问题。 我输出了很多垃圾字符,我能够用以下方法修复它:

## Setup proper term information for emacs ansi-term mode
[[ $TERM == eterm-color ]] && export TERM=xterm

但一切仍然不能完美地工作。 现在,我在将输出绘制到屏幕外时遇到问题,尤其是在使用 Cr 之类的搜索时。

我发现如果你不调整窗口大小它就可以正常工作。 我可以像这样重现它:

  1. 启动一个干净的emacs -q
  2. 启动ansi-term并使用zsh
  3. 使窗口全屏
  4. 输出填充屏幕的内容
  5. 类型Cr
  6. 提示将不在屏幕上

也许有某种方法可以使输出和迷你缓冲区之间的空间更大以补偿超调?

还有人让 Zsh + Ansi term 正常工作吗?

I've been trying to use Zsh within my emacs session, without emacs remapping all the Zsh keys. I found ansi-term works pretty well for this but, I'm still having some problems. I was getting lots of junk characters outputted with, I was able to fix it with:

## Setup proper term information for emacs ansi-term mode
[[ $TERM == eterm-color ]] && export TERM=xterm

But everything still doesn't work perfectly. Now I am having trouble with output being drawn offscreen , especially when using something like C-r for search.

What I found is that it works fine if you don't resize the window. I can reproduce it like:

  1. Launch a clean emacs -q
  2. Start ansi-term and use zsh
  3. Make window fullscreen
  4. Output something that fills the screen
  5. Type C-r
  6. The prompt will be off the screen

Maybe there is some way I can make the space between the output and the minibuffer larger to compensate for the overshoot?

Anyone else have Zsh + Ansi-term working properly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

心的憧憬 2024-07-16 14:31:09

尝试 MultiTerm

它是唯一可以与 zsh 配合良好的 Emacs 终端模式。 它允许您轻松设置要由 emacs 捕获的命令以及要路由到终端的命令。 到目前为止,默认设置对我来说已经足够好了。

另外,将以下内容添加到 .zshrc 中,以允许 emacs 在您 cd 时跟踪当前目录。

if [ -n "$INSIDE_EMACS" ]; then
  chpwd() { print -P "\033AnSiTc %d" }
  print -P "\033AnSiTu %n"
  print -P "\033AnSiTc %d"
fi

Try MultiTerm.

Its the only Emacs terminal mode that seems to play nice with zsh. It allows you to easily set which commands you want captured by emacs and which you want routed to the terminal. The default settings have been good enough for me so far though.

Also, add the following to your .zshrc to allow emacs to track your current directory as you cd around.

if [ -n "$INSIDE_EMACS" ]; then
  chpwd() { print -P "\033AnSiTc %d" }
  print -P "\033AnSiTu %n"
  print -P "\033AnSiTc %d"
fi
┼── 2024-07-16 14:31:09

嗯。 我认为我从未见过任何花哨的编辑在 ansi-term 中表现良好,尽管我可能已经有 20 年没有尝试过了。 顺便问一下,您是否尝试过 shell 模式(Mx shell),因为无论如何,使用 EMACS 会更自然。

也就是说,通读 term.el 文件,看起来 ansi-term 正在做很多自己的管理。 您可能需要查看术语“原始模式代码”,从第 1230 行左右开始,至少在 EMACS 22.3 中是这样。

Hmmm. I don't think I've ever seen any fancy editing work out well within ansi-term, although I haven't tried it in maybe 20 years. I'll just ask, in passing, if you've tried shell-mode (M-x shell) as it's a lot more natural with EMACS anyway.

That said, reading through the term.el file, it kind of looks like ansi-term is doing a lot of manging of its own. you might want to look at the term raw mode code, starting around line 1230, at least in EMACS 22.3.

长梦不多时 2024-07-16 14:31:09

我也一直在寻找这个。 对我来说,在作品中添加以下内容

;; ansi-term

(global-set-key "\C-x\C-a" '(lambda ()(interactive)(ansi-term "/bin/zsh")))
(global-set-key "\C-x\ a" '(lambda ()(interactive)(ansi-term "/bin/zsh")))

。 我从
http://svn. assembla.com/svn/id774/scripts/dot_files/dot_emacs.d/elisp/global-set-key.el

我确信该脚本中还有其他优点。 作为一个额外的奖励屏幕,对我来说,emacs 似乎运行得很好。

I was looking for this as well for quite a while now. For me adding following to the

;; ansi-term

(global-set-key "\C-x\C-a" '(lambda ()(interactive)(ansi-term "/bin/zsh")))
(global-set-key "\C-x\ a" '(lambda ()(interactive)(ansi-term "/bin/zsh")))

works. I picked this from
http://svn.assembla.com/svn/id774/scripts/dot_files/dot_emacs.d/elisp/global-set-key.el .

I am sure there are other goodies in that script. As an added bonus screen seems to play nicely with emacs for me.

抱着落日 2024-07-16 14:31:09

我想到了。 这是一个 emacs 配置问题。 我的 .emacs 中的这一点 elisp 导致了它:

(custom-set-variables
 '(fringe-mode nil nil (fringe))
 '(fringes-outside-margins t t))

感谢您的帮助。

I figured it out. It was an emacs config problem. This bit of elisp in my .emacs was causing it:

(custom-set-variables
 '(fringe-mode nil nil (fringe))
 '(fringes-outside-margins t t))

Thanks for the help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文