bash - 如何使 bash 的“绑定”命令完全不可见?
问题描述
我的 中有以下几行.bashrc
:
# C-Z shortcut can be used to take a suspended job to fg
stty susp undef
bind '"\C-z":" fg >/dev/null 2>&1 \015"'
这样做的目的是使绑定C-Z
更好地挂起 Vim(正如它在 Vim 中已经默认所做的那样),然后C-Z
在 bash 命令行界面中使用以立即返回到 Vim。
这似乎工作得很好,除了一件事:
me:~$ vim ~/.bashrc
[1]+ Stopped vim ~/.bashrc
me:~$ fg >/dev/null 2>&1
me:~$ fg >/dev/null 2>&1
me:~$ fg >/dev/null 2>&1
me:~$ fg >/dev/null 2>&1
me:~$ fg >/dev/null 2>&1
me:~$
fg >/dev/null 2>&1
每次都出现。有没有办法让这个绑定“静默”,这样就根本不显示输出?许多指南使用 zsh 或 fish 来实现这种行为,但我希望坚持使用 bash。
解决方案
这应该适合你:
stty susp undef
bind -x '"\C-z":"fg >/dev/null 2>&1"'
请记住,这可能不是一个好主意,因为它会阻止您暂停大多数其他程序。
推荐阅读
- laravel - 在 Laravel 中向数据透视表添加数据
- angular - Angular:如何以简单的方式组合数据结构
- python - pyqt5 获取 html 崩溃
- r - 如何制作用于进行线性回归并将输出写入 Excel 的函数?
- django - 无法使用 git pull heroku master 从 heroku 中提取所有媒体文件
- r - 如何从方阵中为任何想要的细胞数量进行系统抽样?
- node.js - Node.js在嵌套函数中设置变量
- c++ - std::atomic 怎么样
::operator= 为不可变类型实现? - sabre - 获取 sabre getResarvationRQ 的行程、乘客预订和报价
- python - tkinter PhotoImage 是否总是被重新定义?