Reputation: 58488
When I use the command line I can recall history by using C-P or up arrow. However this does not work when trying to recall input to a here-document.
# cat <<!
> a
> b
> c
> !
a
b
c
# cat <<! # C-p to get here, expected to see ! as last input. C-c to break out
# history 2
2053 cat <<!
2054 history 2
I'm using rxvt.
P.S. This feature works correctly when using shell
within emacs
Upvotes: 2
Views: 565
Reputation: 16044
I have the same problem. Bash 3.2.49(1)-release
psql <<EOF
SELECT * FROM blah;
EOF
My history only preserves the first line. I have got cmdhist (and lithist) set, and they work fine for other multi-line commands, but not for heredocs. Tragic.
A workaround is:
echo "
SELECT *
FROM blah
" | psql
Upvotes: 2
Reputation: 31
shopt -s cmdhist
cat <<!
a
b
c
!
history | tail ...
8580 cat <<!
a
b
c
!
The cmdhist shell option, if enabled, causes the shell to attempt to save each line of a multi-line command in the same history entry, adding semicolons where necessary to preserve syntactic correctness.
The lithist shell option causes the shell to save the command with embedded newlines instead of semicolons.
From man bash
Upvotes: 2