Is it possible to duplicate a powershell session in a new window? I often find that I've created environment variables, activated a specific python virtualenvironment, defined one-off functions, custom prompt, etc. and it would be handy to duplicate those specific, one-off details of the current session into another session in another window.
2 Answers
You should use Powershell profile. In the profile you can have all of those functions, variables etc. Basically every time you open a powershell window, you can load your custom powershell profile which in turn will also load your settings as defined. Please see this link: Powershell profile.
- 4That totally does not answer the question as asked : "it would be handy to duplicate those specific, one-off details of the current session into another session". Profiles are for things you will always want set; this is a different scenario.mfinni– mfinni2014-10-07 16:36:28 +00:00Commented Oct 7, 2014 at 16:36
There's nothing I'm aware of, out of the box, that will do this. You could write a script to dump all of the things you care about, and then paste those into your new window.
get-childitem -path env: will show all your environment variables.
Get-Variable will show your powershell variables.
Get-ChildItem -path function: will show all functions. If you have a naming convention for your custom ones, you could filter on just those.