Last active
August 18, 2022 15:01
-
-
Save zimnyaa/83a5bfc839effbcb5d0dd29a04d72647 to your computer and use it in GitHub Desktop.
Dump history from a running bash process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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