Take the 2-minute tour ×  Is this possible? I've finally decided
to start setting up my personal .NET development environment to
closer mimic how I'd set up a *NIX dev environment, which means
learning Powershell in earnest.  I'm currently writing a
function that recurses through the file system, setting the
working directory as it goes in order to build things. One
little thing that bothers me is that if I Ctrl+C out of the
function, it leaves me wherever the script last was. I've tried
setting a trap block that changes the dir to the starting point
when run, but this seems to only be intended (and fire) on
Exception.  If this were in a language that had root in Unix,
I'd set up a signal handler for SIGINT, but I can't find
anything similar searching in Powershell. Putting on my .NET
cap, I'm imagining there's some sort of event that I can attach
a handler to, and if I had to guess, it'd be an event of $host,
but I can't find any canonical documentation for
System.Management.Automation.Internal.Host.Internal