ITPub博客

首页 > Linux操作系统 > Linux操作系统 > [20260618]bash 5.X与inputrc设置相关问题.txt

[20260618]bash 5.X与inputrc设置相关问题.txt

原创 Linux操作系统 作者:lfree 时间:2026-06-30 21:17:52 0 删除 编辑

[20260618]bash 5.X与inputrc设置相关问题.txt

--//最近安装虚拟机器centos 9,在拷贝和粘贴时,发现如果多行命令,里面会显示^J.
--//并且如果仅仅一行的内容选择整行内容也会出现这种现象,并且显示也是反转的风格,就是白底黑字,有点不习惯。

mkdir /u01/app/oracle
cd /u01/app/oracle

--//选择两行,拷贝和粘贴如下:
$ mkdir /u01/app/oracle^Jcd /u01/app/oracle^J
--//显示保持反转白底黑字。

--//如果选择1行到行尾,显示:
$ mkdir /u01/app/oracle

--//如果选择1行,一般按方向键向下箭头,显示:
$ mkdir /u01/app/oracle^J

--//看了文档,发现参数enable-bracketed-paste控制这个行为:
--//参考链接 :https://relentlesscoding.com/posts/readline-transformation/

Safe Pasting with Bracketed Paste

If you copy commands from the web, you might have noticed that when you copy a newline, Bash will interpret that newline
as an Enter and execute whatever it is in your input buffer at the moment. This is unsafe, because what you see might
not be what you copy. You can be avoided by setting:

set enable-bracketed-paste On

This command puts an escape sequence around what you copy and paste, so Bash can tell the difference between what you,
the user types and what you copied from somewhere.

The default is Off.

--//操作安全的需要,设置这个功能。估计早期版本并不是设置on,我现在安装的版本打开了缺省设置是on。

$ bash --version
GNU bash, version 5.1.8(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

$ man bash
....

enable-bracketed-paste (On)
    When set to On, readline will configure the terminal in a way that will enable it to insert each paste into the
    editing buffer as a single string of characters, instead of treating each character as if it had been read from  the
    keyboard.   This  can  prevent pasted characters from being interpreted as editing commands.

--//将如下内容写入/etc/inputrc:
set enable-bracketed-paste off

--//问题消失。重新读取/etc/inputrc文件不用退出,按ctrl+x,ctrl+r。
--//我个人并不是反对这个功能,仅仅觉得反转的显示风格有点不好接受,就是白底黑字,这样比较费眼力,有点不习惯。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-3174925/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969328