如何使用sed命令编辑Nano的rcfile(界面元素颜色)

rfgamaral

这是我的nanorc文件的一个示例

(...)
## Detect word boundaries differently by treating punctuation
## characters as parts of words.
# set wordbounds

## The characters (besides alphanumeric ones) that should be considered
## as parts of words.  This option does not have a default value.  When
## set, it overrides option 'set wordbounds'.
# set wordchars "<_>."


## Paint the interface elements of nano.  These are examples;
## by default there are no colors, except for errorcolor.
# set titlecolor brightwhite,blue
# set statuscolor brightwhite,green
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,magenta
# set numbercolor cyan
# set keycolor cyan
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor brightwhite,magenta
# set statuscolor brightwhite,magenta
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,cyan
# set numbercolor magenta
# set keycolor brightmagenta
# set functioncolor magenta


## Setup of syntax coloring.
##
## Format:
##
## syntax "short description" ["filename regex" ...]
(...)

我需要将## Paint the interface elements of nano.更改为此:

## Paint the interface elements of nano.  These are examples;
## by default there are no colors, except for errorcolor.
set titlecolor brightwhite,blue
set statuscolor brightwhite,green
set errorcolor brightwhite,red
set selectedcolor brightwhite,magenta
set numbercolor cyan
set keycolor cyan
set functioncolor green

换句话说,取消注释第一个颜色块并删除第二个颜色块(仅建议用于根颜色.nanorc)。

如何使用sed命令实现这一目标?如果使用多个sed命令(而不是一个大命令)使之更简单易读,则我更愿意这样做。

αғsнιη

尝试:

sed "/## Paint the interface elements of nano./,/^$/ \
     {s/^# //; /## In root's .nanorc you might want to use:/,/^$/d}" infile

这将查找## Paint the interface elements of nano.第一个空行之间的行,然后从哈希空间开始取消注释这些行# ,并删除该行之间的其他所有内容,## In root's .nanorc you might want to use:直到最初在同一块中找到空白行为,我们通常{...}sed-编写我们需要的块的脚本sed如果与sed默认操作的条件不匹配,则将打印其他所有行

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章