Skip to content

About . $PROFILE

TIP

  • . $PROFILE will reload your PowerShell profile.
  • This affects the completion menu provided by PSCompletions.
  • Therefore, after running . $PROFILE, you need to run psc again to reload the completion menu.
  • This is the simplest solution and applies to all the following situations.

psc menu config enable_menu 1

  • PSCompletions provides its completion menu in the following way:

    • <Key> is the value of psc menu config trigger_key (default: Tab)
    powershell
    Set-PSReadLineKeyHandler -Key <Key> -ScriptBlock {
      # ...
    }
  • However, after running . $PROFILE:

    • PowerShell automatically resets the key binding:
      powershell
      Set-PSReadLineKeyHandler -Key Tab -Function TabCompleteNext
    • Since the module is already loaded, the key-binding logic inside the module is not re-executed.
    • As a result, the completion menu key binding is overridden by TabCompleteNext and becomes ineffective.
  • Therefore, you need to run psc to reapply the key bindings.


psc menu config enable_menu 0

  • PSCompletions use MenuComplete in the following way:

    • <Key> is the value of psc menu config trigger_key (default: Tab)
    powershell
    Set-PSReadLineKeyHandler -Key <Key> -Function MenuComplete
  • However, after running . $PROFILE:

    • PowerShell automatically resets the key binding:

      powershell
      Set-PSReadLineKeyHandler -Key Tab -Function TabCompleteNext
    • Since the module is already loaded, the key-binding logic inside the module is not re-executed.

    • As a result, it is overridden by TabCompleteNext and becomes ineffective.

  • Therefore, you need to run psc to reapply the key bindings.


NOTE

  • In this case, you can explicitly define the key binding in $PROFILE to avoid this issue:

    powershell
    Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete
  • It should be placed before Import-Module PSCompletions

  • Refer to Import Statement Order.