Search code examples
powershellpsreadline

How do I load SamplePSReadlineProfile.ps1 in my profile?


I'm new to PowerShell and installed PSReadline (via PsGet). Now I want to add the sample key binding in my profile file, should I just copy & paste the contents or is it better to load the file? How do I do that?


Solution

  • I would copy and paste the custom bindings that you want into your profile. The SamplePSReadline.ps1 script is meant to give a whole bunch of examples for folks to figure out how to write their own custom handlers. I would make sure you put the Import-Module command and custom bindings inside the if test that makes sure you're in the ConsoleHost.

    if ($host.Name -eq 'ConsoleHost') {
        Import-Module PSReadline
        ...
    }