Multiline R commands are only partially shown in the command line history

See https://stackoverflow.com/questions/16226216/r-command-history-how-to-configure-up-arrow-to-treat-multiline-brace-enclosed

For instance

f <- function(x) # press Ctrl+v Ctrl+j NOT shift+enter
x^2

What you are looking for is not possible in my understanding using the R terminal from bash