question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support non-script based file configuration of options

See original GitHub issue

Relying on profile.ps1 may not fit scenarios where we want to set-executionpolicy to ban scripts.

Would it be possible to populate options from the registry or json file? I would image modifying PSConsoleReadlineOptions is all that it takes?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lzybkrcommented, Feb 23, 2018

Oh, @nightroman was just suggesting you still use a ps1 file like you would today, but PSReadLine would invoke it in a way that is not affected by the execution policy.

I use the following pattern in my profile to make it feel more like a configuration and less like calling a bunch of commands:

$options =
@{
    PromptText = '> '
    AddToHistoryHandler = {
        param([string]$line)
        return $line.Length -gt 3 -and $line[0] -ne ' ' -and $line[0] -ne ';'
    }
    HistorySavePath = "${env:HOMEDRIVE}${env:HOMEPATH}/PSReadLine_history.txt"
    EditMode = 'Emacs'
    ExtraPromptLineCount = 1
    Colors = @{
        Error = "$([char](0x1b))[44;91m"
    }
}
Set-PSReadLineOption @options

I suppose one option is to mimic the module manifest, basically remove the first and last lines in my example above, then apply the options. This would also need to allow specifying key bindings, maybe like:

@{
    KeyBindings = @{
        UpArrow = 'HistorySearchBackward'
        DownArrow = 'HistorySearchForward'
        'Alt+F1' = @{
            BriefDescription = 'CommandHelp'
            LongDescription = 'Open the help window for the current command'
            ScriptBlock = { ... }
        }
    }
}
0reactions
bgshacklettcommented, Feb 23, 2018

There’s precedent for this kind of configuration data in .psd1 files with DSC as well: https://docs.microsoft.com/en-us/powershell/dsc/separatingenvdata

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support non-script based file configuration of options #635
When I originally considered the problem of configuration, I settled on script because I hated xml. I still hate xml, but it might...
Read more >
TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
Read more >
Configuration (GNU Coding Standards)
The configure script should write a file named config.status which describes which configuration options were specified when the program was last configured.
Read more >
MySQL 8.0 Reference Manual :: 4.2.2.2 Using Option Files
Most MySQL programs can read startup options from option files (sometimes called configuration files). Option files provide a convenient way to specify ...
Read more >
Load external configuration files | Filebeat Reference [8.9]
Filebeat can load external configuration files for inputs and modules, allowing you to separate your configuration into multiple smaller configuration files ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found