BASH:像Kornshell一样编辑历史

BASH:像Kornshell一样编辑历史,bash,Bash,假设我在BASH或Kornshell中执行以下命令: $ foo | while read line > do > echo "Line = '$line'" > done 如果我设置了vi并在Kornshell中编辑它,我会得到: foo | while read line do echo "Line = '$line'" done 如果我设置了vi并在BASH中编辑它,我会得到: foo | while read line;do; echo "Li

假设我在BASH或Kornshell中执行以下命令:

$ foo | while read line
> do
>    echo "Line = '$line'"
> done
如果我设置了
vi
并在Kornshell中编辑它,我会得到:

foo | while read line
do
     echo "Line = '$line'"
done
如果我设置了
vi
并在BASH中编辑它,我会得到:

foo | while read line;do;    echo "Line = '$line'";done

有没有一种方法可以像Kornshell一样在BASH中进行命令行编辑?

您需要启用
lithist
(文字历史记录)选项,该选项告诉BASH保留换行符:

$ shopt -s lithist
你需要两件事:

$ shopt -s cmdhist # This is on by default, so probably unnecessary $ shopt -s lithist # This is off by default $shopt-s cmdhist#默认情况下此选项处于启用状态,因此可能不需要 $shopt-s lithist#默认情况下此选项处于禁用状态
谢谢我知道它必须是一个
shopt
设置,但不知道是哪一个。