Unfortunately there isn't a way to force the command history into the default IDL history file on demand. It only saves the current command history buffer when IDL closes gracefully. However, you can use the RECALL_COMMANDS function to manually save the contents of the session's active command buffer to a (separate) file. You could create a custom routine procedure that can be called anytime you want to export your command buffer. Something like this: PRO exportCommandHistory fName = 'command_history.txt' openw,unit,fName,/GET_LUN printf,unit,RECALL_COMMANDS() free_lun,unit print, 'Command History Saved to File: '+fName END If you want to automate this saving of the buffer, you could set it up inside an asynchronous TIMER block: https://www.nv5geospatialsoftware.com/docs/TIMER.html Something like this: PRO exportCommandHistory, id,userData fName = 'command_history.txt' openw,unit,fName,/GET_LUN printf,unit,RECALL_COMMANDS() free_lun,unit print, 'Command History Saved to File: '+fName END id = Timer.Set(300, 'exportCommandHistory',/REPEAT) ;command history exported to file every 5 minutes (300 sec) If you want the history saving timer to be running in the background every time you launch IDL, you may consider adding it to your IDL startup script, which I think should work but I haven't tested that. Finally, instead of writing to a custom output file, you could instead write to IDL's default history file (~\.idl\idl\rbuf\history). This has not been tested and could possibly corrupt your history file. Use with caution.
|