I have enabled the shell options for multi-line command history like this
shopt -s lithist
shopt -s cmdhist
and it works well in current terminal
bash$ history
8651 echo history test 1
8652 echo history test 2
8653 echo history test 3
8654 cat << EOF
111
222 # multi-line command history works well
333
EOF
if i opened new terminal then the multi-line commands all changed to
single lines like this
bash$ history
7819 echo history test 1
7820 echo history test 2
7821 echo history test 3
7822 cat << EOF
7823 111 # the multi-line
commands changed to single lines
7824 222
7825 333
7826 EOF
7827 history
Chet Ramey
unread,
Aug 17, 2020, 10:10:39 AM8/17/20
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Hyunho Cho, bug-...@gnu.org, chet....@case.edu
When you enable `lithist', each line of a multi-line command is saved to
the history list with a trailing newline, and written to the history file
as a separate line. With the traditional readline history file format,
that makes each line a separate history entry unless the application uses
a delimiter to logically separate commands. With bash, that delimiter is
the timestamp that is controlled by HISTTIMEFORMAT.
Here are a couple of messages that explain the issue in detail: