David W.
David W.

Reputation: 107040

BASH: Getting history editing like Kornshell

Let's say I execute the following command in either BASH or Kornshell:

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

If I have vi set, and edit it in Kornshell, I get:

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

If I have vi set, and edit it in BASH, I get:

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

Is there a way I can get command line editing in BASH the same way Kornshell works?

Upvotes: 2

Views: 122

Answers (2)

William Pursell
William Pursell

Reputation: 212268

You need two things:

$ shopt -s cmdhist  # This is on by default, so probably unnecessary
$ shopt -s lithist  # This is off by default

Upvotes: 1

Sean Bright
Sean Bright

Reputation: 120644

You need to enable the lithist (literal history) option which tells bash to retain the newlines:

$ shopt -s lithist

Upvotes: 5

Related Questions