My end goal is capture the previous command executed in the terminal. Since ~/.bash_history doesn\'t include commands from the current terminal session, I can\'t simply read
why don't you read the file directly. ~/.bash_history
for history in open('/home/user/.bash_history'): print(history, end='')