Skip to content

Profile scripting best practices #38

@rkeithhill

Description

@rkeithhill

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:

. $PSScriptRoot\PSReadline_config.ps1

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 the if ($host.Name -eq 'ConsoleHost') check.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions