Skip to content

Instantly share code, notes, and snippets.

@zimnyaa
Last active August 18, 2022 15:01
Show Gist options
  • Save zimnyaa/83a5bfc839effbcb5d0dd29a04d72647 to your computer and use it in GitHub Desktop.
Save zimnyaa/83a5bfc839effbcb5d0dd29a04d72647 to your computer and use it in GitHub Desktop.
Dump history from a running bash process
#Effectively trigger history -a:
$ gdb -p PID -batch -ex 'call maybe_append_history(get_string_value("HISTFILE"))'
#Dump the last 10 history entries to your local terminal (pty)
$ gdb -p PID -batch -ex 'call append_history(10, "'$(tty)'")'
#Backup the entire history to a temporary file:
$ gdb -p PID -batch -ex 'call write_history("/tmp/history-backup.txt")'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment