MSH: Saving and Loading History

MSH keeps track of the various commands you execute.  You can view this history using get-history or the alias ghy.  You can invoke a command in history using invoke-history <number> or the alias ihy <number>.  One of the first things you may want to do is bump up the maximum history count from 64 to something more reasonable like say 256.  You can do this by adding this line to your profile:
 
$MaximumHistoryCount=256

Occasionally you might want to transfer you command history from one shell to another.  Here’s a couple of functions and aliases that allow you to easily do this:
 
set-alias shy Save-History
function Save-History {
    param ([string]$path = "${Home}\msh_history.xml")
    get-history -count $MaximumHistoryCount | export-clixml $path
}
 
set-alias lhy Load-History
function Load-History {
    param ([string]$path = "${Home}\msh_history.xml")
    import-clixml $path | add-history
}
Advertisements
This entry was posted in Monad. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s