lastcmd <- function(){
tmp <- tempfile()
savehistory(tmp)
# If we call this function then that call will
# be the last line in the history so we want the one
# before that
tail(readLines(tmp), 2)[1]
}
http://stackoverflow.com/questions/18972845/get-last-top-level-command-as-a-character-string
http://stackoverflow.com/questions/18972845/get-last-top-level-command-as-a-character-string