Profile scripting best practices #168
Replies: 4 comments
-
I tend to dot source my profiles anyway. I usually keep them in onedrive and then my normal profile just dot sources the onedrive ones. I should probably just investigate using junctions or something instead. I do like the idea and naming you have used. |
Beta Was this translation helpful? Give feedback.
-
I can't think where to put this, but it's worth discussing ... and documenting. |
Beta Was this translation helpful? Give feedback.
-
I also have one for Posh-git - Posh-Git_config.ps1. |
Beta Was this translation helpful? Give feedback.
-
Posh-Git definitely needs one. This would make for a lot of utility, especially if people are writing generally-useful things to put in their profile and are releasing them as scripts on the gallery. |
Beta Was this translation helpful? Give feedback.
-
I'm not sure where this belongs or if it even belongs in this repo but... Most of us probably have pretty complex profile scripts. My PSReadline custom configuration alone is over 200 lines. So I've taken to moving those "module-specific" configurations out into a separate file that sits by my profile.ps1 file. It is called "PSReadline_config.ps1" - I've seen this approach with Bash (.bash_aliases). I was thinking something like
<ModuleOrDescription>_config.ps1
. Then in your profile script you just dot source it in like so:This has made it easier for me to share my PSReadline config with others.
BTW there is probably some best practices around "which" profile scripts to use. I'm old school and use the current user all hosts script and for PSReadline I check against the host name. I should probably use the console's profile
Microsoft.PowerShell_profile.ps
and ditch theif ($host.Name -eq 'ConsoleHost')
check.Beta Was this translation helpful? Give feedback.
All reactions