X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



275 Rate this article:
No rating

How to back-up an active session’s command history without closing IDL

Background Information:

The Command History in IDL tracks the recent commands you've entered in the IDL Console. It's a handy tool for reviewing, reusing, or editing past commands without having to retype them. Just use the up and down arrow keys to sift through prior commands. In the IDL Workbench, the Command History can also be viewed in a tab to the right of the Console. You can read more about IDL’s Command History functionality HERE

 

Problem:

While IDL is running, recent commands are stored in the command recall buffer (i.e. in system memory). When IDL closes, those commands are written to disk into a user specific text file within your .idl directory:

  • Windows: C:\Users\YourUsername\.idl\idl\rbuf\history
  • Mac OS: /Users/YourUsername/.idl/idl/rbuf/history
  • Linux: /home/yourusername/.idl/idl/rbuf/history

Subsequent IDL invocations read this history file to initialize their buffer.

However, it's important to note that IDL only writes the contents of its command recall buffer to this history file when IDL closes gracefully. Thus, if the IDL session unexpectedly terminates, whether it be an IDL crash or a system shutdown or power outage, any commands entered in that session will be lost.

 

Work-around:

Unfortunately, there isn't really a way to force IDL to write the contents of the command history buffer into the history file on demand while the session is actively running.

However, you can use the RECALL_COMMANDS function to manually save the contents of the session's active command buffer to a (separate) file through a custom routine. Perhaps something like this:

PRO exportCommandHistory
   fName = 'command_history.pro'
   OPENW,unit,fName,/GET_LUN
   PRINTF,unit,RECALL_COMMANDS(),FORMAT='(a)'
   FREE_LUN,unit
   PRINT, 'Command History Saved to File: '+fName
END

WARNING: Do not try to overwrite the default IDL command history file inside of the .idl folder using this method. This will not work and may cause your existing command history to be lost or corrupted. 


To automatically and periodically save the contents of the command history buffer to a file while IDL is running, this can all be set it up inside of an asynchronous TIMER block. Something like this:

 

PRO exportCommandHistory, id, userData
   fName = 'command_history.pro'
   OPENW,unit,fName,/GET_LUN
   PRINTF,unit,RECALL_COMMANDS(),FORMAT='(a)'
   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)

 

Finally, to configure the history-saving TIMER to run in the background every time IDL is launched, add that single timer command into your IDL startup script and make sure the "exportCommandHistory" routine is on your IDL search path.

 

HELPFUL TIP: Naming the output file with a .pro filename extension allows the file to be opened in the IDL Workbench. With this file open in the editor, selected commands can be executed directly (highlight, right-click, "Run Selected Text").  Also, if the file's contents are periodically updated by the TIMER, the Workbench editor will prompt you to refresh the content displayed whenever focus is returned to that editor window.

 

NOTE: While this work-around does archive your history of IDL commands entered in the active session, the created file on disk will not function like a true command history file. You won’t be able to bring up its contents into the IDL Console in any manner. It’s more for referencing and manually copying/pasting past commands if needed.

 

 

 

 

Created by BC-US (7/9/2025), Reviewed by JU (7/9/2025)

 

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »