键入 Ctrl-D (EOF) 时如何防止 iterm2 关闭 [英] How to prevent iterm2 from closing when typing Ctrl-D (EOF)

查看:51
本文介绍了键入 Ctrl-D (EOF) 时如何防止 iterm2 关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用鱼壳.当我输入 Ctrl-D 时,它会向我的终端发送一个 EOF,然后终端关闭.

I am using fish shell. When I type Ctrl-D, it sends a EOF to my terminal and then terminal closes.

我想让 ctrl-D 不会关闭我的 iterm2.

I want to make it such that ctrl-D does not close my iterm2.

我看到人们在 bash shell 中设置了 IGNOREEOF,如下所示:https://unix.stackexchange.com/questions/27588/how-can-i-keep-controld-from-disconnecting-my-session

I saw that people have set up IGNOREEOF in bash shell like this: https://unix.stackexchange.com/questions/27588/how-can-i-keep-controld-from-disconnecting-my-session

不过,我不认为这个变量存在于鱼中.有谁知道我如何强制 iterm2(带有默认鱼壳)在 ctrl-D 上不关闭?

However, I don't think this variable exists in fish. Does anybody know how I can force iterm2(with default fish shell) to not close on ctrl-D?

推荐答案

这是 control-D 的默认键绑定:

This is the default key binding for control-D:

bind \cd delete-or-exit

你可以通过运行 bind 找到它.

you can find this by just running bind.

(delete-or-exit 只是一个函数,你可以用 functions delete-or-exit 读取.)

(delete-or-exit is just a function, which you can read with functions delete-or-exit.)

所以它正在退出,因为这是默认行为.您可以让 control-D 做其他事情.例如,也许它应该删除光标下的字符:

So it's exiting because that's what the default behavior is. You can make control-D do something else. For example, maybe it should delete the character under the cursor:

bind \cd delete-char

如果您想让它永久化,请将其添加到您的 fish_user_key_bindings 函数中:

If you want to make this permanent, add it to your fish_user_key_bindings function:

  1. 运行 funced fish_user_key_bindings 开始编辑
  2. bind \cd delete-char 放入函数中
  3. 点击回车创建函数
  4. 运行funcsavefish_user_key_bindings保存
  1. Run funced fish_user_key_bindings which starts editing
  2. Put bind \cd delete-char within the function
  3. Hit return to create the function
  4. Run funcsave fish_user_key_bindings to save it

这篇关于键入 Ctrl-D (EOF) 时如何防止 iterm2 关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆